Skip to content

Commit

Permalink
[explore-v2] Fix edit datasource link for druid datasources (#1982)
Browse files Browse the repository at this point in the history
* only add imgSrc key if choices contain an imgSrc

* handle table and druid edit links for datasource drop down

* fix linting
  • Loading branch information
Alanna Scott authored Jan 23, 2017
1 parent 37fb56c commit 9cbd667
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 4 additions & 6 deletions superset/assets/javascripts/explorev2/components/SelectField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ export default class SelectField extends React.Component {
}
getOptions() {
const options = this.props.choices.map((c) => {
let label = c[0];
if (c.length > 1) {
label = c[1];
}
return {
const label = c.length > 1 ? c[1] : c[0];
const newOptions = {
value: c[0],
label,
imgSrc: c[2],
};
if (c[2]) newOptions.imgSrc = c[2];
return newOptions;
});
if (this.props.freeForm) {
// For FreeFormSelect, insert value into options if not exist
Expand Down
7 changes: 6 additions & 1 deletion superset/assets/javascripts/explorev2/stores/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ const TIME_STAMP_OPTIONS = [
['%H:%M:%S', '%H:%M:%S | 01:32:10'],
];

const MAP_DATASOURCE_TYPE_TO_EDIT_URL = {
table: '/tablemodelview/edit',
druid: '/druiddatasourcemodelview/edit',
};

export const fields = {
datasource: {
type: 'SelectField',
label: 'Datasource',
clearable: false,
default: null,
editUrl: '/tablemodelview/edit',
mapStateToProps: (state) => ({
choices: state.datasources || [],
editUrl: MAP_DATASOURCE_TYPE_TO_EDIT_URL[state.datasource_type],
}),
description: '',
},
Expand Down

0 comments on commit 9cbd667

Please sign in to comment.