2024-08-06 14:52:22 +00:00
|
|
|
import type { EventLocation } from "ee/utils/analyticsUtilTypes";
|
2023-12-13 17:43:43 +00:00
|
|
|
import {
|
|
|
|
|
createNewApiAction,
|
|
|
|
|
createNewQueryAction,
|
|
|
|
|
} from "actions/apiPaneActions";
|
|
|
|
|
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";
|
2023-12-21 04:52:54 +00:00
|
|
|
import { saveActionName } from "actions/pluginActionActions";
|
|
|
|
|
import { saveJSObjectName } from "actions/jsActionActions";
|
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
|
|
|
|
|
|
|
|
export const saveActionNameBasedOnParentEntity = (
|
|
|
|
|
id: string,
|
|
|
|
|
name: 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-21 04:52:54 +00:00
|
|
|
) => {
|
|
|
|
|
return saveActionName({ id, name });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const saveJSObjectNameBasedOnParentEntity = (
|
|
|
|
|
id: string,
|
|
|
|
|
name: 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-21 04:52:54 +00:00
|
|
|
) => {
|
|
|
|
|
return saveJSObjectName({ id, name });
|
|
|
|
|
};
|
2023-12-26 06:08:00 +00:00
|
|
|
|
|
|
|
|
export const createNewApiActionBasedOnEditorType = (
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
|
editorType: string,
|
|
|
|
|
// 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,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|