Skip to content

Commit b47ce00

Browse files
claudekittyyueli
authored andcommitted
fix(apollo-react): hide task kebab menu in readonly mode [MST-8297]
Gate the task context menu (kebab menu) on both regular and adhoc tasks behind the isReadOnly flag, preventing task deletion in readonly/debug mode. https://claude.ai/code/session_01D3AjfzFVHi7iNwFCJvmgYf
1 parent f8a98fc commit b47ce00

3 files changed

Lines changed: 59 additions & 7 deletions

File tree

packages/apollo-react/src/canvas/components/StageNode/StageNode.stories.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,20 @@ const AddAndReplaceTasksStory = () => {
10611061
data: {
10621062
stageDetails: {
10631063
label: 'Add, Replace, and Group Tasks',
1064+
isReadOnly: false,
1065+
tasks: initialTasksForAddReplace,
1066+
},
1067+
taskOptions: availableTaskOptions,
1068+
},
1069+
},
1070+
{
1071+
id: 'readonly-stage',
1072+
type: 'stage',
1073+
position: { x: 720, y: 96 },
1074+
data: {
1075+
stageDetails: {
1076+
label: 'ReadOnly Stage',
1077+
isReadOnly: true,
10641078
tasks: initialTasksForAddReplace,
10651079
},
10661080
taskOptions: availableTaskOptions,

packages/apollo-react/src/canvas/components/StageNode/StageNode.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,42 @@ describe('StageNode - hideParallelOptions', () => {
847847
});
848848
});
849849

850+
describe('StageNode - ReadOnly Mode', () => {
851+
beforeEach(() => {
852+
vi.clearAllMocks();
853+
});
854+
855+
it('should not render task kebab menu when isReadOnly is true', () => {
856+
const onTaskGroupModification = vi.fn();
857+
const tasks: StageTaskItem[][] = [
858+
[createTask('task-1', 'Task 1')],
859+
[createTask('task-2', 'Task 2')],
860+
];
861+
862+
renderStageNode({
863+
onTaskGroupModification,
864+
stageDetails: { ...defaultProps.stageDetails, tasks, isReadOnly: true },
865+
});
866+
867+
expect(screen.queryByTestId('task-menu-button-task-1')).not.toBeInTheDocument();
868+
expect(screen.queryByTestId('task-menu-button-task-2')).not.toBeInTheDocument();
869+
});
870+
871+
it('should not render adhoc task kebab menu when isReadOnly is true', () => {
872+
const onTaskGroupModification = vi.fn();
873+
const adhocTask = createTask('adhoc-1', 'Adhoc Task 1');
874+
adhocTask.isAdhoc = true;
875+
const tasks: StageTaskItem[][] = [[adhocTask]];
876+
877+
renderStageNode({
878+
onTaskGroupModification,
879+
stageDetails: { ...defaultProps.stageDetails, tasks, isReadOnly: true },
880+
});
881+
882+
expect(screen.queryByTestId('task-menu-button-adhoc-1')).not.toBeInTheDocument();
883+
});
884+
});
885+
850886
describe('StageNode - Header Chips', () => {
851887
beforeEach(() => {
852888
vi.clearAllMocks();

packages/apollo-react/src/canvas/components/StageNode/StageNode.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,10 @@ const StageNodeInner = (props: StageNodeProps) => {
758758
: undefined
759759
}
760760
isDragDisabled={!onTaskReorder}
761-
{...(hasContextMenu && {
762-
getContextMenuItems: buildContextMenuItems,
763-
})}
761+
{...(hasContextMenu &&
762+
!isReadOnly && {
763+
getContextMenuItems: buildContextMenuItems,
764+
})}
764765
/>
765766
);
766767
})}
@@ -800,10 +801,11 @@ const StageNodeInner = (props: StageNodeProps) => {
800801
isSelected={selectedTaskId === task.id}
801802
onTaskClick={handleTaskClick}
802803
onTaskPlay={onTaskPlay}
803-
{...((onTaskGroupModification || onReplaceTaskFromToolbox) && {
804-
getContextMenuItems: () =>
805-
getAdhocContextMenuItems(groupIndex, taskIndex, task.id),
806-
})}
804+
{...((onTaskGroupModification || onReplaceTaskFromToolbox) &&
805+
!isReadOnly && {
806+
getContextMenuItems: () =>
807+
getAdhocContextMenuItems(groupIndex, taskIndex, task.id),
808+
})}
807809
/>
808810
);
809811
})}

0 commit comments

Comments
 (0)