Skip to content

Commit 299a57d

Browse files
Remove copy button from pending events in workflow history (#979)
Since pending events in the workflow history are only present temporarily, we do not want to support deep-linking to them because the deep link will no longer be valid once the event is actually written to history. This PR hides the Copy Link to Event button for pending events.
1 parent b5893df commit 299a57d

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

src/views/workflow-history/workflow-history-events-card/__tests__/workflow-history-events-card.test.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
scheduleActivityTaskEvent,
55
startActivityTaskEvent,
66
} from '../../__fixtures__/workflow-history-activity-events';
7+
import { pendingActivityTaskStartEvent } from '../../__fixtures__/workflow-history-pending-events';
78
import WorkflowHistoryEventsCard from '../workflow-history-events-card';
89
import type { Props } from '../workflow-history-events-card.types';
910

@@ -103,6 +104,44 @@ describe('WorkflowHistoryEventsCard', () => {
103104
);
104105
});
105106

107+
it('should show copy button when event is expanded', () => {
108+
const events: Props['events'] = [scheduleActivityTaskEvent];
109+
const eventsMetadata: Props['eventsMetadata'] = [
110+
{
111+
label: 'First event',
112+
status: 'COMPLETED',
113+
},
114+
];
115+
setup({
116+
events,
117+
eventsMetadata,
118+
getIsEventExpanded: jest.fn().mockReturnValue(true),
119+
});
120+
121+
expect(screen.getByTestId('event-link-button')).toBeInTheDocument();
122+
expect(screen.getByTestId('event-link-button')).toHaveAttribute(
123+
'data-event-id',
124+
scheduleActivityTaskEvent.eventId
125+
);
126+
});
127+
128+
it('should not show copy button for pending event even when expanded', () => {
129+
const events: Props['events'] = [pendingActivityTaskStartEvent];
130+
const eventsMetadata: Props['eventsMetadata'] = [
131+
{
132+
label: 'Pending event',
133+
status: 'WAITING',
134+
},
135+
];
136+
setup({
137+
events,
138+
eventsMetadata,
139+
getIsEventExpanded: jest.fn().mockReturnValue(true),
140+
});
141+
142+
expect(screen.queryByTestId('event-link-button')).not.toBeInTheDocument();
143+
});
144+
106145
it('should call onEventToggle callback on click', async () => {
107146
const events: Props['events'] = [
108147
scheduleActivityTaskEvent,

src/views/workflow-history/workflow-history-events-card/workflow-history-events-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function WorkflowHistoryEventsCard({
5656
/>
5757
<div className={cls.eventLabel}>
5858
{eventMetadata.label}
59-
{isPanelExpanded && (
59+
{event.eventId && isPanelExpanded && (
6060
<WorkflowHistoryEventLinkButton historyEventId={id} />
6161
)}
6262
</div>

src/views/workflow-history/workflow-history-ungrouped-event/__tests__/workflow-history-ungrouped-event.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,29 @@ describe(WorkflowHistoryUngroupedEvent.name, () => {
224224

225225
expect(mockOnReset).toHaveBeenCalledTimes(1);
226226
});
227+
228+
it('should show copy button for regular event when expanded', () => {
229+
setup({ isExpanded: true });
230+
231+
expect(screen.getByTestId('event-link-button')).toBeInTheDocument();
232+
expect(screen.getByTestId('event-link-button')).toHaveAttribute(
233+
'data-event-id',
234+
startWorkflowExecutionEvent.eventId
235+
);
236+
expect(screen.getByTestId('event-link-button')).toHaveAttribute(
237+
'data-ungrouped',
238+
'true'
239+
);
240+
});
241+
242+
it('should not show copy button for pending event even when expanded', () => {
243+
setup({
244+
eventInfo: mockPendingActivityEventInfo,
245+
isExpanded: true,
246+
});
247+
248+
expect(screen.queryByTestId('event-link-button')).not.toBeInTheDocument();
249+
});
227250
});
228251

229252
function setup({

src/views/workflow-history/workflow-history-ungrouped-event/workflow-history-ungrouped-event.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function WorkflowHistoryUngroupedEvent({
5050
label={eventInfo.label}
5151
shortLabel={eventInfo.shortLabel}
5252
/>
53-
{isExpanded && (
53+
{eventInfo.event.eventId && isExpanded && (
5454
<WorkflowHistoryEventLinkButton
5555
historyEventId={eventInfo.id}
5656
isUngroupedView

0 commit comments

Comments
 (0)