mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 17:23:15 -05:00
Make SDK-style project a checkbox option instead of separate template (#18698)
* switch to using a checkbox instead of separate template for new SDK style project * let project provider provide sdk learn more url * Reorder
This commit is contained in:
@@ -49,6 +49,8 @@ export const SelectProjectType = localize('dataworkspace.selectProjectType', "Se
|
||||
export const SelectProjectLocation = localize('dataworkspace.selectProjectLocation', "Select Project Location");
|
||||
export const NameCannotBeEmpty = localize('dataworkspace.nameCannotBeEmpty', "Name cannot be empty");
|
||||
export const TargetPlatform = localize('dataworkspace.targetPlatform', "Target Platform");
|
||||
export const SdkStyleProject = localize('dataworkspace.sdkStyleProject', "SDK-style project (Preview)");
|
||||
export const LearnMore = localize('dataworkspace.learnMore', "Learn More");
|
||||
|
||||
//Open Existing Dialog
|
||||
export const OpenExistingDialogTitle = localize('dataworkspace.openExistingDialogTitle', "Open Existing Project");
|
||||
|
||||
@@ -74,8 +74,9 @@ export interface IWorkspaceService {
|
||||
* @param location The location of the project
|
||||
* @param projectTypeId The project type id
|
||||
* @param projectTargetPlatform The target platform of the project
|
||||
* @param sdkStyleProject Whether or not the project is SDK-style
|
||||
*/
|
||||
createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetPlatform?: string): Promise<vscode.Uri>;
|
||||
createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetPlatform?: string, sdkStyleProject?: boolean): Promise<vscode.Uri>;
|
||||
|
||||
/**
|
||||
* Clones git repository and adds projects to workspace
|
||||
|
||||
11
extensions/data-workspace/src/dataworkspace.d.ts
vendored
11
extensions/data-workspace/src/dataworkspace.d.ts
vendored
@@ -67,8 +67,9 @@ declare module 'dataworkspace' {
|
||||
* @param location the parent directory of the project
|
||||
* @param projectTypeId the identifier of the selected project type
|
||||
* @param projectTargetPlatform the target platform of the project
|
||||
* @param sdkStyleProject whether or not a project is SDK-style
|
||||
*/
|
||||
createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetPlatform?: string): Promise<vscode.Uri>;
|
||||
createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetPlatform?: string, sdkStyleProject?: boolean): Promise<vscode.Uri>;
|
||||
|
||||
/**
|
||||
* Gets the project data corresponding to the project file, to be placed in the dashboard container
|
||||
@@ -131,14 +132,14 @@ declare module 'dataworkspace' {
|
||||
readonly defaultTargetPlatform?: string;
|
||||
|
||||
/**
|
||||
* Link display value for a link at the end of the project description. linkLocation also needs to be set to use this
|
||||
* Whether or not sdk style project is an option
|
||||
*/
|
||||
readonly linkDisplayValue?: string;
|
||||
readonly sdkStyleOption?: boolean;
|
||||
|
||||
/**
|
||||
* Location where clicking on the linkDisplayValue will go to
|
||||
* Location where clicking on the Learn More next to SDK style checkbox will go. sdkStyleOption needs to be set to true to use this
|
||||
*/
|
||||
readonly linkLocation?: string
|
||||
readonly sdkStyleLearnMoreUrl?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ class NewProjectDialogModel {
|
||||
name: string = '';
|
||||
location: string = '';
|
||||
targetPlatform?: string;
|
||||
sdkStyleProject?: boolean;
|
||||
}
|
||||
|
||||
export async function openSpecificProjectNewProjectDialog(projectType: IProjectType, workspaceService: WorkspaceService): Promise<vscode.Uri | undefined> {
|
||||
@@ -35,6 +36,7 @@ export class NewProjectDialog extends DialogBase {
|
||||
public model: NewProjectDialogModel = new NewProjectDialogModel();
|
||||
public formBuilder: azdataType.FormBuilder | undefined;
|
||||
public targetPlatformDropdownFormComponent: azdataType.FormComponent | undefined;
|
||||
public sdkProjectCheckboxFormComponent: azdataType.FormComponent | undefined;
|
||||
public newProjectDialogComplete: Deferred<void> | undefined;
|
||||
public newDialogPromise: Promise<void> = new Promise<void>((resolve, reject) => this.newProjectDialogComplete = { resolve, reject });
|
||||
public projectUri: vscode.Uri | undefined;
|
||||
@@ -87,7 +89,7 @@ export class NewProjectDialog extends DialogBase {
|
||||
.withAdditionalProperties({ projectFileExtension: this.model.projectFileExtension, projectTemplateId: this.model.projectTypeId })
|
||||
.send();
|
||||
|
||||
this.projectUri = await this.workspaceService.createProject(this.model.name, vscode.Uri.file(this.model.location), this.model.projectTypeId, this.model.targetPlatform);
|
||||
this.projectUri = await this.workspaceService.createProject(this.model.name, vscode.Uri.file(this.model.location), this.model.projectTypeId, this.model.targetPlatform, this.model.sdkStyleProject);
|
||||
this.newProjectDialogComplete?.resolve();
|
||||
}
|
||||
catch (err) {
|
||||
@@ -122,8 +124,7 @@ export class NewProjectDialog extends DialogBase {
|
||||
'font-weight': 'bold'
|
||||
}
|
||||
}, {
|
||||
textValue: projectType.description,
|
||||
linkDisplayValue: projectType.linkDisplayValue
|
||||
textValue: projectType.description
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -138,15 +139,7 @@ export class NewProjectDialog extends DialogBase {
|
||||
selectedCardId: allProjectTypes.length > 0 ? allProjectTypes[0].id : undefined
|
||||
}).component();
|
||||
|
||||
projectTypeRadioCardGroup.onLinkClick(async (value) => {
|
||||
for (let projectType of allProjectTypes) {
|
||||
if (value.cardId === projectType.id) {
|
||||
void vscode.env.openExternal(vscode.Uri.parse(projectType.linkLocation!));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.register(projectTypeRadioCardGroup.onSelectionChanged((e) => {
|
||||
this.register(projectTypeRadioCardGroup.onSelectionChanged(async (e) => {
|
||||
this.model.projectTypeId = e.cardId;
|
||||
const selectedProject = allProjectTypes.find(p => p.id === e.cardId);
|
||||
|
||||
@@ -155,12 +148,30 @@ export class NewProjectDialog extends DialogBase {
|
||||
targetPlatformDropdown.values = selectedProject?.targetPlatforms;
|
||||
targetPlatformDropdown.value = this.getDefaultTargetPlatform(selectedProject);
|
||||
|
||||
this.formBuilder?.addFormItem(this.targetPlatformDropdownFormComponent!);
|
||||
this.formBuilder?.insertFormItem(this.targetPlatformDropdownFormComponent!, 3);
|
||||
} else {
|
||||
// remove the target version dropdown if the selected project type didn't provide values for this
|
||||
this.formBuilder?.removeFormItem(this.targetPlatformDropdownFormComponent!);
|
||||
this.model.targetPlatform = undefined;
|
||||
}
|
||||
|
||||
if (selectedProject?.sdkStyleOption) {
|
||||
sdkProjectCheckbox.checked = true;
|
||||
this.model.sdkStyleProject = true;
|
||||
|
||||
if (selectedProject.sdkStyleLearnMoreUrl) {
|
||||
await sdkLearnMore.updateProperty('url', selectedProject.sdkStyleLearnMoreUrl);
|
||||
sdkFormComponentGroup.addItem(sdkLearnMore);
|
||||
} else {
|
||||
// remove learn more link if the project type didn't provide it
|
||||
sdkFormComponentGroup.removeItem(sdkLearnMore);
|
||||
}
|
||||
|
||||
this.formBuilder?.addFormItem(this.sdkProjectCheckboxFormComponent!);
|
||||
} else {
|
||||
this.model.sdkStyleProject = false;
|
||||
this.formBuilder?.removeFormItem(this.sdkProjectCheckboxFormComponent!);
|
||||
}
|
||||
}));
|
||||
|
||||
const projectNameTextBox = view.modelBuilder.inputBox().withProps({
|
||||
@@ -227,6 +238,34 @@ export class NewProjectDialog extends DialogBase {
|
||||
component: targetPlatformDropdown
|
||||
};
|
||||
|
||||
const sdkProjectCheckbox = view.modelBuilder.checkBox().withProps({
|
||||
checked: true,
|
||||
label: constants.SdkStyleProject
|
||||
}).component();
|
||||
|
||||
this.register(sdkProjectCheckbox.onChanged(() => {
|
||||
this.model.sdkStyleProject = sdkProjectCheckbox.checked;
|
||||
}));
|
||||
|
||||
const sdkLearnMore = view.modelBuilder.hyperlink().withProps({
|
||||
label: constants.LearnMore,
|
||||
url: ''
|
||||
}).component();
|
||||
|
||||
const sdkFormComponentGroup = view.modelBuilder.flexContainer()
|
||||
.withLayout({ flexFlow: 'row', alignItems: 'baseline' })
|
||||
.withItems([sdkProjectCheckbox], { CSSStyles: { flex: '0 0 auto', 'margin-right': '10px' } })
|
||||
.component();
|
||||
|
||||
if (allProjectTypes[0].sdkStyleLearnMoreUrl) {
|
||||
await sdkLearnMore.updateProperty('url', allProjectTypes[0].sdkStyleLearnMoreUrl);
|
||||
sdkFormComponentGroup.addItem(sdkLearnMore);
|
||||
}
|
||||
|
||||
this.sdkProjectCheckboxFormComponent = {
|
||||
component: sdkFormComponentGroup,
|
||||
};
|
||||
|
||||
this.formBuilder = view.modelBuilder.formContainer().withFormItems([
|
||||
{
|
||||
title: constants.TypeTitle,
|
||||
@@ -250,6 +289,11 @@ export class NewProjectDialog extends DialogBase {
|
||||
this.formBuilder.addFormItem(this.targetPlatformDropdownFormComponent);
|
||||
}
|
||||
|
||||
// add sdk style checkbox is the first project has the option
|
||||
if (allProjectTypes[0].sdkStyleOption) {
|
||||
this.formBuilder.addFormItem(this.sdkProjectCheckboxFormComponent);
|
||||
}
|
||||
|
||||
await view.initializeModel(this.formBuilder.component());
|
||||
this.initDialogComplete?.resolve();
|
||||
}
|
||||
|
||||
@@ -197,10 +197,10 @@ export class WorkspaceService implements IWorkspaceService {
|
||||
return ProjectProviderRegistry.getProviderByProjectExtension(projectType);
|
||||
}
|
||||
|
||||
async createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetVersion?: string): Promise<vscode.Uri> {
|
||||
async createProject(name: string, location: vscode.Uri, projectTypeId: string, projectTargetVersion?: string, sdkStyleProject?: boolean): Promise<vscode.Uri> {
|
||||
const provider = ProjectProviderRegistry.getProviderByProjectType(projectTypeId);
|
||||
if (provider) {
|
||||
const projectFile = await provider.createProject(name, location, projectTypeId, projectTargetVersion);
|
||||
const projectFile = await provider.createProject(name, location, projectTypeId, projectTargetVersion, sdkStyleProject);
|
||||
await this.addProjectsToWorkspace([projectFile]);
|
||||
this._onDidWorkspaceProjectsChange.fire();
|
||||
return projectFile;
|
||||
|
||||
Reference in New Issue
Block a user