-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable "Run Query in New Tab" in SQL Lab (#1343)
* Enable "Clone to New Tab" btn in QueryHistoryTable Method #1; doesn't feel very clean. Going to attempt to reimplement using an action and changing state directly through the reducer rather than creating a new QueryEditor object directly from the QueryTable * Move Clone Logic to Action * Implement PR feedback * Clean up reducer action; fix bug Bug => Attempting to clone anything other than the most recent Query for a given TabbedQueryEditor would throw an exception, because we depended on lastQueryId to find the title of the QueryEditor to clone. Since you can only activate a clone from the currently active tab, we can instead fetch the ID of the Editor to copy the Title of from the tip of tabHistory. * Tests for Reducer Action * Fix CodeClimate feedback
- Loading branch information
1 parent
8f29944
commit 2edce5b
Showing
4 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as r from '../../../javascripts/SqlLab/reducers'; | ||
import * as actions from '../../../javascripts/SqlLab/actions'; | ||
import { describe, it } from 'mocha'; | ||
import { expect } from 'chai'; | ||
|
||
describe('sqlLabReducer', () => { | ||
describe('CLONE_QUERY_TO_NEW_TAB', () => { | ||
const testQuery = { sql: 'SELECT * FROM...', dbId: 1, id: 1 }; | ||
const state = Object.assign(r.initialState, { queries: [testQuery] }); | ||
const newState = r.sqlLabReducer(state, actions.cloneQueryToNewTab(testQuery)); | ||
|
||
it('should have at most one more tab', () => { | ||
expect(newState.queryEditors).have.length(2); | ||
}); | ||
|
||
it('should have the same SQL as the cloned query', () => { | ||
expect(newState.queryEditors[1].sql).to.equal(testQuery.sql); | ||
}); | ||
|
||
it('should prefix the new tab title with "Copy of"', () => { | ||
expect(newState.queryEditors[1].title).to.include('Copy of'); | ||
}); | ||
|
||
it('should push the cloned tab onto tab history stack', () => { | ||
expect(newState.tabHistory[1]).to.eq(newState.queryEditors[1].id); | ||
}); | ||
}); | ||
}); |