PromucFlow_constructor/app/client/src/sagas/ActionExecution/ModalSagas.ts
Hetu Nandu 39b0a4e5a6
feat: Native promises support in Appsmith (#8988)
Co-authored-by: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com>
2021-12-23 14:17:20 +00:00

42 lines
1.1 KiB
TypeScript

import {
ActionTriggerType,
CloseModalActionDescription,
ShowModalActionDescription,
} from "entities/DataTree/actionTriggers";
import { put } from "redux-saga/effects";
import AppsmithConsole from "utils/AppsmithConsole";
import { ActionValidationError } from "sagas/ActionExecution/errorUtils";
import { getType, Types } from "utils/TypeHelpers";
export function* openModalSaga(action: ShowModalActionDescription) {
const { modalName } = action.payload;
if (typeof modalName !== "string") {
throw new ActionValidationError(
ActionTriggerType.SHOW_MODAL_BY_NAME,
"name",
Types.STRING,
getType(modalName),
);
}
yield put(action);
AppsmithConsole.info({
text: `openModal(${modalName}) was triggered`,
});
}
export function* closeModalSaga(action: CloseModalActionDescription) {
const { modalName } = action.payload;
if (typeof modalName !== "string") {
throw new ActionValidationError(
ActionTriggerType.CLOSE_MODAL,
"name",
Types.STRING,
getType(modalName),
);
}
yield put(action);
AppsmithConsole.info({
text: `closeModal(${modalName}) was triggered`,
});
}