Skip to content

Commit 03a8155

Browse files
changed create component workflow and the application name generated based on the starter project selected (#2433)
1 parent 0cfc933 commit 03a8155

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

src/openshift/component.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,9 @@ export class Component extends OpenShiftItem {
536536
}
537537

538538
@vsCommand('openshift.componentType.newComponent')
539-
public static async createComponentFromCatalogEntry(context: DevfileComponentType | StarterProject, appName?: string, registryName?: string): Promise<string> {
539+
public static async createComponentFromCatalogEntry(context: DevfileComponentType | StarterProject, registryName?: string): Promise<string> {
540540
const application = await Component.getOpenShiftCmdData(undefined,
541-
'Select an Application where you want to create a Component', undefined, undefined,
542-
appName
541+
'Select an Application where you want to create a Component', undefined, undefined
543542
);
544543

545544
if (!application) return null;
@@ -605,7 +604,7 @@ export class Component extends OpenShiftItem {
605604

606605
@vsCommand('openshift.component.createFromRootWorkspaceFolder')
607606
static async createFromRootWorkspaceFolder(folder: Uri, selection: Uri[], context: OpenShiftApplication, componentTypeName?: string, starterProjectName?: string, registryName?: string, notification = true): Promise<string | null> {
608-
const application = await Component.getOpenShiftCmdData(context,
607+
let application = await Component.getOpenShiftCmdData(context,
609608
'Select an Application where you want to create a Component'
610609
);
611610

@@ -622,19 +621,8 @@ export class Component extends OpenShiftItem {
622621
if (devfileYaml && devfileYaml.metadata && devfileYaml.metadata.name) {
623622
initialNameValue = devfileYaml.metadata.name;
624623
}
625-
} else {
626-
initialNameValue = starterProjectName || path.basename(folder.fsPath);
627624
}
628625

629-
const componentName = await Component.getName(
630-
'Name',
631-
application.getParent().getParent() ? Component.odo.getComponents(application) : Promise.resolve([]),
632-
application.getName(),
633-
initialNameValue
634-
);
635-
636-
if (!componentName) return createCancelledResult('componentName');
637-
638626
const progressIndicator = window.createQuickPick();
639627

640628
let createStarter: string;
@@ -699,9 +687,19 @@ export class Component extends OpenShiftItem {
699687
}
700688
}
701689
}
690+
application = application.getName() === 'app' ?
691+
new OpenShiftApplication(application.getParent(), `app-${createStarter}`) : application;
702692
}
703693
}
704694

695+
const componentName = await Component.getName(
696+
'Name',
697+
application.getParent().getParent() ? Component.odo.getComponents(application) : Promise.resolve([]),
698+
application.getName(),
699+
initialNameValue?.trim().length > 0 ? initialNameValue : createStarter
700+
);
701+
702+
if (!componentName) return createCancelledResult('componentName');
705703
const refreshComponentsView = workspace.getWorkspaceFolder(folder);
706704
const creatComponentProperties: NewComponentCommandProps = {
707705
'component_kind': 'devfile',

src/openshift/openshiftItem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default class OpenShiftItem {
180180
return urlList;
181181
}
182182

183-
static async getOpenShiftCmdData<T extends OpenShiftObject>(treeItem: T, appPlaceholder?: string, compPlaceholder?: string, condition?: (value: OpenShiftObject) => boolean, appName?: string): Promise<T | null> {
183+
static async getOpenShiftCmdData<T extends OpenShiftObject>(treeItem: T, appPlaceholder?: string, compPlaceholder?: string, condition?: (value: OpenShiftObject) => boolean): Promise<T | null> {
184184
let context: OpenShiftObject | QuickPickCommand = treeItem;
185185
let project: OpenShiftObject;
186186
if (!context) {
@@ -231,7 +231,7 @@ export default class OpenShiftItem {
231231
context = await window.showQuickPick<OpenShiftObject | QuickPickCommand>(applicationList, {placeHolder: appPlaceholder, ignoreFocusOut: true});
232232
}
233233
if (context && isCommand(context)) {
234-
const newAppName = appName || await context.command();
234+
const newAppName = 'app';
235235
if (newAppName) {
236236
context = new OpenShiftApplication(project, newAppName);
237237
} else {

src/webview/devfile-registry/app/cardItem.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export class CardItem extends React.Component<DevFileProps, {
9191
'action': 'createComponent',
9292
'devFile': this.props.compDescription.Devfile,
9393
'selectedProject': this.state.selectedProject,
94-
'appName': 'app-' + this.state.selectedProject.name,
9594
'registryName': this.props.compDescription.RegistryName
9695
});
9796
return;

src/webview/devfile-registry/registryViewLoader.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ async function devfileRegistryViewerMessageListener(event: any): Promise<any> {
3333
);
3434
break;
3535
case 'createComponent':
36-
const appName = event.appName;
3736
const registryName = event.registryName;
38-
vscode.commands.executeCommand('openshift.componentType.newComponent', starterProject, appName, registryName);
37+
vscode.commands.executeCommand('openshift.componentType.newComponent', starterProject, registryName);
3938
break;
4039
case 'cloneToWorkSpace':
4140
vscode.commands.executeCommand('openshift.componentType.cloneStarterProjectRepository', starterProject);

0 commit comments

Comments
 (0)