Skip to content

Commit

Permalink
type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitakinger committed Jan 23, 2025
1 parent 0115c6a commit afdd229
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import { MODULE_TYPE } from "ee/constants/ModuleConstants";
import ConvertToModuleInstanceCTA from "ee/pages/Editor/EntityEditor/ConvertToModuleInstanceCTA";
import { PluginType } from "entities/Plugin";
import type { Action } from "entities/Action";
import type { JSCollection } from "entities/JSCollection";

interface Props {
action: Action | JSCollection;
action: Action;
}

export const ConvertToModule = ({ action }: Props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ export function AppJSContextMenuItems(props: Props) {

const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);

const canDeleteAction = getHasDeleteActionPermission(
const canDeleteJSAction = getHasDeleteActionPermission(
isFeatureEnabled,
jsActionPermissions,
);

const canManageAction = getHasManageActionPermission(
const canManageJSAction = getHasManageActionPermission(
isFeatureEnabled,
jsActionPermissions,
);

return (
<>
<Rename disabled={!canManageAction} jsAction={jsAction} />
<Rename disabled={!canManageJSAction} jsAction={jsAction} />
<ShowBindings jsAction={jsAction} />
<ConvertToModule action={jsAction} />
<Copy disabled={!canManageAction} jsAction={jsAction} />
<Move disabled={!canManageAction} jsAction={jsAction} />
<ConvertToModule jsAction={jsAction} />
<Copy disabled={!canManageJSAction} jsAction={jsAction} />
<Move disabled={!canManageJSAction} jsAction={jsAction} />
<MenuSeparator />
<Delete disabled={!canDeleteAction} jsAction={jsAction} />
<Delete disabled={!canDeleteJSAction} jsAction={jsAction} />
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import {
} from "ee/utils/BusinessFeatures/permissionPageHelpers";
import { MODULE_TYPE } from "ee/constants/ModuleConstants";
import ConvertToModuleInstanceCTA from "ee/pages/Editor/EntityEditor/ConvertToModuleInstanceCTA";
import { PluginType } from "entities/Plugin";
import type { Action } from "entities/Action";
import type { JSCollection } from "entities/JSCollection";

interface Props {
action: Action | JSCollection;
jsAction: JSCollection;
}

export const ConvertToModule = ({ action }: Props) => {
export const ConvertToModule = ({ jsAction }: Props) => {
const pagePermissions = useSelector(getPagePermissions);
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);

Expand All @@ -26,21 +24,16 @@ export const ConvertToModule = ({ action }: Props) => {
pagePermissions,
);

const canDeleteAction = getHasDeleteActionPermission(
const canDeleteJSAction = getHasDeleteActionPermission(
isFeatureEnabled,
action.userPermissions,
jsAction.userPermissions,
);

if (action.pluginType === PluginType.INTERNAL) {
// Workflow queries cannot be converted to modules
return null;
}

const convertToModuleProps = {
canCreateModuleInstance: canCreateModuleInstance,
canDeleteEntity: canDeleteAction,
entityId: action.id,
moduleType: MODULE_TYPE.QUERY,
canDeleteEntity: canDeleteJSAction,
entityId: jsAction.id,
moduleType: MODULE_TYPE.JS,
};

return <ConvertToModuleInstanceCTA {...convertToModuleProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Move = ({ disabled, jsAction }: Props) => {
return allPages.filter((page) => page.pageId !== currentPageId);
}, [allPages, currentPageId]);

const moveActionToPage = useCallback(
const moveJSActionToPage = useCallback(
(destinationPageId: string) =>
dispatch(
moveJSCollectionRequest({
Expand All @@ -51,7 +51,7 @@ export const Move = ({ disabled, jsAction }: Props) => {
<PageMenuItem
disabled={disabled}
key={page.basePageId}
onSelect={moveActionToPage}
onSelect={moveJSActionToPage}
page={page}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ShowBindings = ({ disabled, jsAction }: Props) => {
payload: {
entityId: jsAction.id,
entityName: jsAction.name,
entityType: ENTITY_TYPE.ACTION,
entityType: ENTITY_TYPE.JSACTION,
show: true,
},
});
Expand Down

0 comments on commit afdd229

Please sign in to comment.