In order to unify package names, we decided to use `@appsmith` prefix as a marker to indicate that packages belong to our codebase and that these packages are developed internally. So that we can use this prefix, we need to rename the alias of the same name. But since `@appsmith` is currently being used as an alias for `ee` folder, we have to rename the alias as the first step. Related discussion https://theappsmith.slack.com/archives/CPG2ZTXEY/p1722516279126329 EE PR — https://github.com/appsmithorg/appsmith-ee/pull/4801 ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10267368821> > Commit: 2b00af2d257e4d4304db0a80072afef7513de6be > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10267368821&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Tue, 06 Aug 2024 14:24:22 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No
108 lines
3.3 KiB
TypeScript
108 lines
3.3 KiB
TypeScript
import type { Action } from "entities/Action";
|
|
import { ActionExecutionContext } from "entities/Action";
|
|
import type { JSAction, JSCollection } from "entities/JSCollection";
|
|
import type { ApplicationPayload } from "ee/constants/ReduxActionConstants";
|
|
import store from "store";
|
|
import { getAppMode } from "ee/selectors/applicationSelectors";
|
|
import { getDatasource } from "ee/selectors/entitiesSelector";
|
|
import { getCurrentEnvironmentDetails } from "ee/selectors/environmentSelectors";
|
|
import type { Plugin } from "api/PluginApi";
|
|
import { get, isNil } from "lodash";
|
|
import type { JSCollectionData } from "ee/reducers/entityReducers/jsActionsReducer";
|
|
|
|
export function getPluginActionNameToDisplay(action: Action) {
|
|
return action.name;
|
|
}
|
|
|
|
export const getActionProperties = (
|
|
action: Action,
|
|
keyConfig: Record<string, string>,
|
|
) => {
|
|
const actionProperties: Record<string, unknown> = {};
|
|
Object.keys(keyConfig).forEach((key) => {
|
|
const value = get(action, key);
|
|
if (!isNil(value)) {
|
|
actionProperties[keyConfig[key]] = get(action, key);
|
|
}
|
|
});
|
|
return actionProperties;
|
|
};
|
|
|
|
export function getJSActionPathNameToDisplay(
|
|
action: JSAction,
|
|
collection: JSCollection,
|
|
) {
|
|
return collection.name + "." + action.name;
|
|
}
|
|
|
|
export function getJSActionNameToDisplay(action: JSAction) {
|
|
return action.name;
|
|
}
|
|
|
|
export function getCollectionNameToDisplay(
|
|
_: JSAction,
|
|
collectionName: string,
|
|
) {
|
|
return collectionName;
|
|
}
|
|
|
|
export function getActionExecutionAnalytics(
|
|
action: Action,
|
|
plugin: Plugin,
|
|
params: Record<string, unknown>,
|
|
currentApp: ApplicationPayload,
|
|
datasourceId: string,
|
|
) {
|
|
let appMode;
|
|
const state = store.getState();
|
|
const datasource = getDatasource(state, datasourceId);
|
|
const currentEnvDetails = getCurrentEnvironmentDetails(state);
|
|
const resultObj = {
|
|
type: action?.pluginType,
|
|
name: action?.name,
|
|
environmentId: currentEnvDetails.id,
|
|
environmentName: currentEnvDetails.name,
|
|
pluginName: plugin?.name,
|
|
datasourceId: datasourceId,
|
|
isMock: !!datasource?.isMock,
|
|
actionId: action?.id,
|
|
inputParams: Object.keys(params).length,
|
|
source: ActionExecutionContext.EVALUATION_ACTION_TRIGGER, // Used in analytic events to understand who triggered action execution
|
|
};
|
|
|
|
if (!!currentApp) {
|
|
appMode = getAppMode(state);
|
|
return {
|
|
...resultObj,
|
|
isExampleApp: currentApp.appIsExample,
|
|
pageId: action?.pageId,
|
|
appId: currentApp.id,
|
|
appMode: appMode,
|
|
appName: currentApp.name,
|
|
};
|
|
}
|
|
|
|
return resultObj;
|
|
}
|
|
|
|
/**
|
|
* Function to check if the browser execution is allowed for the action
|
|
* This is just for code splitting, main feature is in EE
|
|
* */
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
export function isBrowserExecutionAllowed(..._args: any[]) {
|
|
return true;
|
|
}
|
|
|
|
// Function to extract the test payload from the collection data
|
|
export const getTestPayloadFromCollectionData = (
|
|
collectionData: JSCollectionData | undefined,
|
|
): string => {
|
|
if (!collectionData) return "";
|
|
const activeJSActionId = collectionData?.activeJSActionId;
|
|
const testPayload: Record<string, unknown> | undefined = collectionData?.data
|
|
?.testPayload as Record<string, unknown>;
|
|
if (!activeJSActionId || !testPayload) return "";
|
|
return (testPayload[activeJSActionId] as string) || "";
|
|
};
|