Skip to content

Commit 761ad37

Browse files
sudhirvermadgolovin
authored andcommitted
ignoreFocusOut: true for showInputBox and showQuickPick
1 parent 0cd70c6 commit 761ad37

File tree

11 files changed

+47
-39
lines changed

11 files changed

+47
-39
lines changed

src/k8s/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class Build {
7676
} else {
7777
const buildConfig = await common.selectResourceByName(Build.getBuildConfigNames("You have no BuildConfigs available"), "Select a BuildConfig to see the builds");
7878
if (buildConfig) {
79-
const selBuild = await window.showQuickPick(this.getBuildNames(buildConfig), {placeHolder: text});
79+
const selBuild = await window.showQuickPick(this.getBuildNames(buildConfig), {placeHolder: text, ignoreFocusOut: true});
8080
build = selBuild ? selBuild.label : null;
8181
}
8282
}

src/k8s/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function getQuickPicks(cmd: string, errorMessage: string, converter
2626
}
2727

2828
export async function selectResourceByName(config: Promise<QuickPickItem[]> | QuickPickItem[], placeHolderText: string): Promise<string> {
29-
const resource: any = await window.showQuickPick(config, {placeHolder: placeHolderText});
29+
const resource: any = await window.showQuickPick(config, {placeHolder: placeHolderText, ignoreFocusOut: true});
3030
return resource ? resource.label : null;
3131
}
3232

src/k8s/deployment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class DeploymentConfig {
100100
} else {
101101
const deploymentConfig = await common.selectResourceByName(this.getDeploymentConfigNames("You have no DeploymentConfigs available"), "Select a DeploymentConfig to see the Replica");
102102
if (!deploymentConfig) return null;
103-
const selreplica = await window.showQuickPick(this.getReplicaNames(deploymentConfig), {placeHolder: replicaPlaceHolder});
103+
const selreplica = await window.showQuickPick(this.getReplicaNames(deploymentConfig), {placeHolder: replicaPlaceHolder, ignoreFocusOut: true});
104104
replica = selreplica ? selreplica : null;
105105
}
106106
return replica;

