2022-03-25 10:43:26 +00:00
|
|
|
import {
|
2024-01-12 14:43:58 +00:00
|
|
|
ADD_PATH,
|
2022-03-27 16:25:08 +00:00
|
|
|
ADMIN_SETTINGS_PATH,
|
2023-01-10 12:09:33 +00:00
|
|
|
getViewerCustomPath,
|
|
|
|
|
getViewerPath,
|
2022-03-27 16:25:08 +00:00
|
|
|
TEMPLATES_PATH,
|
2022-03-25 10:43:26 +00:00
|
|
|
} from "constants/routes";
|
|
|
|
|
import { APP_MODE } from "entities/App";
|
2024-08-06 14:52:22 +00:00
|
|
|
import urlBuilder from "ee/entities/URLRedirect/URLAssembly";
|
|
|
|
|
import type { URLBuilderParams } from "ee/entities/URLRedirect/URLAssembly";
|
2024-08-22 04:19:30 +00:00
|
|
|
import type { Page } from "entities/Page";
|
|
|
|
|
import type { ApplicationPayload } from "entities/Application";
|
2022-03-25 10:43:26 +00:00
|
|
|
|
2022-07-11 04:06:29 +00:00
|
|
|
export const fillPathname = (
|
|
|
|
|
pathname: string,
|
|
|
|
|
application: ApplicationPayload,
|
|
|
|
|
page: Page,
|
|
|
|
|
) => {
|
|
|
|
|
const replaceValue = page.customSlug
|
2024-07-31 02:54:51 +00:00
|
|
|
? getViewerCustomPath(page.customSlug, page.basePageId)
|
|
|
|
|
: getViewerPath(application.slug, page.slug, page.basePageId);
|
2023-01-10 12:09:33 +00:00
|
|
|
|
2022-07-11 04:06:29 +00:00
|
|
|
return pathname.replace(
|
2024-07-31 02:54:51 +00:00
|
|
|
`/applications/${application.baseId}/pages/${page.basePageId}`,
|
2022-07-11 04:06:29 +00:00
|
|
|
replaceValue,
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const datasourcesEditorURL = (props: URLBuilderParams): string =>
|
|
|
|
|
urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
|
|
|
|
suffix: "datasource",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const datasourcesEditorIdURL = (
|
2022-07-11 04:06:29 +00:00
|
|
|
props: URLBuilderParams & {
|
2022-03-25 10:43:26 +00:00
|
|
|
datasourceId: string;
|
|
|
|
|
},
|
|
|
|
|
): string => {
|
2022-07-11 04:06:29 +00:00
|
|
|
return urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
|
|
|
|
suffix: `datasource/${props.datasourceId}`,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-24 08:52:40 +00:00
|
|
|
export interface WithAddView {
|
|
|
|
|
add?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 10:43:26 +00:00
|
|
|
export const jsCollectionIdURL = (
|
2024-01-24 08:52:40 +00:00
|
|
|
props: URLBuilderParams &
|
|
|
|
|
WithAddView & {
|
2024-07-31 02:54:51 +00:00
|
|
|
baseCollectionId: string;
|
2024-01-24 08:52:40 +00:00
|
|
|
// Pass a function name to set the cursor directly on the function
|
|
|
|
|
functionName?: string;
|
|
|
|
|
},
|
2022-03-25 10:43:26 +00:00
|
|
|
): string => {
|
2022-07-11 04:06:29 +00:00
|
|
|
return urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
2024-07-31 02:54:51 +00:00
|
|
|
suffix: `jsObjects/${props.baseCollectionId}${props.add ? ADD_PATH : ""}`,
|
2022-12-26 05:19:02 +00:00
|
|
|
hash: props.functionName,
|
2022-03-25 10:43:26 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const integrationEditorURL = (
|
2022-07-11 04:06:29 +00:00
|
|
|
props: URLBuilderParams & { selectedTab: string },
|
2022-03-25 10:43:26 +00:00
|
|
|
): string => {
|
|
|
|
|
const suffixPath = props.suffix ? `/${props.suffix}` : "";
|
2024-09-18 16:35:28 +00:00
|
|
|
|
2022-07-11 04:06:29 +00:00
|
|
|
return urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
|
|
|
|
suffix: `datasources/${props.selectedTab}${suffixPath}`,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const queryEditorIdURL = (
|
2024-01-24 08:52:40 +00:00
|
|
|
props: URLBuilderParams &
|
|
|
|
|
WithAddView & {
|
2024-07-31 02:54:51 +00:00
|
|
|
baseQueryId: string;
|
2024-01-24 08:52:40 +00:00
|
|
|
},
|
2022-03-25 10:43:26 +00:00
|
|
|
): string =>
|
2022-07-11 04:06:29 +00:00
|
|
|
urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
2024-07-31 02:54:51 +00:00
|
|
|
suffix: `queries/${props.baseQueryId}${props.add ? ADD_PATH : ""}`,
|
2022-03-25 10:43:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const apiEditorIdURL = (
|
2024-01-24 08:52:40 +00:00
|
|
|
props: URLBuilderParams &
|
|
|
|
|
WithAddView & {
|
2024-07-31 02:54:51 +00:00
|
|
|
baseApiId: string;
|
2024-01-24 08:52:40 +00:00
|
|
|
},
|
2022-03-25 10:43:26 +00:00
|
|
|
): string =>
|
2022-07-11 04:06:29 +00:00
|
|
|
urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
2024-07-31 02:54:51 +00:00
|
|
|
suffix: `api/${props.baseApiId}${props.add ? ADD_PATH : ""}`,
|
2022-03-25 10:43:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const saasEditorDatasourceIdURL = (
|
2022-07-11 04:06:29 +00:00
|
|
|
props: URLBuilderParams & {
|
2022-03-25 10:43:26 +00:00
|
|
|
pluginPackageName: string;
|
|
|
|
|
datasourceId: string;
|
|
|
|
|
},
|
|
|
|
|
): string =>
|
2022-07-11 04:06:29 +00:00
|
|
|
urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
|
|
|
|
suffix: `saas/${props.pluginPackageName}/datasources/${props.datasourceId}`,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const saasEditorApiIdURL = (
|
2024-01-31 05:18:56 +00:00
|
|
|
props: URLBuilderParams &
|
|
|
|
|
WithAddView & {
|
|
|
|
|
pluginPackageName: string;
|
2024-07-31 02:54:51 +00:00
|
|
|
baseApiId: string;
|
2024-01-31 05:18:56 +00:00
|
|
|
},
|
2022-03-25 10:43:26 +00:00
|
|
|
): string =>
|
2022-07-11 04:06:29 +00:00
|
|
|
urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
2024-07-31 02:54:51 +00:00
|
|
|
suffix: `saas/${props.pluginPackageName}/api/${props.baseApiId}${
|
2024-01-31 05:18:56 +00:00
|
|
|
props.add ? ADD_PATH : ""
|
|
|
|
|
}`,
|
2022-03-25 10:43:26 +00:00
|
|
|
});
|
|
|
|
|
|
2022-07-11 04:06:29 +00:00
|
|
|
export const onboardingCheckListUrl = (props: URLBuilderParams): string =>
|
|
|
|
|
urlBuilder.build({
|
2022-03-25 10:43:26 +00:00
|
|
|
...props,
|
|
|
|
|
suffix: "checklist",
|
|
|
|
|
});
|
|
|
|
|
|
2022-07-11 04:06:29 +00:00
|
|
|
export const builderURL = (props: URLBuilderParams): string => {
|
|
|
|
|
return urlBuilder.build(props);
|
2022-03-25 10:43:26 +00:00
|
|
|
};
|
2023-12-22 08:21:47 +00:00
|
|
|
export const globalAddURL = (props: URLBuilderParams): string => {
|
|
|
|
|
return urlBuilder.build({
|
|
|
|
|
...props,
|
|
|
|
|
suffix: "add",
|
|
|
|
|
});
|
|
|
|
|
};
|
2022-03-25 10:43:26 +00:00
|
|
|
|
2023-02-21 13:38:16 +00:00
|
|
|
export const widgetURL = (
|
2024-03-15 09:27:06 +00:00
|
|
|
props: URLBuilderParams & WithAddView & { selectedWidgets: string[] },
|
2023-02-21 13:38:16 +00:00
|
|
|
) => {
|
|
|
|
|
return urlBuilder.build({
|
|
|
|
|
...props,
|
2024-03-15 09:27:06 +00:00
|
|
|
suffix: `widgets/${props.selectedWidgets.join(",")}${
|
|
|
|
|
props.add ? ADD_PATH : ""
|
|
|
|
|
}`,
|
2023-02-21 13:38:16 +00:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-18 10:40:25 +00:00
|
|
|
export const widgetListURL = (props: URLBuilderParams) => {
|
|
|
|
|
return urlBuilder.build({
|
|
|
|
|
...props,
|
|
|
|
|
suffix: `widgets`,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-11 04:06:29 +00:00
|
|
|
export const viewerURL = (props: URLBuilderParams): string => {
|
|
|
|
|
return urlBuilder.build(props, APP_MODE.PUBLISHED);
|
2022-03-25 10:43:26 +00:00
|
|
|
};
|
2022-03-27 16:25:08 +00:00
|
|
|
|
|
|
|
|
export function adminSettingsCategoryUrl({
|
|
|
|
|
category,
|
2022-06-08 13:18:15 +00:00
|
|
|
selected,
|
2022-03-27 16:25:08 +00:00
|
|
|
}: {
|
|
|
|
|
category: string;
|
2022-06-08 13:18:15 +00:00
|
|
|
selected?: string;
|
2022-03-27 16:25:08 +00:00
|
|
|
}) {
|
2022-06-08 13:18:15 +00:00
|
|
|
return `${ADMIN_SETTINGS_PATH}/${category}${selected ? "/" + selected : ""}`;
|
2022-03-27 16:25:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const templateIdUrl = ({ id }: { id: string }): string =>
|
|
|
|
|
`${TEMPLATES_PATH}/${id}`;
|
2023-11-23 09:23:20 +00:00
|
|
|
|
|
|
|
|
export const jsCollectionListURL = (props: URLBuilderParams): string => {
|
|
|
|
|
return urlBuilder.build({
|
|
|
|
|
...props,
|
|
|
|
|
suffix: `jsObjects`,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-27 08:47:35 +00:00
|
|
|
export const jsCollectionAddURL = (props: URLBuilderParams): string => {
|
|
|
|
|
return urlBuilder.build({
|
|
|
|
|
...props,
|
|
|
|
|
suffix: "jsObjects/add",
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-23 09:23:20 +00:00
|
|
|
export const queryListURL = (props: URLBuilderParams): string =>
|
|
|
|
|
urlBuilder.build({
|
|
|
|
|
...props,
|
|
|
|
|
suffix: `queries`,
|
|
|
|
|
});
|
2023-12-18 10:40:25 +00:00
|
|
|
|
|
|
|
|
export const queryAddURL = (props: URLBuilderParams): string =>
|
|
|
|
|
urlBuilder.build({
|
|
|
|
|
...props,
|
|
|
|
|
suffix: `queries/add`,
|
|
|
|
|
});
|
2024-10-22 05:18:03 +00:00
|
|
|
|
|
|
|
|
export const appLibrariesURL = (): string =>
|
|
|
|
|
urlBuilder.build({
|
|
|
|
|
suffix: "libraries",
|
|
|
|
|
});
|
|
|
|
|
export const appPackagesURL = (): string =>
|
|
|
|
|
urlBuilder.build({
|
|
|
|
|
suffix: "packages",
|
|
|
|
|
});
|