refactor(command-menu-item): rename Actions to CommandMenuItem (#18489)

actions are being renamed to command menu item, they will be migrated to
server and will be served as headless front components

---------

Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com>
This commit is contained in:
nitin
2026-03-09 19:33:12 +05:30
committed by GitHub
parent 06bdb5ad6a
commit 36bcc71f3d
275 changed files with 4544 additions and 4436 deletions
@@ -0,0 +1,9 @@
import { getCommandMenuDropdownIdFromCommandMenuId } from '@/command-menu-item/utils/getCommandMenuDropdownIdFromCommandMenuId';
describe('getCommandMenuDropdownIdFromCommandMenuId', () => {
it('should return the correct action menu dropdown id', () => {
expect(getCommandMenuDropdownIdFromCommandMenuId('command-menu-id')).toBe(
'command-menu-dropdown-command-menu-id',
);
});
});
@@ -0,0 +1,9 @@
import { getCommandMenuIdFromRecordIndexId } from '@/command-menu-item/utils/getCommandMenuIdFromRecordIndexId';
describe('getCommandMenuIdFromRecordIndexId', () => {
it('should return the correct action menu id', () => {
expect(getCommandMenuIdFromRecordIndexId('record-index-id')).toBe(
'command-menu-record-index-record-index-id',
);
});
});
@@ -0,0 +1,9 @@
import { getSidePanelCommandMenuDropdownIdFromCommandMenuId } from '@/command-menu-item/utils/getSidePanelCommandMenuDropdownIdFromCommandMenuId';
describe('getSidePanelCommandMenuDropdownIdFromCommandMenuId', () => {
it('should return the side panel action menu dropdown id', () => {
expect(
getSidePanelCommandMenuDropdownIdFromCommandMenuId('command-menu-id'),
).toBe('side-panel-command-menu-dropdown-command-menu-id');
});
});
@@ -0,0 +1,28 @@
import { isDefined } from 'twenty-shared/utils';
import { type ObjectRecordQueryProgress } from '@/object-record/types/ObjectRecordQueryProgress';
export const computeProgressText = (
progress?: ObjectRecordQueryProgress,
): string => {
if (
!isDefined(progress) ||
!isDefined(progress.processedRecordCount) ||
progress.processedRecordCount === 0
) {
return '';
}
if (isDefined(progress.totalRecordCount)) {
const percentage =
progress.totalRecordCount > 0
? Math.round(
(progress.processedRecordCount / progress.totalRecordCount) * 100,
)
: 0;
return ` (${percentage}%)`;
}
return ` (${progress.processedRecordCount})`;
};
@@ -0,0 +1,5 @@
export const getCommandMenuDropdownIdFromCommandMenuId = (
commandMenuId: string,
) => {
return `command-menu-dropdown-${commandMenuId}`;
};
@@ -0,0 +1,3 @@
export const getCommandMenuIdFromRecordIndexId = (recordIndexId: string) => {
return `command-menu-record-index-${recordIndexId}`;
};
@@ -0,0 +1,44 @@
import { DASHBOARD_COMMAND_MENU_ITEMS_CONFIG } from '@/command-menu-item/record/constants/DashboardCommandMenuItemsConfig';
import { DEFAULT_RECORD_COMMAND_MENU_ITEMS_CONFIG } from '@/command-menu-item/record/constants/DefaultRecordCommandMenuItemsConfig';
import { WORKFLOW_COMMAND_MENU_ITEMS_CONFIG } from '@/command-menu-item/record/constants/WorkflowCommandMenuItemsConfig';
import { WORKFLOW_RUNS_COMMAND_MENU_ITEMS_CONFIG } from '@/command-menu-item/record/constants/WorkflowRunsCommandMenuItemsConfig';
import { WORKFLOW_VERSIONS_COMMAND_MENU_ITEMS_CONFIG } from '@/command-menu-item/record/constants/WorkflowVersionsCommandMenuItemsConfig';
import { WORKSPACE_MEMBERS_COMMAND_MENU_ITEMS_CONFIG } from '@/command-menu-item/record/constants/WorkspaceMembersCommandMenuItemsConfig';
import { type CommandMenuItemConfig } from '@/command-menu-item/types/CommandMenuItemConfig';
import { CoreObjectNameSingular } from 'twenty-shared/types';
import { type ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
import { isDefined } from 'twenty-shared/utils';
export const getCommandMenuItemConfig = ({
objectMetadataItem,
}: {
objectMetadataItem?: ObjectMetadataItem;
}): Record<string, CommandMenuItemConfig> => {
if (!isDefined(objectMetadataItem)) {
return {};
}
switch (objectMetadataItem.nameSingular) {
case CoreObjectNameSingular.Dashboard: {
return DASHBOARD_COMMAND_MENU_ITEMS_CONFIG;
}
case CoreObjectNameSingular.Workflow: {
return WORKFLOW_COMMAND_MENU_ITEMS_CONFIG;
}
case CoreObjectNameSingular.WorkflowVersion: {
return WORKFLOW_VERSIONS_COMMAND_MENU_ITEMS_CONFIG;
}
case CoreObjectNameSingular.WorkflowRun: {
return WORKFLOW_RUNS_COMMAND_MENU_ITEMS_CONFIG;
}
case CoreObjectNameSingular.WorkspaceMember: {
return WORKSPACE_MEMBERS_COMMAND_MENU_ITEMS_CONFIG;
}
case CoreObjectNameSingular.Company: {
return DEFAULT_RECORD_COMMAND_MENU_ITEMS_CONFIG;
}
default: {
return DEFAULT_RECORD_COMMAND_MENU_ITEMS_CONFIG;
}
}
};
@@ -0,0 +1,8 @@
import { i18n, type MessageDescriptor } from '@lingui/core';
import { isString } from '@sniptt/guards';
export const getCommandMenuItemLabel = (
label: string | MessageDescriptor,
): string => {
return isString(label) ? label : i18n._(label);
};
@@ -0,0 +1,32 @@
import { CommandMenuItemViewType } from 'twenty-shared/types';
import { type ContextStoreTargetedRecordsRule } from '@/context-store/states/contextStoreTargetedRecordsRuleComponentState';
import { ContextStoreViewType } from '@/context-store/types/ContextStoreViewType';
export const getCommandMenuItemViewType = (
contextStoreCurrentViewType: ContextStoreViewType | null,
contextStoreTargetedRecordsRule: ContextStoreTargetedRecordsRule,
) => {
if (contextStoreCurrentViewType === null) {
return null;
}
if (contextStoreCurrentViewType === ContextStoreViewType.ShowPage) {
return CommandMenuItemViewType.SHOW_PAGE;
}
if (
contextStoreTargetedRecordsRule.mode === 'selection' &&
contextStoreTargetedRecordsRule.selectedRecordIds.length === 0
) {
return CommandMenuItemViewType.INDEX_PAGE_NO_SELECTION;
}
if (
contextStoreTargetedRecordsRule.mode === 'selection' &&
contextStoreTargetedRecordsRule.selectedRecordIds.length === 1
) {
return CommandMenuItemViewType.INDEX_PAGE_SINGLE_RECORD_SELECTION;
}
return CommandMenuItemViewType.INDEX_PAGE_BULK_SELECTION;
};
@@ -0,0 +1,5 @@
export const getSidePanelCommandMenuDropdownIdFromCommandMenuId = (
commandMenuId: string,
) => {
return `side-panel-command-menu-dropdown-${commandMenuId}`;
};