[COMMAND MENU ITEMS] Add dynamic label and icon to command menu navigation items (#19452)

This commit is contained in:
Raphaël Bosi
2026-04-09 14:00:49 +02:00
committed by GitHub
parent 9b8cb610c3
commit 19f11b1216
14 changed files with 847 additions and 20 deletions
@@ -15,10 +15,14 @@ import { addPayloadCheckConstraintToCommandMenuItem } from 'src/database/typeorm
import { ApplicationService } from 'src/engine/core-modules/application/application.service';
import { RegisteredWorkspaceCommand } from 'src/engine/core-modules/upgrade/decorators/registered-workspace-command.decorator';
import { EngineComponentKey } from 'src/engine/metadata-modules/command-menu-item/enums/engine-component-key.enum';
import { isObjectMetadataCommandMenuItemPayload } from 'src/engine/metadata-modules/command-menu-item/utils/is-object-metadata-command-menu-item-payload.util';
import { type FlatCommandMenuItem } from 'src/engine/metadata-modules/flat-command-menu-item/types/flat-command-menu-item.type';
import {
buildNavigationFlatCommandMenuItem,
NAVIGATION_COMMAND_UUID_NAMESPACE,
NAVIGATION_INTERPOLATED_ICON,
NAVIGATION_INTERPOLATED_LABEL,
NAVIGATION_INTERPOLATED_SHORT_LABEL,
} from 'src/engine/metadata-modules/flat-command-menu-item/utils/build-navigation-flat-command-menu-item.util';
import { seedCompareObjectMetadataForNavigationPosition } from 'src/engine/metadata-modules/flat-command-menu-item/utils/seed-compare-object-metadata-for-navigation-position.util';
import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
@@ -239,19 +243,38 @@ export class RefactorNavigationCommandsCommand extends ActiveOrSuspendedWorkspac
});
}
const staleNavigationItemsToUpdate = allCommandMenuItems
.filter(
(item) =>
item.engineComponentKey === EngineComponentKey.NAVIGATION &&
isObjectMetadataCommandMenuItemPayload(item.payload) &&
(item.label !== NAVIGATION_INTERPOLATED_LABEL ||
item.shortLabel !== NAVIGATION_INTERPOLATED_SHORT_LABEL ||
item.icon !== NAVIGATION_INTERPOLATED_ICON),
)
.map((item) => ({
...item,
label: NAVIGATION_INTERPOLATED_LABEL,
shortLabel: NAVIGATION_INTERPOLATED_SHORT_LABEL,
icon: NAVIGATION_INTERPOLATED_ICON,
updatedAt: now,
}));
if (
goToItemsToDelete.length === 0 &&
flatCommandMenuItemsToCreate.length === 0
flatCommandMenuItemsToCreate.length === 0 &&
staleNavigationItemsToUpdate.length === 0
) {
this.logger.log(
`All NAVIGATION commands already exist for workspace ${workspaceId}, skipping`,
`All NAVIGATION commands already exist and use interpolation for workspace ${workspaceId}, skipping`,
);
return;
}
this.logger.log(
`${isDryRun ? '[DRY RUN] Would create' : 'Creating'} ${flatCommandMenuItemsToCreate.length} NAVIGATION command(s) for workspace ${workspaceId}`,
`${isDryRun ? '[DRY RUN] Would create' : 'Creating'} ${flatCommandMenuItemsToCreate.length} NAVIGATION command(s) ` +
`and update ${staleNavigationItemsToUpdate.length} stale item(s) for workspace ${workspaceId}`,
);
if (isDryRun) {
@@ -265,7 +288,7 @@ export class RefactorNavigationCommandsCommand extends ActiveOrSuspendedWorkspac
commandMenuItem: {
flatEntityToCreate: flatCommandMenuItemsToCreate,
flatEntityToDelete: goToItemsToDelete,
flatEntityToUpdate: [],
flatEntityToUpdate: staleNavigationItemsToUpdate,
},
},
workspaceId,