Skip to content

The open alternative to Salesforce, designed for AI.

Remove the See Version command menu item from workflow runs (#27063)

Thomas Trompette4d8e0fc59fdd
diff --git a/packages/twenty-front/src/testing/mock-data/generated/metadata/command-menu-items/mock-command-menu-items-data.ts b/packages/twenty-front/src/testing/mock-data/generated/metadata/command-menu-items/mock-command-menu-items-data.ts
index b9b6073720f..5d797fba773 100644
--- a/packages/twenty-front/src/testing/mock-data/generated/metadata/command-menu-items/mock-command-menu-items-data.ts
+++ b/packages/twenty-front/src/testing/mock-data/generated/metadata/command-menu-items/mock-command-menu-items-data.ts
@@ -667,28 +667,6 @@ export const mockedCommandMenuItems: CommandMenuItemFieldsFragment[] =
"shortLabel": "Duplicate",
"navigationTargetObjectMetadataId": null
},
- {
- "__typename": "CommandMenuItem",
- "id": "7501575b-0af1-4e35-9091-639969d3abc9",
- "applicationId": "0be210aa-685b-4c31-9a2a-010b44eacaf5",
- "workflowVersionId": null,
- "frontComponentId": null,
- "engineComponentKey": "SEE_VERSION_WORKFLOW_RUN",
- "position": 33,
- "isPinned": true,
- "payload": null,
- "hotKeys": null,
- "conditionalAvailabilityExpression": null,
- "availabilityType": "RECORD_SELECTION",
- "availabilityObjectMetadataId": "dccf06e5-31d9-43fc-9612-30517caadf5f",
- "pageLayoutId": null,
- "isActive": true,
- "frontComponent": null,
- "label": "See Version",
- "icon": "IconVersions",
- "shortLabel": "See Version",
- "navigationTargetObjectMetadataId": null
- },
{
"__typename": "CommandMenuItem",
"id": "5ba655ec-8787-45c2-9a8e-f6e34b8ff79d",
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-45/2-45-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-45/2-45-upgrade-version-command.module.ts
index c2b205d1218..80f3158e66f 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-45/2-45-upgrade-version-command.module.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-45/2-45-upgrade-version-command.module.ts
@@ -3,6 +3,7 @@ import { Module } from '@nestjs/common';
import { WorkspaceIteratorModule } from 'src/database/commands/command-runners/workspace-iterator.module';
import { RestrictExportRecordsToIndexPageCommand } from 'src/database/commands/upgrade-version-command/2-45/2-45-workspace-command-1790837443029-restrict-export-records-to-index-page.command';
import { GateWorkflowCommandsOnRecordUpdatePermissionCommand } from 'src/database/commands/upgrade-version-command/2-45/2-45-workspace-command-1790853316722-gate-workflow-commands-on-record-update-permission.command';
+import { RemoveSeeVersionWorkflowRunCommandMenuItemCommand } from 'src/database/commands/upgrade-version-command/2-45/2-45-workspace-command-1790860694324-remove-see-version-workflow-run-command-menu-item.command';
import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';
import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace-migration/workspace-migration.module';
@@ -15,6 +16,7 @@ import { WorkspaceMigrationModule } from 'src/engine/workspace-manager/workspace
providers: [
RestrictExportRecordsToIndexPageCommand,
GateWorkflowCommandsOnRecordUpdatePermissionCommand,
+ RemoveSeeVersionWorkflowRunCommandMenuItemCommand,
],
})
export class V2_45_UpgradeVersionCommandModule {}
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-45/2-45-workspace-command-1790860694324-remove-see-version-workflow-run-command-menu-item.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-45/2-45-workspace-command-1790860694324-remove-see-version-workflow-run-command-menu-item.command.ts
new file mode 100644
index 00000000000..30c100b1d31
--- /dev/null
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-45/2-45-workspace-command-1790860694324-remove-see-version-workflow-run-command-menu-item.command.ts
@@ -0,0 +1,83 @@
+import { Command } from 'nest-commander';
+import { TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER } from 'twenty-shared/application';
+import { isDefined } from 'twenty-shared/utils';
+
+import { ProvisionedWorkspaceCommandRunner } from 'src/database/commands/command-runners/provisioned-workspace.command-runner';
+import { WorkspaceIteratorService } from 'src/database/commands/command-runners/workspace-iterator.service';
+import { type RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspace.command-runner';
+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 { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
+import { WorkspaceMigrationBuilderException } from 'src/engine/workspace-manager/workspace-migration/exceptions/workspace-migration-builder-exception';
+import { WorkspaceMigrationValidateBuildAndRunService } from 'src/engine/workspace-manager/workspace-migration/services/workspace-migration-validate-build-and-run-service';
+
+const SEE_VERSION_WORKFLOW_RUN_UNIVERSAL_IDENTIFIER =
+ 'cc3a065c-c89e-40ac-9449-4272c55b1bb8';
+
+@RegisteredWorkspaceCommand('2.45.0', 1790860694324)
+@Command({
+ name: 'upgrade:2-45:remove-see-version-workflow-run-command-menu-item',
+ description:
+ 'Remove the See Version workflow run command menu item from existing workspaces',
+})
+export class RemoveSeeVersionWorkflowRunCommandMenuItemCommand extends ProvisionedWorkspaceCommandRunner {
+ constructor(
+ protected readonly workspaceIteratorService: WorkspaceIteratorService,
+ private readonly workspaceCacheService: WorkspaceCacheService,
+ private readonly workspaceMigrationValidateBuildAndRunService: WorkspaceMigrationValidateBuildAndRunService,
+ ) {
+ super(workspaceIteratorService);
+ }
+
+ override async runOnWorkspace({
+ workspaceId,
+ options,
+ }: RunOnWorkspaceArgs): Promise<void> {
+ const { flatCommandMenuItemMaps } =
+ await this.workspaceCacheService.getOrRecompute(workspaceId, [
+ 'flatCommandMenuItemMaps',
+ ]);
+
+ const seeVersionWorkflowRun =
+ flatCommandMenuItemMaps.byUniversalIdentifier[
+ SEE_VERSION_WORKFLOW_RUN_UNIVERSAL_IDENTIFIER
+ ];
+
+ if (
+ !isDefined(seeVersionWorkflowRun) ||
+ seeVersionWorkflowRun.engineComponentKey !==
+ EngineComponentKey.SEE_VERSION_WORKFLOW_RUN
+ ) {
+ return;
+ }
+
+ this.logger.log(
+ `${options.dryRun ? '[DRY RUN] ' : ''}Workspace ${workspaceId}: removing the See Version workflow run command menu item`,
+ );
+
+ if (options.dryRun) {
+ return;
+ }
+
+ const result =
+ await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunLegacyWorkspaceMigration(
+ {
+ workspaceId,
+ isSystemBuild: true,
+ applicationUniversalIdentifier:
+ TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER,
+ allFlatEntityOperationByMetadataName: {
+ commandMenuItem: {
+ flatEntityToCreate: [],
+ flatEntityToDelete: [seeVersionWorkflowRun],
+ flatEntityToUpdate: [],
+ },
+ },
+ },
+ );
+
+ if (result.status === 'fail') {
+ throw new WorkspaceMigrationBuilderException(result);
+ }
+ }
+}
diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant.ts
index c6a4d6471d6..219f62a0496 100644
--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant.ts
+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/constants/standard-command-menu-item.constant.ts
@@ -678,25 +678,6 @@ export const STANDARD_COMMAND_MENU_ITEMS = {
engineComponentKey: EngineComponentKey.TOGGLE_WORKFLOW_VISIBILITY,
hotKeys: null,
},
- seeVersionWorkflowRun: {
- universalIdentifier: 'cc3a065c-c89e-40ac-9449-4272c55b1bb8',
- label: i18nLabel(
- msg({ message: `See Version`, context: 'commandMenuItem.label' }),
- ),
- icon: 'IconVersions',
- isPinned: true,
- position: 33,
- shortLabel: i18nLabel(
- msg({ message: `See Version`, context: 'commandMenuItem.shortLabel' }),
- ),
- availabilityType: CommandMenuItemAvailabilityType.RECORD_SELECTION,
- conditionalAvailabilityExpression: null,
- availabilityObjectMetadataUniversalIdentifier:
- STANDARD_OBJECTS.workflowRun.universalIdentifier,
- frontComponentUniversalIdentifier: null,
- engineComponentKey: EngineComponentKey.SEE_VERSION_WORKFLOW_RUN,
- hotKeys: null,
- },
seeWorkflowWorkflowRun: {
universalIdentifier: '9d9cc62d-3543-45c3-93f3-23d2d8979f2b',
label: i18nLabel(