PromucFlow_constructor/app/client/src/sagas/SaaSPaneSagas.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

55 lines
1.7 KiB
TypeScript

import { all, select, takeEvery } from "redux-saga/effects";
import {
ReduxAction,
ReduxActionTypes,
} from "@appsmith/constants/ReduxActionConstants";
import history from "utils/history";
import { getPlugin } from "selectors/entitiesSelector";
import { Datasource } from "entities/Datasource";
import { Action, PluginType } from "entities/Action";
import { Plugin } from "api/PluginApi";
import { saasEditorApiIdURL, saasEditorDatasourceIdURL } from "RouteBuilder";
function* handleDatasourceCreatedSaga(actionPayload: ReduxAction<Datasource>) {
const plugin = yield select(getPlugin, actionPayload.payload.pluginId);
// Only look at SAAS plugins
if (plugin.type !== PluginType.SAAS) return;
history.push(
saasEditorDatasourceIdURL({
pluginPackageName: plugin.packageName,
datasourceId: actionPayload.payload.id,
params: { from: "datasources" },
}),
);
}
function* handleActionCreatedSaga(actionPayload: ReduxAction<Action>) {
const { id, pluginId } = actionPayload.payload;
const plugin: Plugin = yield select(getPlugin, pluginId);
if (plugin.type !== "SAAS") return;
history.push(
saasEditorApiIdURL({
pluginPackageName: plugin.packageName,
apiId: id,
params: {
editName: "true",
from: "datasources",
},
}),
);
}
// since we are re-using the query editor form names for SAAS actions, all formValueChanges will be handled in the QuerypaneSagas.
export default function* root() {
yield all([
takeEvery(
ReduxActionTypes.CREATE_DATASOURCE_SUCCESS,
handleDatasourceCreatedSaga,
),
takeEvery(ReduxActionTypes.CREATE_ACTION_SUCCESS, handleActionCreatedSaga),
]);
}