mirror of
https://github.com/apache/superset.git
synced 2026-04-12 20:57:55 +00:00
* 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
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
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());
|
|
}
|
|
});
|
|
};
|
|
}
|