mirror of
https://github.com/apache/superset.git
synced 2026-04-16 14:45:21 +00:00
[explore] Split large reducer logic in ExploreViewContainer (#3088)
* split reducer logic for ExploreViewContainer * fix saveModal component and unit tests * revert changes in SaveModal_spec. will make another commit just to improve test coverage for SaveModal component. * remove comment-out code * fix merge confilicts
This commit is contained in:
committed by
Maxime Beauchemin
parent
08b7e891a7
commit
b3107bb603
@@ -0,0 +1,57 @@
|
||||
const $ = window.$ = require('jquery');
|
||||
|
||||
export const FETCH_DASHBOARDS_SUCCEEDED = 'FETCH_DASHBOARDS_SUCCEEDED';
|
||||
export function fetchDashboardsSucceeded(choices) {
|
||||
return { type: FETCH_DASHBOARDS_SUCCEEDED, choices };
|
||||
}
|
||||
|
||||
export const FETCH_DASHBOARDS_FAILED = 'FETCH_DASHBOARDS_FAILED';
|
||||
export function fetchDashboardsFailed(userId) {
|
||||
return { type: FETCH_DASHBOARDS_FAILED, userId };
|
||||
}
|
||||
|
||||
export function fetchDashboards(userId) {
|
||||
return function (dispatch) {
|
||||
const url = '/dashboardmodelviewasync/api/read?_flt_0_owners=' + userId;
|
||||
return $.ajax({
|
||||
type: 'GET',
|
||||
url,
|
||||
success: (data) => {
|
||||
const choices = [];
|
||||
for (let i = 0; i < data.pks.length; i++) {
|
||||
choices.push({ value: data.pks[i], label: data.result[i].dashboard_title });
|
||||
}
|
||||
dispatch(fetchDashboardsSucceeded(choices));
|
||||
},
|
||||
error: () => {
|
||||
dispatch(fetchDashboardsFailed(userId));
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const SAVE_SLICE_FAILED = 'SAVE_SLICE_FAILED';
|
||||
export function saveSliceFailed() {
|
||||
return { type: SAVE_SLICE_FAILED };
|
||||
}
|
||||
export const SAVE_SLICE_SUCCESS = 'SAVE_SLICE_SUCCESS';
|
||||
export function saveSliceSuccess(data) {
|
||||
return { type: SAVE_SLICE_SUCCESS, data };
|
||||
}
|
||||
|
||||
export const REMOVE_SAVE_MODAL_ALERT = 'REMOVE_SAVE_MODAL_ALERT';
|
||||
export function removeSaveModalAlert() {
|
||||
return { type: REMOVE_SAVE_MODAL_ALERT };
|
||||
}
|
||||
|
||||
export function saveSlice(url) {
|
||||
return function (dispatch) {
|
||||
return $.get(url, (data, status) => {
|
||||
if (status === 'success') {
|
||||
dispatch(saveSliceSuccess(data));
|
||||
} else {
|
||||
dispatch(saveSliceFailed());
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user