Skip to content

Commit 07a67b8

Browse files
committed
[Cases] Do not show status dropdown on modal cases selector (#111101)
1 parent dae544a commit 07a67b8

File tree

3 files changed

+63
-35
lines changed

3 files changed

+63
-35
lines changed

x-pack/plugins/cases/public/components/all_cases/all_cases_generic.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ export const AllCasesGeneric = React.memo<AllCasesGenericProps>(
203203
handleIsLoading,
204204
isLoadingCases: loading,
205205
refreshCases,
206-
showActions,
206+
// isSelectorView is boolean | undefined. We need to convert it to a boolean.
207+
isSelectorView: !!isSelectorView,
207208
userCanCrud,
208209
connectors,
209210
});

x-pack/plugins/cases/public/components/all_cases/columns.tsx

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export interface GetCasesColumn {
7272
handleIsLoading: (a: boolean) => void;
7373
isLoadingCases: string[];
7474
refreshCases?: (a?: boolean) => void;
75-
showActions: boolean;
75+
isSelectorView: boolean;
7676
userCanCrud: boolean;
7777
connectors?: ActionConnector[];
7878
}
@@ -84,7 +84,7 @@ export const useCasesColumns = ({
8484
handleIsLoading,
8585
isLoadingCases,
8686
refreshCases,
87-
showActions,
87+
isSelectorView,
8888
userCanCrud,
8989
connectors = [],
9090
}: GetCasesColumn): CasesColumns[] => {
@@ -281,38 +281,42 @@ export const useCasesColumns = ({
281281
return getEmptyTagValue();
282282
},
283283
},
284-
{
285-
name: i18n.STATUS,
286-
render: (theCase: Case) => {
287-
if (theCase?.subCases == null || theCase.subCases.length === 0) {
288-
if (theCase.status == null || theCase.type === CaseType.collection) {
289-
return getEmptyTagValue();
290-
}
291-
return (
292-
<StatusContextMenu
293-
currentStatus={theCase.status}
294-
disabled={!userCanCrud || isLoadingCases.length > 0}
295-
onStatusChanged={(status) =>
296-
handleDispatchUpdate({
297-
updateKey: 'status',
298-
updateValue: status,
299-
caseId: theCase.id,
300-
version: theCase.version,
301-
})
284+
...(!isSelectorView
285+
? [
286+
{
287+
name: i18n.STATUS,
288+
render: (theCase: Case) => {
289+
if (theCase?.subCases == null || theCase.subCases.length === 0) {
290+
if (theCase.status == null || theCase.type === CaseType.collection) {
291+
return getEmptyTagValue();
292+
}
293+
return (
294+
<StatusContextMenu
295+
currentStatus={theCase.status}
296+
disabled={!userCanCrud || isLoadingCases.length > 0}
297+
onStatusChanged={(status) =>
298+
handleDispatchUpdate({
299+
updateKey: 'status',
300+
updateValue: status,
301+
caseId: theCase.id,
302+
version: theCase.version,
303+
})
304+
}
305+
/>
306+
);
302307
}
303-
/>
304-
);
305-
}
306308

307-
const badges = getSubCasesStatusCountsBadges(theCase.subCases);
308-
return badges.map(({ color, count }, index) => (
309-
<EuiBadge key={index} color={color}>
310-
{count}
311-
</EuiBadge>
312-
));
313-
},
314-
},
315-
...(showActions
309+
const badges = getSubCasesStatusCountsBadges(theCase.subCases);
310+
return badges.map(({ color, count }, index) => (
311+
<EuiBadge key={index} color={color}>
312+
{count}
313+
</EuiBadge>
314+
));
315+
},
316+
},
317+
]
318+
: []),
319+
...(userCanCrud && !isSelectorView
316320
? [
317321
{
318322
name: (

x-pack/plugins/cases/public/components/all_cases/index.test.tsx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('AllCasesGeneric', () => {
144144
filterStatus: CaseStatuses.open,
145145
handleIsLoading: jest.fn(),
146146
isLoadingCases: [],
147-
showActions: true,
147+
isSelectorView: false,
148148
userCanCrud: true,
149149
};
150150

@@ -377,7 +377,7 @@ describe('AllCasesGeneric', () => {
377377
isLoadingCases: [],
378378
filterStatus: CaseStatuses.open,
379379
handleIsLoading: jest.fn(),
380-
showActions: false,
380+
isSelectorView: true,
381381
userCanCrud: true,
382382
})
383383
);
@@ -926,4 +926,27 @@ describe('AllCasesGeneric', () => {
926926
).toBeFalsy();
927927
});
928928
});
929+
930+
it('should not render status when isSelectorView=true', async () => {
931+
const wrapper = mount(
932+
<TestProviders>
933+
<AllCases {...defaultAllCasesProps} isSelectorView={true} />
934+
</TestProviders>
935+
);
936+
937+
const { result } = renderHook<GetCasesColumn, CasesColumns[]>(() =>
938+
useCasesColumns({
939+
...defaultColumnArgs,
940+
isSelectorView: true,
941+
})
942+
);
943+
944+
expect(result.current.find((i) => i.name === 'Status')).toBeFalsy();
945+
946+
await waitFor(() => {
947+
expect(wrapper.find('[data-test-subj="cases-table"]').exists()).toBeTruthy();
948+
});
949+
950+
expect(wrapper.find('[data-test-subj="case-view-status-dropdown"]').exists()).toBeFalsy();
951+
});
929952
});

0 commit comments

Comments
 (0)