This is an automated email from the ASF dual-hosted git repository. lyndsi pushed a commit to branch lyndsi/sql-lab-new-explore-button-functionality-and-move-save-dataset-to-split-save-button in repository https://gitbox.apache.org/repos/asf/superset.git
commit ad2bbe3fa9a03f5905d88b8f8e53d5cd08fcecb0 Author: lyndsiWilliams <[email protected]> AuthorDate: Mon Jul 11 10:58:39 2022 -0500 Change QueryEditor title property to name --- superset-frontend/src/SqlLab/actions/sqlLab.js | 28 ++++++++++------------ .../src/SqlLab/actions/sqlLab.test.js | 16 ++++++------- .../SqlLab/components/ShareSqlLabQuery/index.tsx | 4 ++-- .../src/SqlLab/components/SqlEditor/index.jsx | 10 ++++---- .../SqlLab/components/TabbedSqlEditors/index.jsx | 6 ++--- .../src/SqlLab/reducers/getInitialState.js | 6 ++--- superset-frontend/src/SqlLab/reducers/sqlLab.js | 6 ++--- superset-frontend/src/SqlLab/types.ts | 2 +- .../src/SqlLab/utils/newQueryTabName.ts | 4 ++-- 9 files changed, 40 insertions(+), 42 deletions(-) diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 6a43821b5c..1435e0d796 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -112,7 +112,7 @@ const queryClientMapping = { id: 'remoteId', db_id: 'dbId', client_id: 'id', - label: 'title', + label: 'name', }; const queryServerMapping = invert(queryClientMapping); @@ -541,7 +541,7 @@ export function cloneQueryToNewTab(query, autorun) { qe => qe.id === tabHistory[tabHistory.length - 1], ); const queryEditor = { - title: t('Copy of %s', sourceQueryEditor.title), + name: t('Copy of %s', sourceQueryEditor.name), dbId: query.dbId ? query.dbId : null, schema: query.schema ? query.schema : null, autorun, @@ -629,7 +629,7 @@ export function switchQueryEditor(queryEditor, displayLimit) { const loadedQueryEditor = { id: json.id.toString(), loaded: true, - title: json.label, + name: json.label, sql: json.sql, selectedText: null, latestQueryId: json.latest_query?.id, @@ -834,24 +834,22 @@ export function queryEditorSetAutorun(queryEditor, autorun) { }; } -export function queryEditorSetTitle(queryEditor, title) { +export function queryEditorSetTitle(queryEditor, name) { return function (dispatch) { const sync = isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) ? SupersetClient.put({ endpoint: encodeURI(`/tabstateview/${queryEditor.id}`), - postPayload: { label: title }, + postPayload: { label: name }, }) : Promise.resolve(); return sync - .then(() => - dispatch({ type: QUERY_EDITOR_SET_TITLE, queryEditor, title }), - ) + .then(() => dispatch({ type: QUERY_EDITOR_SET_TITLE, queryEditor, name })) .catch(() => dispatch( addDangerToast( t( - 'An error occurred while setting the tab title. Please contact your administrator.', + 'An error occurred while setting the tab name. Please contact your administrator.', ), ), ), @@ -873,7 +871,7 @@ export function saveQuery(query) { query, result: savedQuery, }); - dispatch(queryEditorSetTitle(query, query.title)); + dispatch(queryEditorSetTitle(query, query.name)); return savedQuery; }) .catch(() => @@ -908,7 +906,7 @@ export function updateSavedQuery(query) { }) .then(() => { dispatch(addSuccessToast(t('Your query was updated'))); - dispatch(queryEditorSetTitle(query, query.title)); + dispatch(queryEditorSetTitle(query, query.name)); }) .catch(() => dispatch(addDangerToast(t('Your query could not be updated'))), @@ -965,7 +963,7 @@ export function queryEditorSetQueryLimit(queryEditor, queryLimit) { dispatch( addDangerToast( t( - 'An error occurred while setting the tab title. Please contact your administrator.', + 'An error occurred while setting the tab name. Please contact your administrator.', ), ), ), @@ -1264,7 +1262,7 @@ export function popStoredQuery(urlId) { .then(({ json }) => dispatch( addQueryEditor({ - title: json.title ? json.title : t('Shared query'), + name: json.name ? json.name : t('Shared query'), dbId: json.dbId ? parseInt(json.dbId, 10) : null, schema: json.schema ? json.schema : null, autorun: json.autorun ? json.autorun : false, @@ -1302,7 +1300,7 @@ export function popQuery(queryId) { dbId: queryData.database.id, schema: queryData.schema, sql: queryData.sql, - title: `Copy of ${queryData.tab_name}`, + name: `Copy of ${queryData.tab_name}`, autorun: false, }; return dispatch(addQueryEditor(queryEditorProps)); @@ -1318,7 +1316,7 @@ export function popDatasourceQuery(datasourceKey, sql) { .then(({ json }) => dispatch( addQueryEditor({ - title: `Query ${json.name}`, + name: `Query ${json.name}`, dbId: json.database.id, schema: json.schema, autorun: sql !== undefined, diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.test.js b/superset-frontend/src/SqlLab/actions/sqlLab.test.js index f9e972d2a4..1c4509b3a1 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.test.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.test.js @@ -38,8 +38,8 @@ describe('async actions', () => { latestQueryId: null, selectedText: null, sql: 'SELECT *\nFROM\nWHERE', - title: 'Untitled Query 1', - schemaOptions: [{ value: 'main', label: 'main', title: 'main' }], + name: 'Untitled Query 1', + schemaOptions: [{ value: 'main', label: 'main', name: 'main' }], }; let dispatch; @@ -290,7 +290,7 @@ describe('async actions', () => { const state = { sqlLab: { tabHistory: [id], - queryEditors: [{ id, title: 'Dummy query editor' }], + queryEditors: [{ id, name: 'Dummy query editor' }], }, }; const store = mockStore(state); @@ -350,7 +350,7 @@ describe('async actions', () => { const state = { sqlLab: { tabHistory: [id], - queryEditors: [{ id, title: 'Dummy query editor' }], + queryEditors: [{ id, name: 'Dummy query editor' }], }, }; const store = mockStore(state); @@ -358,7 +358,7 @@ describe('async actions', () => { { type: actions.ADD_QUERY_EDITOR, queryEditor: { - title: 'Copy of Dummy query editor', + name: 'Copy of Dummy query editor', dbId: 1, schema: null, autorun: true, @@ -617,17 +617,17 @@ describe('async actions', () => { it('updates the tab state in the backend', () => { expect.assertions(2); - const title = 'title'; + const name = 'name'; const store = mockStore({}); const expectedActions = [ { type: actions.QUERY_EDITOR_SET_TITLE, queryEditor, - title, + name, }, ]; return store - .dispatch(actions.queryEditorSetTitle(queryEditor, title)) + .dispatch(actions.queryEditorSetTitle(queryEditor, name)) .then(() => { expect(store.getActions()).toEqual(expectedActions); expect(fetchMock.calls(updateTabStateEndpoint)).toHaveLength(1); diff --git a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx index 5f473c642f..c521cb5dc7 100644 --- a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx +++ b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx @@ -49,8 +49,8 @@ function ShareSqlLabQuery({ const theme = useTheme(); const getCopyUrlForKvStore = (callback: Function) => { - const { dbId, title, schema, autorun, sql } = queryEditor; - const sharedQuery = { dbId, title, schema, autorun, sql }; + const { dbId, name, schema, autorun, sql } = queryEditor; + const sharedQuery = { dbId, name, schema, autorun, sql }; return storeQuery(sharedQuery) .then(shortUrl => { diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx index b66e13e4bf..346e53fbdb 100644 --- a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx +++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx @@ -345,10 +345,10 @@ class SqlEditor extends React.PureComponent { key: userOS === 'Windows' ? 'ctrl+q' : 'ctrl+t', descr: t('New tab'), func: () => { - const title = newQueryTabName(this.props.queryEditors || []); + const name = newQueryTabName(this.props.queryEditors || []); this.props.addQueryEditor({ ...this.props.queryEditor, - title, + name, }); }, }, @@ -463,7 +463,7 @@ class SqlEditor extends React.PureComponent { dbId: qe.dbId, sql: qe.selectedText ? qe.selectedText : qe.sql, sqlEditorId: qe.id, - tab: qe.title, + tab: qe.name, schema: qe.schema, tempTable: ctas ? this.state.ctas : '', templateParams: qe.templateParams, @@ -584,7 +584,7 @@ class SqlEditor extends React.PureComponent { {scheduledQueriesConf && ( <Menu.Item> <ScheduleQueryButton - defaultLabel={qe.title} + defaultLabel={qe.name} sql={qe.sql} onSchedule={this.props.actions.scheduleQuery} schema={qe.schema} @@ -722,7 +722,7 @@ class SqlEditor extends React.PureComponent { <span> <SaveQuery query={qe} - defaultLabel={qe.title || qe.description} + defaultLabel={qe.name || qe.description} onSave={this.saveQuery} onUpdate={this.props.actions.updateSavedQuery} saveQueryWarning={this.props.saveQueryWarning} diff --git a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx index 494ef9cba0..c97080c6e9 100644 --- a/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx +++ b/superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.jsx @@ -167,7 +167,7 @@ class TabbedSqlEditors extends React.PureComponent { } } const newQueryEditor = { - title: query.title, + name: query.name, dbId, schema: query.schema, autorun: query.autorun, @@ -266,7 +266,7 @@ class TabbedSqlEditors extends React.PureComponent { const newTitle = newQueryTabName(this.props.queryEditors || []); const qe = { - title: newTitle, + name: newTitle, dbId: activeQueryEditor && activeQueryEditor.dbId ? activeQueryEditor.dbId @@ -376,7 +376,7 @@ class TabbedSqlEditors extends React.PureComponent { const tabHeader = ( <TabTitleWrapper> <Dropdown overlay={menu} trigger={['click']} /> - <TabTitle>{qe.title}</TabTitle> <TabStatusIcon tabState={state} />{' '} + <TabTitle>{qe.name}</TabTitle> <TabStatusIcon tabState={state} />{' '} </TabTitleWrapper> ); return ( diff --git a/superset-frontend/src/SqlLab/reducers/getInitialState.js b/superset-frontend/src/SqlLab/reducers/getInitialState.js index d5f02029d0..21c367844d 100644 --- a/superset-frontend/src/SqlLab/reducers/getInitialState.js +++ b/superset-frontend/src/SqlLab/reducers/getInitialState.js @@ -41,7 +41,7 @@ export default function getInitialState({ const defaultQueryEditor = { id: null, loaded: true, - title: t('Untitled query'), + name: t('Untitled query'), sql: 'SELECT *\nFROM\nWHERE', selectedText: null, latestQueryId: null, @@ -73,7 +73,7 @@ export default function getInitialState({ queryEditor = { id: id.toString(), loaded: true, - title: activeTab.label, + name: activeTab.label, sql: activeTab.sql || undefined, selectedText: undefined, latestQueryId: activeTab.latest_query @@ -99,7 +99,7 @@ export default function getInitialState({ ...defaultQueryEditor, id: id.toString(), loaded: false, - title: label, + name: label, }; } queryEditors.push(queryEditor); diff --git a/superset-frontend/src/SqlLab/reducers/sqlLab.js b/superset-frontend/src/SqlLab/reducers/sqlLab.js index a9cef50870..f87c8ce9c1 100644 --- a/superset-frontend/src/SqlLab/reducers/sqlLab.js +++ b/superset-frontend/src/SqlLab/reducers/sqlLab.js @@ -48,7 +48,7 @@ export default function sqlLabReducer(state = {}, action) { existing, { remoteId: result.remoteId, - title: query.title, + name: query.name, }, 'id', ); @@ -71,7 +71,7 @@ export default function sqlLabReducer(state = {}, action) { ); const qe = { remoteId: progenitor.remoteId, - title: t('Copy of %s', progenitor.title), + name: t('Copy of %s', progenitor.name), dbId: action.query.dbId ? action.query.dbId : null, schema: action.query.schema ? action.query.schema : null, autorun: true, @@ -467,7 +467,7 @@ export default function sqlLabReducer(state = {}, action) { }, [actions.QUERY_EDITOR_SET_TITLE]() { return alterInArr(state, 'queryEditors', action.queryEditor, { - title: action.title, + name: action.name, }); }, [actions.QUERY_EDITOR_SET_SQL]() { diff --git a/superset-frontend/src/SqlLab/types.ts b/superset-frontend/src/SqlLab/types.ts index 6203598daa..8bb3e73d28 100644 --- a/superset-frontend/src/SqlLab/types.ts +++ b/superset-frontend/src/SqlLab/types.ts @@ -33,7 +33,7 @@ export type QueryDictionary = { export interface QueryEditor { dbId?: number; - title: string; + name: string; schema: string; autorun: boolean; sql: string; diff --git a/superset-frontend/src/SqlLab/utils/newQueryTabName.ts b/superset-frontend/src/SqlLab/utils/newQueryTabName.ts index 3815226cd4..c068fdd3d5 100644 --- a/superset-frontend/src/SqlLab/utils/newQueryTabName.ts +++ b/superset-frontend/src/SqlLab/utils/newQueryTabName.ts @@ -31,10 +31,10 @@ export const newQueryTabName = ( if (queryEditors.length > 0) { const mappedUntitled = queryEditors.filter(qe => - qe.title.match(untitledQueryRegex), + qe.name.match(untitledQueryRegex), ); const untitledQueryNumbers = mappedUntitled.map( - qe => +qe.title.replace(untitledQuery, ''), + qe => +qe.name.replace(untitledQuery, ''), ); if (untitledQueryNumbers.length > 0) { // When there are query tabs open, and at least one is called "Untitled Query #"
