Skip to content
Snippets Groups Projects
Commit 0caff25e authored by Tom Robinson's avatar Tom Robinson Committed by GitHub
Browse files

Merge pull request #3529 from metabase/fix-sql-button-logic

Fix SQL button logic
parents 22513926 492e585a
No related branches found
No related tags found
No related merge requests found
......@@ -169,7 +169,7 @@ export default class QueryHeader extends Component {
}
getHeaderButtons() {
const { isNew, isDirty, isEditing, tableMetadata } = this.props;
const { isNew, isDirty, isEditing, tableMetadata, databases } = this.props;
var buttonSections = [];
......@@ -335,9 +335,12 @@ export default class QueryHeader extends Component {
key="queryModeToggle"
mode={this.props.card.dataset_query.type}
allowNativeToQuery={isNew && !isDirty}
allowQueryToNative={isNew && (!isDirty ||
(tableMetadata && tableMetadata.db && tableMetadata.db.native_permissions === "write")
)}
allowQueryToNative={tableMetadata ?
// if a table is selected, only enable if user has native write permissions for THAT database
tableMetadata.db && tableMetadata.db.native_permissions === "write" :
// if no table is selected, only enable if user has native write permissions for ANY database
_.any(databases, (db) => db.native_permissions === "write")
}
nativeForm={this.props.result && this.props.result.data && this.props.result.data.native_form}
onSetMode={this.props.setQueryModeFn}
tableMetadata={tableMetadata}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment