2023-11-09 11:40:36 +00:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2025-01-10 04:51:54 +00:00
|
|
|
import type { ReduxAction } from "actions/ReduxActionTypes";
|
2023-11-09 11:40:36 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionErrorTypes,
|
|
|
|
|
ReduxActionTypes,
|
2024-08-06 14:52:22 +00:00
|
|
|
} from "ee/constants/ReduxActionConstants";
|
|
|
|
|
import type { ExplorerURLParams } from "ee/pages/Editor/Explorer/helpers";
|
|
|
|
|
import type { DependentFeatureFlags } from "ee/selectors/engineSelectors";
|
2023-11-09 11:40:36 +00:00
|
|
|
import { fetchDatasources } from "actions/datasourceActions";
|
|
|
|
|
import { fetchPageDSLs } from "actions/pageActions";
|
|
|
|
|
import { fetchPlugins } from "actions/pluginActions";
|
2024-01-23 07:46:43 +00:00
|
|
|
import type { Plugin } from "api/PluginApi";
|
2024-07-31 02:54:51 +00:00
|
|
|
import { useSelector } from "react-redux";
|
|
|
|
|
import { useParams } from "react-router";
|
2024-01-24 06:44:16 +00:00
|
|
|
import type { EditConsolidatedApi } from "sagas/InitSagas";
|
2024-07-31 02:54:51 +00:00
|
|
|
import {
|
|
|
|
|
convertToBaseParentEntityIdSelector,
|
|
|
|
|
convertToPageIdSelector,
|
|
|
|
|
} from "selectors/pageListSelectors";
|
2023-11-09 11:40:36 +00:00
|
|
|
|
2023-12-21 04:52:54 +00:00
|
|
|
export const CreateNewActionKey = {
|
|
|
|
|
PAGE: "pageId",
|
|
|
|
|
} as const;
|
|
|
|
|
|
2023-12-26 06:08:00 +00:00
|
|
|
export const ActionParentEntityType = {
|
2023-12-21 04:52:54 +00:00
|
|
|
PAGE: "PAGE",
|
|
|
|
|
} as const;
|
2023-12-13 17:43:43 +00:00
|
|
|
|
2024-01-15 08:23:00 +00:00
|
|
|
export const getPageDependencyActions = (
|
|
|
|
|
currentWorkspaceId: string = "",
|
|
|
|
|
featureFlags: DependentFeatureFlags = {},
|
2024-01-24 06:44:16 +00:00
|
|
|
allResponses: EditConsolidatedApi,
|
2024-10-22 05:18:03 +00:00
|
|
|
applicationId: string,
|
2024-01-15 08:23:00 +00:00
|
|
|
) => {
|
2024-01-24 06:44:16 +00:00
|
|
|
const { datasources, pagesWithMigratedDsl, plugins } = allResponses || {};
|
|
|
|
|
const initActions = [
|
|
|
|
|
fetchPlugins({ plugins }),
|
|
|
|
|
fetchDatasources({ datasources }),
|
|
|
|
|
fetchPageDSLs({ pagesWithMigratedDsl }),
|
|
|
|
|
] as Array<ReduxAction<unknown>>;
|
2023-11-09 11:40:36 +00:00
|
|
|
|
|
|
|
|
const successActions = [
|
|
|
|
|
ReduxActionTypes.FETCH_PLUGINS_SUCCESS,
|
|
|
|
|
ReduxActionTypes.FETCH_DATASOURCES_SUCCESS,
|
|
|
|
|
ReduxActionTypes.FETCH_PAGE_DSLS_SUCCESS,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const errorActions = [
|
|
|
|
|
ReduxActionErrorTypes.FETCH_PLUGINS_ERROR,
|
|
|
|
|
ReduxActionErrorTypes.FETCH_DATASOURCES_ERROR,
|
|
|
|
|
ReduxActionErrorTypes.POPULATE_PAGEDSLS_ERROR,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
initActions,
|
|
|
|
|
successActions,
|
|
|
|
|
errorActions,
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-01-23 07:46:43 +00:00
|
|
|
|
|
|
|
|
export const doesPluginRequireDatasource = (plugin: Plugin | undefined) => {
|
|
|
|
|
return !!plugin && plugin.hasOwnProperty("requiresDatasource")
|
|
|
|
|
? plugin.requiresDatasource
|
|
|
|
|
: true;
|
|
|
|
|
};
|
2024-03-04 14:26:47 +00:00
|
|
|
|
|
|
|
|
export enum APPSMITH_NAMESPACED_FUNCTIONS {}
|
2024-03-07 10:06:31 +00:00
|
|
|
|
2024-07-31 02:54:51 +00:00
|
|
|
export const useParentEntityDetailsFromParams = (
|
2024-03-07 10:06:31 +00:00
|
|
|
parentEntityIdProp: string,
|
|
|
|
|
isInsideReconnectModal?: boolean,
|
|
|
|
|
) => {
|
2024-07-31 02:54:51 +00:00
|
|
|
const baseParentEntityIdProp = useSelector((state) =>
|
|
|
|
|
convertToBaseParentEntityIdSelector(state, parentEntityIdProp),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const { basePageId } = useParams<ExplorerURLParams>();
|
|
|
|
|
const parentEntityIdQuery = basePageId || "";
|
|
|
|
|
const pageId = useSelector((state) =>
|
|
|
|
|
convertToPageIdSelector(state, basePageId),
|
|
|
|
|
);
|
|
|
|
|
const baseParentEntityIdQuery = pageId || "";
|
|
|
|
|
|
2024-03-07 10:06:31 +00:00
|
|
|
const parentEntityId = isInsideReconnectModal
|
|
|
|
|
? parentEntityIdProp
|
|
|
|
|
: parentEntityIdQuery;
|
2024-07-31 02:54:51 +00:00
|
|
|
const baseParentEntityId = isInsideReconnectModal
|
|
|
|
|
? baseParentEntityIdProp
|
|
|
|
|
: baseParentEntityIdQuery;
|
|
|
|
|
|
2024-03-07 10:06:31 +00:00
|
|
|
const entityType = ActionParentEntityType.PAGE;
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2024-07-31 02:54:51 +00:00
|
|
|
return { baseParentEntityId, parentEntityId, entityType };
|
2024-03-07 10:06:31 +00:00
|
|
|
};
|