PromucFlow_constructor/app/client/src/sagas/UtilSagas.ts
Ankita Kinger c1e48f7486
feat: Refactor code for SAML integration (#12700)
* Implemented code splitting of some files for SAML integration

* Implemented code splitting of some more files for SAML integration

* updated redirect url component

* fixed an import statement

* fixed a unit test

* updated restart banner tooltip logic

* updated an import statement
2022-04-12 16:20:01 +05:30

42 lines
1.2 KiB
TypeScript

import { all, takeEvery, race, put, take } from "redux-saga/effects";
import {
ReduxAction,
ReduxActionTypes,
} from "@appsmith/constants/ReduxActionConstants";
import history from "utils/history";
import { showActionConfirmationModal } from "actions/pluginActionActions";
import { ModalInfo } from "reducers/uiReducers/modalActionReducer";
function* redirectWindowLocationSaga(
actionPayload: ReduxAction<{ url: string }>,
) {
window.location.href = actionPayload.payload.url;
}
function* historyPushSaga(actionPayload: ReduxAction<{ url: string }>) {
history.push(actionPayload.payload.url);
}
export default function* root() {
yield all([
takeEvery(ReduxActionTypes.HISTORY_PUSH, historyPushSaga),
takeEvery(
ReduxActionTypes.REDIRECT_WINDOW_LOCATION,
redirectWindowLocationSaga,
),
]);
}
export function* requestModalConfirmationSaga(payload: ModalInfo) {
yield put(showActionConfirmationModal(payload));
const { accept } = yield race({
cancel: take(ReduxActionTypes.CANCEL_ACTION_MODAL + `_FOR_${payload.name}`),
accept: take(
ReduxActionTypes.CONFIRM_ACTION_MODAL + `_FOR_${payload.name}`,
),
});
return !!accept;
}