Skip to content

Commit

Permalink
ignoreFocusOut: true for showInputBox and showQuickPick
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhirverma authored and dgolovin committed Nov 12, 2019
1 parent 0cd70c6 commit 761ad37
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/k8s/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class Build {
} else {
const buildConfig = await common.selectResourceByName(Build.getBuildConfigNames("You have no BuildConfigs available"), "Select a BuildConfig to see the builds");
if (buildConfig) {
const selBuild = await window.showQuickPick(this.getBuildNames(buildConfig), {placeHolder: text});
const selBuild = await window.showQuickPick(this.getBuildNames(buildConfig), {placeHolder: text, ignoreFocusOut: true});
build = selBuild ? selBuild.label : null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function getQuickPicks(cmd: string, errorMessage: string, converter
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/k8s/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class DeploymentConfig {
} else {
const deploymentConfig = await common.selectResourceByName(this.getDeploymentConfigNames("You have no DeploymentConfigs available"), "Select a DeploymentConfig to see the Replica");
if (!deploymentConfig) return null;
const selreplica = await window.showQuickPick(this.getReplicaNames(deploymentConfig), {placeHolder: replicaPlaceHolder});
const selreplica = await window.showQuickPick(this.getReplicaNames(deploymentConfig), {placeHolder: replicaPlaceHolder, ignoreFocusOut: true});
replica = selreplica ? selreplica : null;
}
return replica;
Expand Down
8 changes: 4 additions & 4 deletions src/openshift/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Cluster extends OpenShiftItem {
const k8sConfig = new KubeConfigUtils();
const contexts = k8sConfig.contexts.filter((item) => item.name !== k8sConfig.currentContext);
const contextName: QuickPickItem[] = contexts.map((ctx) => ({ label: `${ctx.name}`}));
const choice = await window.showQuickPick(contextName, {placeHolder: "Select the new OpenShift context"});
const choice = await window.showQuickPick(contextName, {placeHolder: "Select the new OpenShift context", ignoreFocusOut: true});
if (!choice) return null;
return Promise.resolve()
.then(() => Cluster.odo.execute(Command.setOpenshiftContext(choice.label)))
Expand All @@ -87,7 +87,7 @@ export class Cluster extends OpenShiftItem {
const clusterURl = await Cluster.getUrlFromClipboard();
const createUrl = new CreateUrlItem();
const clusterItems = await k8sConfig.getServers();
const choice = await window.showQuickPick([createUrl, ...clusterItems], {placeHolder: "Provide Cluster URL to connect"});
const choice = await window.showQuickPick([createUrl, ...clusterItems], {placeHolder: "Provide Cluster URL to connect", ignoreFocusOut: true});
if (!choice) return null;
return (choice.label === createUrl.label) ?
await window.showInputBox({
Expand All @@ -111,7 +111,7 @@ export class Cluster extends OpenShiftItem {
}
];
if (response !== 'Yes') return null;
const loginActionSelected = await window.showQuickPick(loginActions, {placeHolder: 'Select the way to log in to the cluster.'});
const loginActionSelected = await window.showQuickPick(loginActions, {placeHolder: 'Select the way to log in to the cluster.', ignoreFocusOut: true});
if (!loginActionSelected) return null;
return loginActionSelected.label === 'Credentials' ? Cluster.credentialsLogin(true) : Cluster.tokenLogin(true);
}
Expand Down Expand Up @@ -148,7 +148,7 @@ export class Cluster extends OpenShiftItem {
const k8sConfig = new KubeConfigUtils();
const users = await k8sConfig.getClusterUsers(clusterURL);
const addUser = new CreateUserItem();
const choice = await window.showQuickPick([addUser, ...users], {placeHolder: "Select username for basic authentication to the API server"});
const choice = await window.showQuickPick([addUser, ...users], {placeHolder: "Select username for basic authentication to the API server", ignoreFocusOut: true});

if (!choice) return null;

Expand Down
38 changes: 20 additions & 18 deletions src/openshift/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export class Component extends OpenShiftItem {
}
];
const componentSource = await window.showQuickPick(sourceTypes, {
placeHolder: "Select source type for Component"
placeHolder: "Select source type for Component",
ignoreFocusOut: true
});
if (!componentSource) return null;

Expand Down Expand Up @@ -154,7 +155,7 @@ export class Component extends OpenShiftItem {
description: 'Unlink Service'
}
];
const unlinkActionSelected = await window.showQuickPick(unlinkActions, {placeHolder: 'Select the option'});
const unlinkActionSelected = await window.showQuickPick(unlinkActions, {placeHolder: 'Select the option', ignoreFocusOut: true});
if (!unlinkActionSelected) return null;
return unlinkActionSelected.label === 'Component' ? Component.unlinkComponent(context) : unlinkActionSelected.label === 'Service' ? Component.unlinkService(context) : null;
}
Expand All @@ -174,7 +175,7 @@ export class Component extends OpenShiftItem {
Object.keys(getLinkComponent).forEach(async key => {
linkCompName.push(key);
});
const compName = await window.showQuickPick(linkCompName, {placeHolder: "Select a Component to unlink"});
const compName = await window.showQuickPick(linkCompName, {placeHolder: "Select a Component to unlink", ignoreFocusOut: true});
if (!compName) return null;
return Progress.execFunctionWithProgress(`Unlinking Component`,
() => Component.odo.execute(Command.unlinkComponents(component.getParent().getParent().getName(), component.getParent().getName(), component.getName(), compName), component.contextPath.fsPath)
Expand All @@ -194,7 +195,7 @@ export class Component extends OpenShiftItem {
const linkService = await Component.getLinkData(component);
const getLinkService = linkService['status'].linkedServices;
if (!getLinkService) throw Error('No linked Services found');
const serviceName = await window.showQuickPick(getLinkService, {placeHolder: "Select a Service to unlink"});
const serviceName = await window.showQuickPick(getLinkService, {placeHolder: "Select a Service to unlink", ignoreFocusOut: true});
if (!serviceName) return null;
return Progress.execFunctionWithProgress(`Unlinking Service`,
() => Component.odo.execute(Command.unlinkService(component.getParent().getParent().getName(), component.getParent().getName(), serviceName, component.getName()), component.contextPath.fsPath)
Expand All @@ -213,7 +214,7 @@ export class Component extends OpenShiftItem {
if (!component) return null;
const componentPresent = (await Component.odo.getComponents(component.getParent())).filter((component) => component.contextValue !== ContextType.COMPONENT);
if (componentPresent.length === 1) throw Error('You have no Components available to link, please create new OpenShift Component and try again.');
const componentToLink = await window.showQuickPick(componentPresent.filter((comp)=> comp.getName() !== component.getName()), {placeHolder: "Select a Component to link"});
const componentToLink = await window.showQuickPick(componentPresent.filter((comp)=> comp.getName() !== component.getName()), {placeHolder: "Select a Component to link", ignoreFocusOut: true});
if (!componentToLink) return null;

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

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

if (!componentName) return null;

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

if (!componentTypeName) return null;

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

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

if (!componentName) return null;

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

if (!componentTypeName) return null;

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

if (!componentTypeVersion) return null;

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

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

const references: Map<string, Ref> = await Refs.fetchTag(repoURI);
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)"});
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});

if (!gitRef) return null;

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

if (!componentName) return null;

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

if (!componentTypeName) return null;

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

if (!componentTypeVersion) return null;

Expand Down Expand Up @@ -478,7 +480,7 @@ export class Component extends OpenShiftItem {

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

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

if (!binaryFile) return null;

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

if (!componentName) return null;

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

if (!componentTypeName) return null;

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

if (!componentTypeVersion) return null;

Expand Down
7 changes: 4 additions & 3 deletions src/openshift/openshiftItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export abstract class OpenShiftItem {
static async getName(message: string, data: Array<OpenShiftObject>, offset?: string): Promise<string> {
return await window.showInputBox({
prompt: `Provide ${message}`,
ignoreFocusOut: true,
validateInput: (value: string) => {
let validationMessage = OpenShiftItem.emptyName(`Empty ${message}`, value.trim());
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);
Expand Down Expand Up @@ -128,10 +129,10 @@ export abstract class OpenShiftItem {
static async getOpenShiftCmdData(treeItem: OpenShiftObject, projectPlaceholder: string, appPlaceholder?: string, compPlaceholder?: string, condition?: (value: OpenShiftObject) => boolean) {
let context: OpenShiftObject | QuickPickCommand = treeItem;
let project: OpenShiftObject;
if (!context) context = await window.showQuickPick(OpenShiftItem.getProjectNames(), {placeHolder: projectPlaceholder});
if (!context) context = await window.showQuickPick(OpenShiftItem.getProjectNames(), {placeHolder: projectPlaceholder, ignoreFocusOut: true});
if (context && context.contextValue === ContextType.PROJECT && appPlaceholder ) {
project = context as OpenShiftObject;
context = await window.showQuickPick<OpenShiftObject | QuickPickCommand>(OpenShiftItem.getApplicationNames(project, appPlaceholder.includes('create') && compPlaceholder === undefined), {placeHolder: appPlaceholder});
context = await window.showQuickPick<OpenShiftObject | QuickPickCommand>(OpenShiftItem.getApplicationNames(project, appPlaceholder.includes('create') && compPlaceholder === undefined), {placeHolder: appPlaceholder, ignoreFocusOut: true});
if (context && isCommand(context)) {
const newAppName = await context.command();
if (newAppName) {
Expand All @@ -141,7 +142,7 @@ export abstract class OpenShiftItem {
}
}
}
if (context && !isCommand(context) && context.contextValue === ContextType.APPLICATION && compPlaceholder) context = await window.showQuickPick(OpenShiftItem.getComponentNames(context as OpenShiftObject, condition), {placeHolder: compPlaceholder});
if (context && !isCommand(context) && context.contextValue === ContextType.APPLICATION && compPlaceholder) context = await window.showQuickPick(OpenShiftItem.getComponentNames(context as OpenShiftObject, condition), {placeHolder: compPlaceholder, ignoreFocusOut: true});
return context as OpenShiftObject;
}
}
9 changes: 6 additions & 3 deletions src/openshift/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class Service extends OpenShiftItem {
serviceTemplatePlanName = plans[0];
} else if (plans.length > 1) {
serviceTemplatePlanName = await window.showQuickPick(plans, {
placeHolder: "Service Template Plan Name"
placeHolder: "Service Template Plan Name",
ignoreFocusOut: true
});
} else {
window.showErrorMessage('No Service Plans available for selected Service Template');
Expand All @@ -51,7 +52,8 @@ export class Service extends OpenShiftItem {
"From which Application you want to delete Service"
);
if (application) {
service = await window.showQuickPick(Service.getServiceNames(application), {placeHolder: "Select Service to delete"});
service = await window.showQuickPick(Service.getServiceNames(application), {placeHolder: "Select Service to delete",
ignoreFocusOut: true});
}
}
if (service) {
Expand All @@ -73,7 +75,8 @@ export class Service extends OpenShiftItem {
"From which project you want to describe Service",
"From which application you want to describe Service");
if (application) {
service = await window.showQuickPick(Service.getServiceNames(application), {placeHolder: "Select Service you want to describe"});
service = await window.showQuickPick(Service.getServiceNames(application), {placeHolder: "Select Service you want to describe",
ignoreFocusOut: true});
}
}
if (service) {
Expand Down
Loading

0 comments on commit 761ad37

Please sign in to comment.