Add resource deployment samples for (#17734)

This commit is contained in:
Charles Gagnon
2021-11-22 15:49:05 -08:00
committed by GitHub
parent a79c61ff4e
commit 4c191d4acc
4 changed files with 112 additions and 2 deletions

View File

@@ -174,7 +174,7 @@ See [NotebookWizardInfo](https://github.com/microsoft/azuredatastudio/blob/main/
`required`
`options`
`options` - **REQUIRED** if `type` is `options`. See [Options](#options) for more information.
`placeHolder`
@@ -196,6 +196,29 @@ See [NotebookWizardInfo](https://github.com/microsoft/azuredatastudio/blob/main/
`valueProvider` - **OPTIONAL** If defined then the value for this field is retrieved using the specified [Value Provider](#value-provider).
#### Options
This defines the set of options for this field to display. There are a number of different ways to configure the set of options :
* String array (`string[]`) - A static list of values that will be shown as a dropdown. Default value selected is defined as `FieldInfo.defaultValue`.
* CategoryValue array (`azdata.CategoryValue[]`) - A static list of CategoryValue objects that will be shown as a dropdown. Each value will define a display name separate from its value - use this for values you want to display differently to the user (such as names for an Azure region).
* [OptionsInfo](#optionsinfo) - An object allowing more control over the option values.
See [sample-options](https://github.com/microsoft/azuredatastudio/blob/main/samples/sample-resource-deployment/package.json) for example implementations.
##### OptionsInfo
This object defines a set of options for a field, similar to the arrays that can be used for the [options](#options) field but with greater control over of the options. Currently there are two reasons that you would use this object over the arrays - either you want to display the options as something other than a dropdown or you wish to use an [Options Source Provider](#options-source-provider) to populate the options dynamically.
`values` - An array of either `strings` or `azdata.CategoryValue` objects. See [options](#options) for more details on each of those.
`defaultValue` - The string value of the default option to have selected
`optionsType` - How to display the options, either `radio` or `dropdown`
`source` - OPTIONAL If set defines the [Options Source Provider](#options-source-provider) to use for populating the options dynamically.
### Options Source Provider
### Value Provider
When a field specifies a value provider then it is saying that the value for that field is dynamic and will be retrieved from a value provider that is registered by an extension separately. This can be used for more complex logic such as running calculations, reading files, making web requests, etc.

View File

@@ -776,7 +776,10 @@ function processDropdownOptionsTypeField(context: FieldContext): azdata.DropDown
// Note we don't currently check that the value actually exists in the list - if it doesn't then it'll
// just default to the first one anyways
const initialValue = context.fieldInfo.variableName && context.initialVariableValues?.[context.fieldInfo.variableName]?.toString();
const defaultValue = initialValue || options.defaultValue;
const optionValues = options.values;
// If we have an array of CategoryValues then find the option that matches the defaultValue specified - otherwise just use the defaultValue provided
const defaultValueOption = (optionValues && optionValues.length > 0 && typeof optionValues[0] === 'object') ? (optionValues as azdata.CategoryValue[]).find(v => v.name === options.defaultValue) : options.defaultValue;
const defaultValue = initialValue || defaultValueOption;
const dropdown = createDropdownInputInfo(context.view, {
values: options.values,
defaultValue: defaultValue,

View File

@@ -151,6 +151,10 @@
{
"name": "value-provider",
"displayName": "%option-value-provider%"
},
{
"name": "options",
"displayName": "%option-options%"
}
]
}
@@ -527,6 +531,74 @@
},
"requiredTools": [ ],
"when": "sample-type=value-provider"
},
{
"name": "sample-options",
"notebookWizard": {
"notebook": "./notebooks/empty-notebook.ipynb",
"codeCellInsertionPosition": 1,
"actionText": "%deploy.wizard.action%",
"title": "%sample.options.title%",
"name": "sample.options",
"labelPosition": "left",
"generateSummaryPage": false,
"pages": [
{
"title": "%sample.options.title%",
"sections": [
{
"title": "%sample.options.stringarray.title%",
"collapsible": false,
"fields": [
{
"label": "%sample.options.stringarray.label%",
"description": "%sample.options.stringarray.description%",
"type": "options",
"variableName": "AZDATA_NB_VAR_SAMPLE_OPTIONS_STRINGARRAY",
"defaultValue": "String option 2",
"required": true,
"options": [
"String option 1",
"String option 2",
"%sample.options.value3.displayname%"
]
}
]
},
{
"title": "%sample.options.categoryvalue.title%",
"collapsible": false,
"fields": [
{
"label": "%sample.options.categoryvalue.label%",
"description": "%sample.options.categoryvalue.description%",
"type": "options",
"variableName": "AZDATA_NB_VAR_SAMPLE_OPTIONS_CATEGORYVALUE",
"defaultValue": "value2",
"required": true,
"options": [
{
"name": "value1",
"displayName": "%sample.options.value1.displayname%"
},
{
"name": "value2",
"displayName": "%sample.options.value2.displayname%"
},
{
"name": "value3",
"displayName": "%sample.options.value3.displayname%"
}
]
}
]
}
]
}
]
},
"requiredTools": [ ],
"when": "sample-type=options"
}
],
"agreements": [

View File

@@ -19,6 +19,7 @@
"option-sample-type": "Sample Type",
"option-wizard": "Wizard",
"option-value-provider": "Value Provider",
"option-options": "Options",
"resource.type.sample.display.name": "Sample Deployment Types",
"resource.type.sample.description": "Provides samples of various deployment types and their options",
@@ -34,6 +35,17 @@
"sample.value-provider.multiple.title": "Multiple Trigger Value Provider Sample",
"sample.value-provider.multiple.field.label": "Field using multiple trigger fields",
"sample.options.title": "Options Samples",
"sample.options.stringarray.title": "Sample string array options",
"sample.options.categoryvalue.title": "Sample CategoryValue array options",
"sample.options.stringarray.label": "Option list provided by static string array",
"sample.options.stringarray.description": "Note that you can use localized values if you want. (Including mixing both localized and unlocalized values but that isn't recommended)",
"sample.options.categoryvalue.label": "Option list provided by static azdata.CategoryValue array",
"sample.options.categoryvalue.description": "The variable will store the name property of the currently selected option",
"sample.options.value1.displayname": "Value 1 Display Name",
"sample.options.value2.displayname": "Value 2 Display Name",
"sample.options.value3.displayname": "Value 3 Display Name",
"wizard.new.wizard.title": "Create Test controller",
"wizard.cluster.environment.title": "What is your target existing Kubernetes cluster environment?",
"wizard.select.cluster.title": "Select from installed existing Kubernetes clusters",