## Description This PR only contains interfaces for the EE AI feat. These are temporary changes ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? - Manual ### Test Plan > Add Testsmith test cases links that relate to this PR ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] New and existing unit tests pass locally with my changes - [x] My changes generate no new warnings - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
78 lines
2.0 KiB
TypeScript
78 lines
2.0 KiB
TypeScript
import { matchPath } from "react-router";
|
|
import { matchBasePath } from "@appsmith/pages/Editor/Explorer/helpers";
|
|
import {
|
|
API_EDITOR_ID_PATH,
|
|
QUERIES_EDITOR_ID_PATH,
|
|
DATA_SOURCES_EDITOR_ID_PATH,
|
|
JS_COLLECTION_ID_PATH,
|
|
matchBuilderPath,
|
|
} from "constants/routes";
|
|
import { SAAS_EDITOR_API_ID_PATH } from "pages/Editor/SaaSEditor/constants";
|
|
|
|
export const getEntityInCurrentPath = (pathName: string) => {
|
|
const builderMatch = matchBuilderPath(pathName);
|
|
if (builderMatch)
|
|
return {
|
|
type: "page",
|
|
id: builderMatch?.params?.pageId,
|
|
params: builderMatch?.params,
|
|
pageType: "canvas",
|
|
};
|
|
|
|
const baseMatch = matchBasePath(pathName);
|
|
if (!baseMatch) return { type: "", id: "" };
|
|
const { path: basePath } = baseMatch;
|
|
const apiMatch = matchPath<{ apiId: string }>(pathName, {
|
|
path: [
|
|
`${basePath}${API_EDITOR_ID_PATH}`,
|
|
`${basePath}${SAAS_EDITOR_API_ID_PATH}`,
|
|
],
|
|
});
|
|
if (apiMatch)
|
|
return {
|
|
type: "action",
|
|
id: apiMatch?.params?.apiId,
|
|
params: apiMatch?.params,
|
|
pageType: "apiEditor",
|
|
};
|
|
|
|
const queryMatch = matchPath<{ queryId: string }>(pathName, {
|
|
path: `${basePath}${QUERIES_EDITOR_ID_PATH}`,
|
|
});
|
|
if (queryMatch)
|
|
return {
|
|
type: "action",
|
|
id: queryMatch.params?.queryId,
|
|
params: queryMatch?.params,
|
|
pageType: "queryEditor",
|
|
};
|
|
|
|
const datasourceMatch = matchPath<{ datasourceId: string }>(pathName, {
|
|
path: `${basePath}${DATA_SOURCES_EDITOR_ID_PATH}`,
|
|
});
|
|
if (datasourceMatch)
|
|
return {
|
|
type: "datasource",
|
|
id: datasourceMatch?.params?.datasourceId,
|
|
params: datasourceMatch?.params,
|
|
pageType: "datasourceEditor",
|
|
};
|
|
|
|
const jsObjectMatch = matchPath<{ collectionId: string }>(pathName, {
|
|
path: `${basePath}${JS_COLLECTION_ID_PATH}`,
|
|
});
|
|
if (jsObjectMatch) {
|
|
return {
|
|
type: "jsAction",
|
|
id: jsObjectMatch?.params?.collectionId,
|
|
params: jsObjectMatch?.params,
|
|
pageType: "jsEditor",
|
|
};
|
|
}
|
|
|
|
return {
|
|
type: "",
|
|
id: "",
|
|
};
|
|
};
|