src/openshift/cluster.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class Cluster extends OpenShiftItem {
7575
const k8sConfig = new KubeConfigUtils();
7676
const contexts = k8sConfig.contexts.filter((item) => item.name !== k8sConfig.currentContext);
7777
const contextName: QuickPickItem[] = contexts.map((ctx) => ({ label: `${ctx.name}`}));
78-
const choice = await window.showQuickPick(contextName, {placeHolder: "Select the new OpenShift context"});
78+
const choice = await window.showQuickPick(contextName, {placeHolder: "Select the new OpenShift context", ignoreFocusOut: true});
7979
if (!choice) return null;
8080
return Promise.resolve()
8181
.then(() => Cluster.odo.execute(Command.setOpenshiftContext(choice.label)))
@@ -87,7 +87,7 @@ export class Cluster extends OpenShiftItem {
8787
const clusterURl = await Cluster.getUrlFromClipboard();
8888
const createUrl = new CreateUrlItem();
8989
const clusterItems = await k8sConfig.getServers();
90-
const choice = await window.showQuickPick([createUrl, ...clusterItems], {placeHolder: "Provide Cluster URL to connect"});
90+
const choice = await window.showQuickPick([createUrl, ...clusterItems], {placeHolder: "Provide Cluster URL to connect", ignoreFocusOut: true});
9191
if (!choice) return null;
9292
return (choice.label === createUrl.label) ?
9393
await window.showInputBox({
@@ -111,7 +111,7 @@ export class Cluster extends OpenShiftItem {
111111
}
112112
];
113113
if (response !== 'Yes') return null;
114-
const loginActionSelected = await window.showQuickPick(loginActions, {placeHolder: 'Select the way to log in to the cluster.'});
114+
const loginActionSelected = await window.showQuickPick(loginActions, {placeHolder: 'Select the way to log in to the cluster.', ignoreFocusOut: true});
115115
if (!loginActionSelected) return null;
116116
return loginActionSelected.label === 'Credentials' ? Cluster.credentialsLogin(true) : Cluster.tokenLogin(true);
117117
}
@@ -148,7 +148,7 @@ export class Cluster extends OpenShiftItem {
148148
const k8sConfig = new KubeConfigUtils();
149149
const users = await k8sConfig.getClusterUsers(clusterURL);
150150
const addUser = new CreateUserItem();
151-
const choice = await window.showQuickPick([addUser, ...users], {placeHolder: "Select username for basic authentication to the API server"});
151+
const choice = await window.showQuickPick([addUser, ...users], {placeHolder: "Select username for basic authentication to the API server", ignoreFocusOut: true});
152152

153153
if (!choice) return null;
154154

src/openshift/component.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export class Component extends OpenShiftItem {
4444
}
4545
];
4646
const componentSource = await window.showQuickPick(sourceTypes, {
47-
placeHolder: "Select source type for Component"
47+
placeHolder: "Select source type for Component",
48+
ignoreFocusOut: true
4849
});
4950
if (!componentSource) return null;
5051

@@ -154,7 +155,7 @@ export class Component extends OpenShiftItem {
154155
description: 'Unlink Service'
155156
}
156157
];
157-
const unlinkActionSelected = await window.showQuickPick(unlinkActions, {placeHolder: 'Select the option'});
158+
const unlinkActionSelected = await window.showQuickPick(unlinkActions, {placeHolder: 'Select the option', ignoreFocusOut: true});
158159
if (!unlinkActionSelected) return null;
159160
return unlinkActionSelected.label === 'Component' ? Component.unlinkComponent(context) : unlinkActionSelected.label === 'Service' ? Component.unlinkService(context) : null;
160161
}
@@ -174,7 +175,7 @@ export class Component extends OpenShiftItem {
174175
Object.keys(getLinkComponent).forEach(async key => {
175176
linkCompName.push(key);
176177
});
177-
const compName = await window.showQuickPick(linkCompName, {placeHolder: "Select a Component to unlink"});
178+
const compName = await window.showQuickPick(linkCompName, {placeHolder: "Select a Component to unlink", ignoreFocusOut: true});
178179
if (!compName) return null;
179180
return Progress.execFunctionWithProgress(`Unlinking Component`,
180181
() => Component.odo.execute(Command.unlinkComponents(component.getParent().getParent().getName(), component.getParent().getName(), component.getName(), compName), component.contextPath.fsPath)
@@ -194,7 +195,7 @@ export class Component extends OpenShiftItem {
194195
const linkService = await Component.getLinkData(component);
195196
const getLinkService = linkService['status'].linkedServices;
196197
if (!getLinkService) throw Error('No linked Services found');
197-
const serviceName = await window.showQuickPick(getLinkService, {placeHolder: "Select a Service to unlink"});
198+
const serviceName = await window.showQuickPick(getLinkService, {placeHolder: "Select a Service to unlink", ignoreFocusOut: true});
198199
if (!serviceName) return null;
199200
return Progress.execFunctionWithProgress(`Unlinking Service`,
200201
() => Component.odo.execute(Command.unlinkService(component.getParent().getParent().getName(), component.getParent().getName(), serviceName, component.getName()), component.contextPath.fsPath)
@@ -213,7 +214,7 @@ export class Component extends OpenShiftItem {
213214
if (!component) return null;
214215
const componentPresent = (await Component.odo.getComponents(component.getParent())).filter((component) => component.contextValue !== ContextType.COMPONENT);
215216
if (componentPresent.length === 1) throw Error('You have no Components available to link, please create new OpenShift Component and try again.');
216-
const componentToLink = await window.showQuickPick(componentPresent.filter((comp)=> comp.getName() !== component.getName()), {placeHolder: "Select a Component to link"});
217+
const componentToLink = await window.showQuickPick(componentPresent.filter((comp)=> comp.getName() !== component.getName()), {placeHolder: "Select a Component to link", ignoreFocusOut: true});
217218
if (!componentToLink) return null;
218219

219220
const portsResult: CliExitData = await Component.odo.execute(Command.listComponentPorts(component.getParent().getParent().getName(), component.getParent().getName(), componentToLink.getName()));
@@ -224,7 +225,7 @@ export class Component extends OpenShiftItem {
224225
if (ports.length === 1) {
225226
port = ports[0];
226227
} else if (ports.length > 1) {
227-
port = await window.showQuickPick(ports, {placeHolder: "Select Port to link"});
228+
port = await window.showQuickPick(ports, {placeHolder: "Select Port to link", ignoreFocusOut: true});
228229
} else {
229230
return Promise.reject(`Component '${component.getName()}' has no Ports declared.`);
230231
}
@@ -244,7 +245,7 @@ export class Component extends OpenShiftItem {
244245
(value: OpenShiftObject) => value.contextValue === ContextType.COMPONENT_PUSHED
245246
);
246247
if (!component) return null;
247-
const serviceToLink: OpenShiftObject = await window.showQuickPick(Component.getServiceNames(component.getParent()), {placeHolder: "Select the service to link"});
248+
const serviceToLink: OpenShiftObject = await window.showQuickPick(Component.getServiceNames(component.getParent()), {placeHolder: "Select the service to link", ignoreFocusOut: true});
248249
if (!serviceToLink) return null;
249250

250251
return Progress.execFunctionWithProgress(`Link Service '${serviceToLink.getName()}' with Component '${component.getName()}'`,
@@ -349,7 +350,7 @@ export class Component extends OpenShiftItem {
349350
if (pushedUrl.length > 0) {
350351
const hostName: QuickPickItem[] = pushedUrl.map((value) => ({ label: `${value.spec.protocol}://${value.spec.host}`, description: `Target Port is ${value.spec.port}`}));
351352
if (hostName.length >1) {
352-
selectRoute = await window.showQuickPick(hostName, {placeHolder: "This Component has multiple URLs. Select the desired URL to open in browser."});
353+
selectRoute = await window.showQuickPick(hostName, {placeHolder: "This Component has multiple URLs. Select the desired URL to open in browser.", ignoreFocusOut: true});
353354
if (!selectRoute) return null;
354355
return commands.executeCommand('vscode.open', Uri.parse(`${selectRoute.label}`));
355356
} else {
@@ -379,11 +380,11 @@ export class Component extends OpenShiftItem {
379380

380381
if (!componentName) return null;
381382

382-
const componentTypeName = await window.showQuickPick(Component.odo.getComponentTypes(), {placeHolder: "Component type"});
383+
const componentTypeName = await window.showQuickPick(Component.odo.getComponentTypes(), {placeHolder: "Component type", ignoreFocusOut: true});
383384

384385
if (!componentTypeName) return null;
385386

386-
const componentTypeVersion = await window.showQuickPick(Component.odo.getComponentTypeVersions(componentTypeName), {placeHolder: "Component type version"});
387+
const componentTypeVersion = await window.showQuickPick(Component.odo.getComponentTypeVersions(componentTypeName), {placeHolder: "Component type version", ignoreFocusOut: true});
387388

388389
if (!componentTypeVersion) return null;
389390
await Progress.execFunctionWithProgress(`Creating new Component '${componentName}'`, () => Component.odo.createComponentFromFolder(application, componentTypeName, componentTypeVersion, componentName, workspacePath));
@@ -401,11 +402,11 @@ export class Component extends OpenShiftItem {
401402

402403
if (!componentName) return null;
403404

404-
const componentTypeName = await window.showQuickPick(Component.odo.getComponentTypes(), {placeHolder: "Component type"});
405+
const componentTypeName = await window.showQuickPick(Component.odo.getComponentTypes(), {placeHolder: "Component type", ignoreFocusOut: true});
405406

406407
if (!componentTypeName) return null;
407408

408-
const componentTypeVersion = await window.showQuickPick(Component.odo.getComponentTypeVersions(componentTypeName), {placeHolder: "Component type version"});
409+
const componentTypeVersion = await window.showQuickPick(Component.odo.getComponentTypeVersions(componentTypeName), {placeHolder: "Component type version", ignoreFocusOut: true});
409410

410411
if (!componentTypeVersion) return null;
411412

@@ -423,6 +424,7 @@ export class Component extends OpenShiftItem {
423424

424425
const repoURI = await window.showInputBox({
425426
prompt: 'Git repository URI',
427+
ignoreFocusOut: true,
426428
validateInput: (value: string) => {
427429
return delayer.trigger(async () => {
428430
if (!value.trim()) return 'Empty Git repository URL';
@@ -436,7 +438,7 @@ export class Component extends OpenShiftItem {
436438
if (!repoURI) return null;
437439

438440
const references: Map<string, Ref> = await Refs.fetchTag(repoURI);
439-
const gitRef = await window.showQuickPick([...references.values()].map(value => ({label: value.name, description: value.type === Type.TAG? `Tag at ${value.hash}` : value.hash })) , {placeHolder: "Select git reference (branch/tag)"});
441+
const gitRef = await window.showQuickPick([...references.values()].map(value => ({label: value.name, description: value.type === Type.TAG? `Tag at ${value.hash}` : value.hash })) , {placeHolder: "Select git reference (branch/tag)", ignoreFocusOut: true});
440442

441443
if (!gitRef) return null;
442444

@@ -445,11 +447,11 @@ export class Component extends OpenShiftItem {
445447

446448
if (!componentName) return null;
447449

448-
const componentTypeName = await window.showQuickPick(Component.odo.getComponentTypes(), {placeHolder: "Component type"});
450+
const componentTypeName = await window.showQuickPick(Component.odo.getComponentTypes(), {placeHolder: "Component type", ignoreFocusOut: true});
449451

450452
if (!componentTypeName) return null;
451453

452-
const componentTypeVersion = await window.showQuickPick(Component.odo.getComponentTypeVersions(componentTypeName), {placeHolder: "Component type version"});
454+
const componentTypeVersion = await window.showQuickPick(Component.odo.getComponentTypeVersions(componentTypeName), {placeHolder: "Component type version", ignoreFocusOut: true});
453455

454456
if (!componentTypeVersion) return null;
455457

@@ -478,7 +480,7 @@ export class Component extends OpenShiftItem {
478480

479481
const binaryFileObj: QuickPickItem[] = paths.map((file) => ({ label: `$(file-zip) ${path.basename(file)}`, description: `${file}`}));
480482

481-
const binaryFile: any = await window.showQuickPick(binaryFileObj, {placeHolder: "Select binary file"});
483+
const binaryFile: any = await window.showQuickPick(binaryFileObj, {placeHolder: "Select binary file", ignoreFocusOut: true});
482484

483485
if (!binaryFile) return null;
484486

@@ -487,11 +489,11 @@ export class Component extends OpenShiftItem {
487489

488490
if (!componentName) return null;
489491

490-
const componentTypeName = await window.showQuickPick(Component.odo.getComponentTypes(), {placeHolder: "Component type"});
492+
const componentTypeName = await window.showQuickPick(Component.odo.getComponentTypes(), {placeHolder: "Component type", ignoreFocusOut: true});
491493

492494
if (!componentTypeName) return null;
493495

494-
const componentTypeVersion = await window.showQuickPick(Component.odo.getComponentTypeVersions(componentTypeName), {placeHolder: "Component type version"});
496+
const componentTypeVersion = await window.showQuickPick(Component.odo.getComponentTypeVersions(componentTypeName), {placeHolder: "Component type version", ignoreFocusOut: true});
495497

496498
if (!componentTypeVersion) return null;
497499

src/openshift/openshiftItem.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export abstract class OpenShiftItem {
4646
static async getName(message: string, data: Array<OpenShiftObject>, offset?: string): Promise<string> {
4747
return await window.showInputBox({
4848
prompt: `Provide ${message}`,
49+
ignoreFocusOut: true,
4950
validateInput: (value: string) => {
5051
let validationMessage = OpenShiftItem.emptyName(`Empty ${message}`, value.trim());
5152
if (!validationMessage) validationMessage = OpenShiftItem.validateMatches(`Not a valid ${message}. Please use lower case alphanumeric characters or "-", start with an alphabetic character, and end with an alphanumeric character`, value);
@@ -128,10 +129,10 @@ export abstract class OpenShiftItem {
128129
static async getOpenShiftCmdData(treeItem: OpenShiftObject, projectPlaceholder: string, appPlaceholder?: string, compPlaceholder?: string, condition?: (value: OpenShiftObject) => boolean) {
129130
let context: OpenShiftObject | QuickPickCommand = treeItem;
130131
let project: OpenShiftObject;
131-
if (!context) context = await window.showQuickPick(OpenShiftItem.getProjectNames(), {placeHolder: projectPlaceholder});
132+
if (!context) context = await window.showQuickPick(OpenShiftItem.getProjectNames(), {placeHolder: projectPlaceholder, ignoreFocusOut: true});
132133
if (context && context.contextValue === ContextType.PROJECT && appPlaceholder ) {
133134
project = context as OpenShiftObject;
134-
context = await window.showQuickPick<OpenShiftObject | QuickPickCommand>(OpenShiftItem.getApplicationNames(project, appPlaceholder.includes('create') && compPlaceholder === undefined), {placeHolder: appPlaceholder});
135+
context = await window.showQuickPick<OpenShiftObject | QuickPickCommand>(OpenShiftItem.getApplicationNames(project, appPlaceholder.includes('create') && compPlaceholder === undefined), {placeHolder: appPlaceholder, ignoreFocusOut: true});
135136
if (context && isCommand(context)) {
136137
const newAppName = await context.command();
137138
if (newAppName) {
@@ -141,7 +142,7 @@ export abstract class OpenShiftItem {
141142
}
142143
}
143144
}
144-
if (context && !isCommand(context) && context.contextValue === ContextType.APPLICATION && compPlaceholder) context = await window.showQuickPick(OpenShiftItem.getComponentNames(context as OpenShiftObject, condition), {placeHolder: compPlaceholder});
145+
if (context && !isCommand(context) && context.contextValue === ContextType.APPLICATION && compPlaceholder) context = await window.showQuickPick(OpenShiftItem.getComponentNames(context as OpenShiftObject, condition), {placeHolder: compPlaceholder, ignoreFocusOut: true});
145146
return context as OpenShiftObject;
146147
}
147148
}

src/openshift/service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export class Service extends OpenShiftItem {
2828
serviceTemplatePlanName = plans[0];
2929
} else if (plans.length > 1) {
3030
serviceTemplatePlanName = await window.showQuickPick(plans, {
31-
placeHolder: "Service Template Plan Name"
31+
placeHolder: "Service Template Plan Name",
32+
ignoreFocusOut: true
3233
});
3334
} else {
3435
window.showErrorMessage('No Service Plans available for selected Service Template');
@@ -51,7 +52,8 @@ export class Service extends OpenShiftItem {
5152
"From which Application you want to delete Service"
5253
);
5354
if (application) {
54-
service = await window.showQuickPick(Service.getServiceNames(application), {placeHolder: "Select Service to delete"});
55+
service = await window.showQuickPick(Service.getServiceNames(application), {placeHolder: "Select Service to delete",
56+
ignoreFocusOut: true});
5557
}
5658
}
5759
if (service) {
@@ -73,7 +75,8 @@ export class Service extends OpenShiftItem {
7375
"From which project you want to describe Service",
7476
"From which application you want to describe Service");
7577
if (application) {
76-
service = await window.showQuickPick(Service.getServiceNames(application), {placeHolder: "Select Service you want to describe"});
78+
service = await window.showQuickPick(Service.getServiceNames(application), {placeHolder: "Select Service you want to describe",
79+
ignoreFocusOut: true});
7780
}
7881
}
7982
if (service) {

0 commit comments

Comments
 (0)