提交 7b315c80 编写于 作者: O Oliver Larsson 提交者: Alex Ross

Friendly pickstring options (#89180)

* Implement git.pruneOnFetch setting (#86813)

* Revert "Implement git.pruneOnFetch setting (#86813)"

This reverts commit 55fbb5347f2e75d0da62f1875dcc12acbc52e0a6.

* Implemented pickString "friendly name"

* Default pickString option fix

* "name" field changed to "label"
Co-authored-by: NAlex Ross <alros@microsoft.com>
上级 61141737
......@@ -268,22 +268,39 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR
if (!Types.isString(info.description)) {
missingAttribute('description');
}
if (!Types.isStringArray(info.options)) {
if (Types.isArray(info.options)) {
info.options.forEach(pickOption => {
if (!Types.isString(pickOption) && !Types.isString(pickOption.value)) {
missingAttribute('value');
}
});
} else {
missingAttribute('options');
}
const picks = new Array<IQuickPickItem>();
info.options.forEach(pickOption => {
const item: IQuickPickItem = { label: pickOption };
if (pickOption === info.default) {
const value = Types.isString(pickOption) ? pickOption : pickOption.value;
const label = Types.isString(pickOption) ? undefined : pickOption.label;
// If there is no label defined, use value as label
const item: IQuickPickItem = {
label: label ? label : value,
detail: label ? value : undefined
};
if (value === info.default) {
item.description = nls.localize('inputVariable.defaultInputValue', "Default");
picks.unshift(item);
} else {
picks.push(item);
}
});
const pickOptions: IPickOptions<IQuickPickItem> = { placeHolder: info.description };
const pickOptions: IPickOptions<IQuickPickItem> = { placeHolder: info.description, matchOnDetail: true };
return this.quickInputService.pick(picks, pickOptions, undefined).then(resolvedInput => {
return resolvedInput ? resolvedInput.label : undefined;
if (resolvedInput) {
return Types.isString(resolvedInput.detail) ? resolvedInput.detail : resolvedInput.label;
}
return undefined;
});
}
......
......@@ -55,7 +55,7 @@ export interface PickStringInputInfo {
id: string;
type: 'pickString';
description: string;
options: string[];
options: (string | { value: string, label?: string })[];
default?: string;
}
......
......@@ -73,9 +73,28 @@ export const inputsSchema: IJSONSchema = {
},
options: {
type: 'array',
description: nls.localize('JsonSchema.input.options', 'An array of strings that defines the options for a quick pick.'),
description: nls.localize('JsonSchema.input.options', "An array of strings that defines the options for a quick pick."),
items: {
type: 'string'
oneOf: [
{
type: 'string'
},
{
type: 'object',
required: ['value'],
additionalProperties: false,
properties: {
label: {
type: 'string',
description: nls.localize('JsonSchema.input.pickString.optionLabel', "Label for the option.")
},
value: {
type: 'string',
description: nls.localize('JsonSchema.input.pickString.optionValue', "Value for the option.")
}
}
}
]
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册