Add DESTROY_RESOURCE_START action

pull/1349/head
Rick Carlino 2019-08-01 11:55:25 -05:00
parent 90b65ab5c6
commit 2010f6efbd
3 changed files with 8 additions and 0 deletions

View File

@ -194,8 +194,14 @@ export const destroyCatch = (p: DestroyNoProps) => (err: UnsafeError) => {
return Promise.reject(err);
};
/** We need this to detect read-only deletion attempts */
function destroyStart() {
return { type: Actions.DESTROY_RESOURCE_START, payload: {} };
}
export function destroy(uuid: string, force = false) {
return function (dispatch: Function, getState: GetState) {
dispatch(destroyStart());
/** Stop user from deleting resources if app is read only. */
if (appIsReadonly(getState().resources.index)) {
return Promise.reject("Application is in read-only mode.");

View File

@ -893,6 +893,7 @@ export namespace DiagnosticMessages {
export enum Actions {
// Resources
DESTROY_RESOURCE_START = "DESTROY_RESOURCE_START",
DESTROY_RESOURCE_OK = "DESTROY_RESOURCE_OK",
INIT_RESOURCE = "INIT_RESOURCE",
BATCH_INIT = "BATCH_INIT",

View File

@ -275,6 +275,7 @@ export const beforeEach = (state: RestResources,
return state;
}
case Actions.SAVE_RESOURCE_START:
case Actions.DESTROY_RESOURCE_START:
if (kind !== "WebAppConfig") {
// User is trying to make HTTP requests.
fail("3");