Skip to content

Commit

Permalink
Make it work for "extendedEnum" prop
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldutra committed Sep 24, 2019
1 parent d807a85 commit d40af5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client/app/components/dynamic-form/dynamicFormHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ function setDefaultValueToFields(configurationSchema, options = {}) {
}
// set default or first value when value has predefined options
if (property.type === 'select') {
options[key] = includes(property.enum, property.default) ? property.default : property.enum[0];
const optionValues = map(property.options, option => option.value);
options[key] = includes(optionValues, property.default) ? property.default : optionValues[0];
}
});
}
Expand Down
5 changes: 4 additions & 1 deletion redash/query_runner/impala_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def configuration_schema(cls):
},
"protocol": {
"type": "string",
"enum": ["beeswax", "hiveserver2"],
"extendedEnum": [
{"value": "beeswax", "name": "Beeswax"},
{"value": "hiveserver2", "name": "Hive Server 2"}
],
"title": "Protocol"
},
"database": {
Expand Down
5 changes: 5 additions & 0 deletions redash/utils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def __init__(self, config, schema=None):
self.set_schema(schema)

def set_schema(self, schema):
if isinstance(schema, dict):
for prop in schema.get('properties', {}).values():
if 'extendedEnum' in prop:
prop['enum'] = map(lambda v : v['value'], prop['extendedEnum'])
del prop['extendedEnum']
self._schema = schema

@property
Expand Down

0 comments on commit d40af5b

Please sign in to comment.