2024-08-06 14:52:22 +00:00
|
|
|
import type { EventLocation } from "ee/utils/analyticsUtilTypes";
|
2023-12-13 17:43:43 +00:00
|
|
|
import { createNewJSCollection } from "actions/jsPaneActions";
|
2023-12-26 06:08:00 +00:00
|
|
|
import {
|
|
|
|
|
ActionParentEntityType,
|
|
|
|
|
type ActionParentEntityTypeInterface,
|
2024-08-06 14:52:22 +00:00
|
|
|
} from "ee/entities/Engine/actionHelpers";
|
2024-10-08 10:42:27 +00:00
|
|
|
import {
|
|
|
|
|
createNewApiAction,
|
|
|
|
|
createNewQueryAction,
|
|
|
|
|
saveActionName,
|
|
|
|
|
} from "actions/pluginActionActions";
|
2023-12-21 04:52:54 +00:00
|
|
|
import { saveJSObjectName } from "actions/jsActionActions";
|
2025-02-07 11:15:55 +00:00
|
|
|
import { IDE_TYPE, type IDEType } from "ee/IDE/Interfaces/IDETypes";
|
2023-12-13 17:43:43 +00:00
|
|
|
|
|
|
|
|
export const createNewQueryBasedOnParentEntity = (
|
|
|
|
|
entityId: string,
|
|
|
|
|
from: EventLocation,
|
|
|
|
|
dsId: string,
|
|
|
|
|
// Used in EE
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-12-26 06:08:00 +00:00
|
|
|
parentEntityType: ActionParentEntityTypeInterface = ActionParentEntityType.PAGE,
|
2023-12-13 17:43:43 +00:00
|
|
|
) => {
|
|
|
|
|
return createNewQueryAction(entityId, from, dsId);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createNewAPIBasedOnParentEntity = (
|
|
|
|
|
entityId: string,
|
|
|
|
|
from: EventLocation,
|
|
|
|
|
apiType?: string,
|
|
|
|
|
// Used in EE
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-12-26 06:08:00 +00:00
|
|
|
parentEntityType: ActionParentEntityTypeInterface = ActionParentEntityType.PAGE,
|
2023-12-13 17:43:43 +00:00
|
|
|
) => {
|
|
|
|
|
return createNewApiAction(entityId, from, apiType);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createNewJSCollectionBasedOnParentEntity = (
|
|
|
|
|
entityId: string,
|
|
|
|
|
from: EventLocation,
|
|
|
|
|
// Used in EE
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-12-26 06:08:00 +00:00
|
|
|
parentEntityType = ActionParentEntityType.PAGE,
|
2023-12-13 17:43:43 +00:00
|
|
|
) => {
|
|
|
|
|
return createNewJSCollection(entityId, from);
|
|
|
|
|
};
|
2023-12-21 04:52:54 +00:00
|
|
|
|
2025-01-21 09:54:06 +00:00
|
|
|
export const saveActionNameBasedOnIdeType = (
|
2023-12-21 04:52:54 +00:00
|
|
|
id: string,
|
|
|
|
|
name: string,
|
|
|
|
|
// Used in EE
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2025-01-21 09:54:06 +00:00
|
|
|
ideType: IDEType = IDE_TYPE.App,
|
2023-12-21 04:52:54 +00:00
|
|
|
) => {
|
|
|
|
|
return saveActionName({ id, name });
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-21 09:54:06 +00:00
|
|
|
export const saveJSObjectNameBasedOnIdeType = (
|
2023-12-21 04:52:54 +00:00
|
|
|
id: string,
|
|
|
|
|
name: string,
|
|
|
|
|
// Used in EE
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2025-01-21 09:54:06 +00:00
|
|
|
ideType: IDEType = IDE_TYPE.App,
|
2023-12-21 04:52:54 +00:00
|
|
|
) => {
|
|
|
|
|
return saveJSObjectName({ id, name });
|
|
|
|
|
};
|
2023-12-26 06:08:00 +00:00
|
|
|
|
2025-01-21 09:54:06 +00:00
|
|
|
export const createNewApiActionBasedOnIdeType = (
|
2023-12-26 06:08:00 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2025-01-21 09:54:06 +00:00
|
|
|
ideType: IDEType,
|
2023-12-26 06:08:00 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
|
editorId: string,
|
|
|
|
|
parentEntityId: string,
|
|
|
|
|
parentEntityType: ActionParentEntityTypeInterface,
|
|
|
|
|
apiType: string,
|
2024-07-31 15:41:28 +00:00
|
|
|
// TODO: Fix this the next time the file is edited
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2023-12-26 06:08:00 +00:00
|
|
|
): any => {
|
|
|
|
|
if (parentEntityId) {
|
|
|
|
|
return createNewAPIBasedOnParentEntity(
|
|
|
|
|
parentEntityId,
|
|
|
|
|
"API_PANE",
|
|
|
|
|
apiType,
|
|
|
|
|
parentEntityType,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|