Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for dropdown of predefined options in data sources setup #4161

Merged
merged 7 commits into from
Oct 6, 2019

Conversation

gabrieldutra
Copy link
Member

@gabrieldutra gabrieldutra commented Sep 21, 2019

What type of PR is this? (check all applicable)

  • Feature

Description

This adds support to use Select in Data sources/Destinations setup.

  • Rendering in frontend
  • Check if ath is missing backend-wise

Related Tickets & Documents

--

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

ds-predefined-options

@gabrieldutra gabrieldutra self-assigned this Sep 21, 2019
Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about the schema.

Will it pick some value by default? I think think it should pick either the default value as default and if no default is specified, then it should pick the first value.

"options": [
{"value": "beeswax"},
{"value": "hiveserver2"}
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't pass schema validation. A valid enum is:

{
    "protocol": {
        "type": "string",
        "enum": ["beeswax", "hiveserver2"]
    }
}

We might want to add our own extension to provide friendly names for options:

{
    "protocol": {
        "type": "string",
        "extendedEnum": [{"value", "beeswax", "name": "Beeswax"}, {"value": "hiveserver2", "name": "Hive Server 2"}]
    }
}

And we will transform extendedEnum into enum before passing it into jsonschema.validate call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add our own extension to provide friendly names for options

That's exactly why I went with the list of objects on that, but yeah, it does make sense to permit a simplified version.

And we will transform extendedEnum into enum before passing it into jsonschema.validate call.

That's the only thing missing in terms of backend code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the only thing missing in terms of backend code?

I think so.

@gabrieldutra
Copy link
Member Author

Will it pick some value by default? I think think it should pick either the default value as default and if no default is specified, then it should pick the first value.

For now only if you specify a default value, for other cases I went with the placeholder. First value is an option too, I'll update that.

@arikfr
Copy link
Member

arikfr commented Sep 21, 2019

For now only if you specify a default value, for other cases I went with the placeholder. First value is an option too, I'll update that.

Because it will fail validation if you don't specify a value from the list it's best if we just pick one for you.

@@ -24,6 +24,11 @@ def __init__(self, config, schema=None):
self.set_schema(schema)

def set_schema(self, schema):
if isinstance(schema, dict):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed: schema is always a dict.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting a "NoneType has no attribute..." And that's why I put it 😬

redash/utils/configuration.py Show resolved Hide resolved
@gabrieldutra gabrieldutra marked this pull request as ready for review September 27, 2019 00:19
@gabrieldutra gabrieldutra added dependencies Pull requests that update a dependency file and removed dependencies Pull requests that update a dependency file labels Sep 27, 2019
@arikfr arikfr merged commit 569c325 into master Oct 6, 2019
@arikfr arikfr deleted the ds-predefined-options branch October 6, 2019 08:45
@arikfr
Copy link
Member

arikfr commented Oct 6, 2019

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants