mirror of
https://github.com/apache/superset.git
synced 2026-05-09 18:05:52 +00:00
More goodness
This commit is contained in:
@@ -12,11 +12,12 @@ const defaultQueryEditor = {
|
||||
};
|
||||
|
||||
export const initialState = {
|
||||
queryEditors: [defaultQueryEditor],
|
||||
alerts: [],
|
||||
queries: [],
|
||||
queryEditors: [defaultQueryEditor],
|
||||
tabHistory: [defaultQueryEditor.id],
|
||||
tables: [],
|
||||
workspaceQueries: [],
|
||||
tabHistory: [defaultQueryEditor.id],
|
||||
};
|
||||
|
||||
|
||||
@@ -46,6 +47,9 @@ function removeFromArr(state, arrKey, obj, idKey = 'id') {
|
||||
}
|
||||
|
||||
function addToArr(state, arrKey, obj) {
|
||||
if (!(obj.id)) {
|
||||
obj.id = shortid.generate();
|
||||
}
|
||||
const newState = {};
|
||||
newState[arrKey] = [...state[arrKey], Object.assign({}, obj)];
|
||||
return Object.assign({}, state, newState);
|
||||
@@ -137,6 +141,12 @@ export const sqlLabReducer = function (state, action) {
|
||||
[actions.REMOVE_WORKSPACE_QUERY]() {
|
||||
return removeFromArr(state, 'workspaceQueries', action.query);
|
||||
},
|
||||
[actions.ADD_ALERT]() {
|
||||
return addToArr(state, 'alerts', action.alert);
|
||||
},
|
||||
[actions.REMOVE_ALERT]() {
|
||||
return removeFromArr(state, 'alerts', action.alert);
|
||||
},
|
||||
};
|
||||
if (action.type in actionHandlers) {
|
||||
return actionHandlers[action.type]();
|
||||
|
||||
Reference in New Issue
Block a user