Skip to content

Commit

Permalink
fix(sqllab): Mistitled for new tab after rename
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Oct 4, 2023
1 parent 5ab1e7e commit a89d915
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 6 additions & 1 deletion superset-frontend/src/SqlLab/actions/sqlLab.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,12 @@ export function addNewQueryEditor() {
'-- Note: Unless you save your query, these tabs will NOT persist if you clear your cookies or change browsers.\n\n',
);

const name = newQueryTabName(queryEditors || []);
const name = newQueryTabName(
queryEditors?.map(qe => ({
...qe,
...(qe.id === unsavedQueryEditor.id && unsavedQueryEditor),
})) || [],
);

return dispatch(
addQueryEditor({
Expand Down
15 changes: 11 additions & 4 deletions superset-frontend/src/SqlLab/actions/sqlLab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,23 @@ describe('async actions', () => {

describe('addNewQueryEditor', () => {
it('creates new query editor with new tab name', () => {
const store = mockStore(initialState);
const store = mockStore({
...initialState,
sqlLab: {
...initialState.sqlLab,
unsavedQueryEditor: {
id: defaultQueryEditor.id,
name: 'Untitled Query 6',
},
},
});
const expectedActions = [
{
type: actions.ADD_QUERY_EDITOR,
queryEditor: {
id: 'abcd',
sql: expect.stringContaining('SELECT ...'),
name: `Untitled Query ${
store.getState().sqlLab.queryEditors.length + 1
}`,
name: `Untitled Query 7`,
dbId: defaultQueryEditor.dbId,
schema: defaultQueryEditor.schema,
autorun: false,
Expand Down

0 comments on commit a89d915

Please sign in to comment.