Azure / azure-resource-manager-schemas

Schemas used to author and validate Resource Manager Templates. These schemas power the intellisense and syntax completion in our ARM Tools VSCode extension, as well as the Export Template API
MIT License
609 stars 516 forks source link

DropDown with multiselect enabled should return array value for default selection #1095

Open galiacheng opened 4 years ago

galiacheng commented 4 years ago

Hello team,

Microsoft.Common.DropDown with multiselect enabled returns a string value if I don't change the default value by clicking any dropdown item, which stops template validation, as the expected parameter type is array.

Reproduce steps:

  1. Copy the following json code to UI Definition Sandbox
  2. Click "Preview"
  3. Input resource group
  4. Click "Yes" in Elasticsearch and Kibana section. And DO NOT select any items, keep the default one.
  5. Click Review + create
  6. Click "View outputs payload"

You will find the output value of "test" is 'ServerLog'. Expected value is ["ServerLog"]

{
    "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
    "handler": "Microsoft.Azure.CreateUIDef",
    "version": "0.1.2-preview",
    "parameters": {
        "basics": [],
        "steps": [
            {
                "name": "section_elk",
                "label": "Elasticsearch and Kibana",
                "subLabel": {
                    "preValidation": "Configure the connection to Elasticsearch and Kibana.",
                    "postValidation": "Done"
                },
                "bladeTitle": "Elasticsearch and Kibana",
                "elements": [
                    {
                        "name": "aboutelk",
                        "type": "Microsoft.Common.TextBlock",
                        "visible": true,
                        "options": {
                            "icon": "None",
                            "text": "Selecting 'Yes' here and providing the configuration will cause the template to configure the Elasticsearch and Kibana, the WebLogic Server logs will be exported to Elasticsearch.",
                            "link": {
                                "label": "Learn more",
                                "uri": "https://www.elastic.co/azure"
                            }
                        }
                    },
                    {
                        "name": "enableELK",
                        "type": "Microsoft.Common.OptionsGroup",
                        "label": "Export logs to Elasticsearch?",
                        "defaultValue": "No",
                        "toolTip": "Select 'Yes' and provide required info to configure the connection to Elasticsearch.",
                        "constraints": {
                            "allowedValues": [
                                {
                                    "label": "Yes",
                                    "value": "true"
                                },
                                {
                                    "label": "No",
                                    "value": "false"
                                }
                            ],
                            "required": true
                        }
                    },
                    {
                        "name": "elkInfo",
                        "type": "Microsoft.Common.Section",
                        "label": "Connection settings",
                        "elements": [
                            {
                                "name": "logsToIntegrate",
                                "type": "Microsoft.Common.DropDown",
                                "label": "WebLogic Server logs to export",
                                "toolTip": "The logs selected will be exported to Elasticsearch.",
                                "defaultValue": "Server Log",
                                "multiselect": true,
                                "selectAll": true,
                                "multiLine": true,
                                "defaultDescription": "The logs selected will be exported to Elasticsearch",
                                "constraints": {
                                    "allowedValues": [
                                        {
                                            "label": "Data Source Log",
                                            "description": "Export Datasource logs to Elasticsearch.",
                                            "value": "DataSourceLog"
                                        },
                                        {
                                            "label": "Domain Log",
                                            "description": "Export Domain logs to Elasticsearch.",
                                            "value": "DomainLog"
                                        },
                                        {
                                            "label": "HTTP Access Log",
                                            "description": "Export HTTP logs to Elasticsearch.",
                                            "value": "HTTPAccessLog"
                                        },
                                        {
                                            "label": "Server Log",
                                            "description": "Export Server logs to Elasticsearch.",
                                            "value": "ServerLog"
                                        },
                                        {
                                            "label": "stdout",
                                            "description": "Export stdout logs to Elasticsearch.",
                                            "value": "stdout"
                                        },
                                        {
                                            "label": "stderr",
                                            "description": "Export stderr logs to Elasticsearch.",
                                            "value": "stderr"
                                        }
                                    ],
                                    "required": true
                                }
                            }
                        ],
                        "visible": "[bool(steps('section_elk').enableELK)]"
                    }
                ]
            },
            {
                "name": "tags",
                "label": "Tags",
                "elements": [
                    {
                        "name": "tagsByResource",
                        "type": "Microsoft.Common.TagsByResource",
                        "resources": [
                            "Microsoft.Storage/storageAccounts",
                            "Microsoft.Compute/virtualMachines"
                        ]
                    }
                ]
            }
        ],
        "outputs": {
            "tagsByResource": "[steps('tags').tagsByResource]",
            "test": "[steps('section_elk').elkInfo.logsToIntegrate]"
        }
    }
}
anthony-c-martin commented 4 years ago

@QuinnMcHugh mind taking a look at this?

QuinnMcHugh commented 4 years ago

Adding @Naira (v-mnaira)