mirror of
https://github.com/apache/superset.git
synced 2026-04-20 00:24:38 +00:00
[sql lab] allow users to save their queries (#2528)
* Allow users to save their queries Fixing tests . * Adding placeholder for Query Description * initJQueryCSRF -> initJQueryAjaxCSRF
This commit is contained in:
committed by
GitHub
parent
c1d9918abe
commit
122891c29b
@@ -6,7 +6,7 @@ import * as Actions from '../actions';
|
||||
import SqlEditor from './SqlEditor';
|
||||
import CopyQueryTabUrl from './CopyQueryTabUrl';
|
||||
import { areArraysShallowEqual } from '../../reduxUtils';
|
||||
import { getParamFromQuery } from '../../../utils/common';
|
||||
import URI from 'urijs';
|
||||
|
||||
const propTypes = {
|
||||
actions: React.PropTypes.object.isRequired,
|
||||
@@ -35,19 +35,19 @@ class TabbedSqlEditors extends React.PureComponent {
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
const search = window.location.search;
|
||||
if (search) {
|
||||
const queryString = search.substring(1);
|
||||
const urlId = getParamFromQuery(queryString, 'id');
|
||||
if (urlId) {
|
||||
this.props.actions.popStoredQuery(urlId);
|
||||
} else {
|
||||
let dbId = getParamFromQuery(queryString, 'dbid');
|
||||
const query = URI(window.location).search(true);
|
||||
if (query.id || query.sql || query.savedQueryId) {
|
||||
if (query.id) {
|
||||
this.props.actions.popStoredQuery(query.id);
|
||||
} else if (query.savedQueryId) {
|
||||
this.props.actions.popSavedQuery(query.savedQueryId);
|
||||
} else if (query.sql) {
|
||||
let dbId = query.dbid;
|
||||
if (dbId) {
|
||||
dbId = parseInt(dbId, 10);
|
||||
} else {
|
||||
const databases = this.props.databases;
|
||||
const dbName = getParamFromQuery(queryString, 'dbname');
|
||||
const dbName = query.dbname;
|
||||
if (dbName) {
|
||||
Object.keys(databases).forEach((db) => {
|
||||
if (databases[db].database_name === dbName) {
|
||||
@@ -57,11 +57,11 @@ class TabbedSqlEditors extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
const newQueryEditor = {
|
||||
title: getParamFromQuery(queryString, 'title'),
|
||||
title: query.title,
|
||||
dbId,
|
||||
schema: getParamFromQuery(queryString, 'schema'),
|
||||
autorun: getParamFromQuery(queryString, 'autorun'),
|
||||
sql: getParamFromQuery(queryString, 'sql'),
|
||||
schema: query.schema,
|
||||
autorun: query.autorun,
|
||||
sql: query.sql,
|
||||
};
|
||||
this.props.actions.addQueryEditor(newQueryEditor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user