Refactor command menu items deprecated code (#19508)
- Removes the intermediate `CommandMenuItemConfig` / `CommandConfigContext` / `CommandMenuItemDisplay` abstraction layers, replacing them with a single `CommandMenuItemRenderer` that renders directly from the command menu items from the backend - Eliminates the server-items/ subdirectory by moving its contents (hooks/, contexts/, states/, display/, edit/) up into the parent command-menu-item/ module, removing an unnecessary nesting level.
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { getCommandMenuDropdownIdFromCommandMenuId } from '@/command-menu-item/utils/getCommandMenuDropdownIdFromCommandMenuId';
|
||||
|
||||
describe('getCommandMenuDropdownIdFromCommandMenuId', () => {
|
||||
it('should return the correct action menu dropdown id', () => {
|
||||
it('should return the correct command menu dropdown id', () => {
|
||||
expect(getCommandMenuDropdownIdFromCommandMenuId('command-menu-id')).toBe(
|
||||
'command-menu-dropdown-command-menu-id',
|
||||
);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { getCommandMenuIdFromRecordIndexId } from '@/command-menu-item/utils/getCommandMenuIdFromRecordIndexId';
|
||||
|
||||
describe('getCommandMenuIdFromRecordIndexId', () => {
|
||||
it('should return the correct action menu id', () => {
|
||||
it('should return the correct command menu id', () => {
|
||||
expect(getCommandMenuIdFromRecordIndexId('record-index-id')).toBe(
|
||||
'command-menu-record-index-record-index-id',
|
||||
);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { getSidePanelCommandMenuDropdownIdFromCommandMenuId } from '@/command-menu-item/utils/getSidePanelCommandMenuDropdownIdFromCommandMenuId';
|
||||
|
||||
describe('getSidePanelCommandMenuDropdownIdFromCommandMenuId', () => {
|
||||
it('should return the side panel action menu dropdown id', () => {
|
||||
it('should return the side panel command menu dropdown id', () => {
|
||||
expect(
|
||||
getSidePanelCommandMenuDropdownIdFromCommandMenuId('command-menu-id'),
|
||||
).toBe('side-panel-command-menu-dropdown-command-menu-id');
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { type CommandMenuItemFieldsFragment } from '~/generated-metadata/graphql';
|
||||
|
||||
export const doesCommandMenuItemMatchObjectMetadataId =
|
||||
(objectMetadataItemId: unknown) => (item: CommandMenuItemFieldsFragment) =>
|
||||
!isDefined(item.availabilityObjectMetadataId) ||
|
||||
item.availabilityObjectMetadataId === objectMetadataItemId;
|
||||
@@ -0,0 +1,18 @@
|
||||
import { type CommandMenuItemFieldsFragment } from '~/generated-metadata/graphql';
|
||||
|
||||
export const groupCommandMenuItems = (
|
||||
items: CommandMenuItemFieldsFragment[],
|
||||
) => {
|
||||
const pinned: CommandMenuItemFieldsFragment[] = [];
|
||||
const other: CommandMenuItemFieldsFragment[] = [];
|
||||
|
||||
for (const item of items) {
|
||||
if (item.isPinned) {
|
||||
pinned.push(item);
|
||||
} else {
|
||||
other.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
return { pinned, other };
|
||||
};
|
||||
Reference in New Issue
Block a user