Skip to content

Commit dd193a9

Browse files
committed
make WpSingleContextMenu filter out numeric ID option instead of hiding it
1 parent 5849286 commit dd193a9

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ export class WorkPackageSingleContextMenuDirective extends OpContextMenuTrigger
158158

159159
// Copying the numeric ID is only useful in semantic mode, where the
160160
// displayed identifier (e.g. "PROJ-42") is not the numeric ID itself.
161-
const copyIdAction = actions.find((action) => action.key === 'copy_numeric_id_to_clipboard');
162-
if (copyIdAction) {
163-
copyIdAction.hidden = !isSemanticWorkPackageId(this.workPackage.displayId);
164-
}
161+
actions = actions.filter((action) => (
162+
action.key !== 'copy_numeric_id_to_clipboard'
163+
|| isSemanticWorkPackageId(this.workPackage.displayId)
164+
));
165165

166166
// Splice plugin actions onto the core actions
167167
_.each(this.getPermittedPluginActions(authorization), (action:WorkPackageAction) => {

frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
2828
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
2929
import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';
3030
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
31+
import { isSemanticWorkPackageId } from 'core-app/shared/helpers/work-package-id-pattern';
3132

3233
import { Placement } from '@floating-ui/dom';
3334

@@ -123,6 +124,10 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {
123124
this.copyToClipboardService.copy(url.toString());
124125
break;
125126
}
127+
case 'copy_numeric_id_to_clipboard':
128+
this.copyToClipboardService.copy(`${id}`);
129+
break;
130+
126131
case 'copy_to_other_project':
127132
window.location.href = `${this.pathHelper.staticBase}/work_packages/move/new?copy=true&ids[]=${id}`;
128133
break;
@@ -212,7 +217,15 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {
212217

213218
protected buildItems():OpContextMenuItem[] {
214219
const selected = this.getSelectedWorkPackages();
215-
const items = this.permittedActions.map((action:WorkPackageAction) => ({
220+
221+
// Copying the numeric ID is only useful in semantic mode, where the
222+
// displayed identifier (e.g. "PROJ-42") is not the numeric ID itself.
223+
const visibleActions = this.permittedActions.filter((action) => (
224+
action.key !== 'copy_numeric_id_to_clipboard'
225+
|| isSemanticWorkPackageId(this.workPackage.displayId)
226+
));
227+
228+
const items = visibleActions.map((action:WorkPackageAction) => ({
216229
class: undefined as string | undefined,
217230
disabled: false,
218231
linkText: action.text,

0 commit comments

Comments
 (0)