mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add sample value provider (#17548)
This commit is contained in:
@@ -86,7 +86,7 @@ There are a number of properties on each `ResourceType`.
|
||||
|
||||
#### Provider Types
|
||||
|
||||
There are a number of different types of providers that can be used which affect what happens when the user selects that provider. These are indicated by what fields the provider contains - the provider is checked in order of top to bottom for each property and use the first type that it finds in the properties for that provider.
|
||||
There are a number of different types of providers that can be used which affect what happens when the user selects that provider. These are indicated by what fields the provider contains - the provider is checked in order of top to bottom for each property and uses the first type that it finds in the properties for that provider.
|
||||
|
||||
`Notebook Wizard` - A wizard is opened that can be used to prompt the user for values and display information, and then at the very end will open the specified Notebook with those values injected in. Indicated by the presence of the `notebookWizard` property.
|
||||
|
||||
@@ -104,4 +104,110 @@ There are a number of different types of providers that can be used which affect
|
||||
|
||||
**TODO**
|
||||
|
||||
### NotebookWizard (extends [WizardInfoBase](#wizardinfobase))
|
||||
|
||||
See [NotebookWizardInfo](https://github.com/microsoft/azuredatastudio/blob/main/extensions/resource-deployment/src/interfaces.ts#L170) for how it's defined in code.
|
||||
|
||||
`notebook` - The path to the Python-based Notebook that is used as a template for the wizard.
|
||||
|
||||
`pages` - An array of [NotebookWizardPageInfo](#notebookwizardpageinfo) containing information for each page in the Notebook Wizard.
|
||||
|
||||
`codeCellInsertionPosition` - **OPTIONAL** The index of the code cell to insert the injected parameters cell. Default is 0.
|
||||
|
||||
### WizardInfoBase
|
||||
|
||||
`type` - **OPTIONAL** This is an internal type only used for BDC deployment wizards. Any other deployment providers can leave it out.
|
||||
|
||||
`doneAction`
|
||||
|
||||
`scriptAction` - **OPTIONAL**
|
||||
|
||||
`title`
|
||||
|
||||
`name` - **OPTIONAL**
|
||||
|
||||
`pages` - An array of the pages for this wizard. Each wizard implementation will usually have its own page type that extends [PageInfoBase](#pageinfobase).
|
||||
|
||||
`isSummaryPageAutoGenerated` - **OPTIONAL**
|
||||
|
||||
### NotebookWizardPageInfo (extends [PageInfoBase](#pageinfobase))
|
||||
|
||||
`description` - **OPTIONAL** The page description to display at the top of the page.
|
||||
|
||||
### PageInfoBase
|
||||
|
||||
`title` - The title to display for the page
|
||||
|
||||
`isSummaryPage` - **OPTIONAL** Whether this page is set as a summary page that displays a summary of the Note
|
||||
|
||||
`sections` - An array of [SectionInfo] objects containing the details of each section to display on this page.
|
||||
|
||||
### SectionInfo (extends [FieldInfoBase](#fieldinfobase))
|
||||
|
||||
`title` - **OPTIONAL** The title to display at the top of the section
|
||||
|
||||
`fields` - **OPTIONAL** An array of [FieldInfo](#fieldinfo) objects containing details for each field in this section.
|
||||
|
||||
`rows` - **OPTIONAL** Used for wide dialogs or wizards, the label for each field will be placed to the left of the field component.
|
||||
|
||||
`collapsible` - **OPTIONAL** Whether the section is collapsible or not. Default is `true`.
|
||||
|
||||
`collapsed` - **OPTIONAL** Whether the section starts off collapsed. Default is `false`.
|
||||
|
||||
`spaceBetweenFields` - **OPTIONAL** A string defining how much space should be between each field. Default is `50px`.
|
||||
|
||||
### FieldInfo
|
||||
|
||||
`subFields`
|
||||
|
||||
`type`
|
||||
|
||||
`defaultValue`
|
||||
|
||||
`confirmationRequired`
|
||||
|
||||
`confirmationLabel`
|
||||
|
||||
`min`
|
||||
|
||||
`max`
|
||||
|
||||
`required`
|
||||
|
||||
`options`
|
||||
|
||||
`placeHolder`
|
||||
|
||||
`description`
|
||||
|
||||
`labelCSSStyles`
|
||||
|
||||
`fontWeight`
|
||||
|
||||
`editable`
|
||||
|
||||
`enabled`
|
||||
|
||||
`dynamicOptions`
|
||||
|
||||
`isEvaluated`
|
||||
|
||||
`validations`
|
||||
|
||||
`valueProvider` - **OPTIONAL** If defined then the value for this field is retrieved using the specified [Value Provider](#value-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.
|
||||
|
||||
See [sample-value-provider](https://github.com/microsoft/azuredatastudio/blob/main/samples/sample-resource-deployment/package.json) for an example implementation.
|
||||
|
||||
**NOTE** There is currently some behavior that should be known before using this :
|
||||
|
||||
1. The value providers are hooked up after all the components are made, so order doesn't generally matter (you don't have to define the trigger fields before the target field) when the values are on the same page.
|
||||
2. If the fields are on different pages then currently the hookup logic is non-deterministic and so you may end up with trigger components not existing yet if they are on a different page which hasn't completed its initialization. **So currently having a value provider that has trigger fields on another page is not something officially supported. Contact the dev team if you need this for your scenario**
|
||||
|
||||
`providerId` - The string ID of this provider, this must be registered by an extension using [registerValueProvider](https://github.com/microsoft/azuredatastudio/blob/main/extensions/resource-deployment/src/typings/resource-deployment.d.ts#L47).
|
||||
|
||||
`triggerFields` - The field IDs (`variableName` or `label`) of the fields that - when changed - will trigger `getValue` to be called and the result set as the value of the dependent field. **NOTE** While `variableName` OR `label` is supported it is generally strongly suggested to use a `variableName` (even if you don't need that variable in the final deployment target) due to potential localization mismatches that could happen between the localized strings in the package.json and the ones used by the `valueProvider`.
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ async function hookUpValueProviders(context: WizardPageContext): Promise<void> {
|
||||
field.valueProvider.triggerFields.forEach((triggerField) => {
|
||||
const targetComponent = context.inputComponents[triggerField];
|
||||
if (!targetComponent) {
|
||||
console.error(`Could not find target component ${triggerField} when hooking up value providers for ${field.label}`);
|
||||
console.error(`Could not find target component '${triggerField}' when hooking up value providers for '${field.label}'`);
|
||||
return;
|
||||
}
|
||||
targetComponentLabelToComponent[triggerField] = targetComponent;
|
||||
|
||||
Reference in New Issue
Block a user