Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Case ui enhancement #91863

Merged
merged 36 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4803fcf
ui enhancement
angorayc Feb 18, 2021
c1acfba
Merge branch 'master' of github.com:elastic/kibana into case-ui-fix
angorayc Feb 18, 2021
fab3950
fix actions
angorayc Feb 18, 2021
9b80fa9
unit test
angorayc Feb 18, 2021
6dc3ca6
update row actions
angorayc Feb 19, 2021
5e8dcc3
add case status all
angorayc Feb 19, 2021
46335f0
update find status
angorayc Feb 22, 2021
baef996
fix type
angorayc Feb 22, 2021
0ed83b3
remove all case count from dropdown
angorayc Feb 22, 2021
0bddbf9
fix type error
angorayc Feb 23, 2021
d7107bd
fix unit test
angorayc Feb 23, 2021
e0c29b7
disable bulk actions on status all
angorayc Feb 23, 2021
5342462
clean up
angorayc Feb 23, 2021
f412d15
Merge branch 'case-ui-fix' of github.com:angorayc/kibana into case-ui…
angorayc Feb 23, 2021
b9da2f9
fix types
angorayc Feb 23, 2021
8e0251e
fix cypress tests
angorayc Feb 24, 2021
08e3516
Merge branch 'case-ui-fix' of github.com:angorayc/kibana into case-ui…
angorayc Feb 24, 2021
6986423
Merge branch 'master' into case-ui-fix
kibanamachine Feb 24, 2021
46e4684
review
angorayc Mar 1, 2021
385a6fa
Merge branch 'master' of github.com:elastic/kibana into case-ui-fix
angorayc Mar 1, 2021
d7554cd
review
angorayc Mar 1, 2021
1d4f9ab
update status is only available for individual cases
angorayc Mar 1, 2021
067b20e
update available actions on status all
angorayc Mar 1, 2021
94da327
fix unit test
angorayc Mar 1, 2021
e1c285f
remove lodash get
angorayc Mar 2, 2021
c1508ba
rename status all
angorayc Mar 2, 2021
a453269
omit status if it is set to all
angorayc Mar 2, 2021
a812a98
do not sent status if itis set to all
angorayc Mar 2, 2021
f4624bc
Merge branch 'master' of github.com:elastic/kibana into case-ui-fix
angorayc Mar 2, 2021
d05c171
Merge branch 'master' of github.com:elastic/kibana into case-ui-fix
angorayc Mar 2, 2021
89be6cf
Remove all status from the backend
cnasikas Mar 2, 2021
173dac0
Merge branch 'case-ui-fix' of github.com:angorayc/kibana into case-ui…
cnasikas Mar 2, 2021
a6c372c
Merge branch 'case-ui-fix' of github.com:angorayc/kibana into case-ui…
cnasikas Mar 2, 2021
b250898
Hide actions on all status
cnasikas Mar 2, 2021
92a57fd
Merge branch 'case-ui-fix' of github.com:angorayc/kibana into case-ui…
angorayc Mar 2, 2021
efdaf6e
fix unit test
angorayc Mar 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions x-pack/plugins/case/server/routes/api/cases/find_cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export function initFindCasesApi({ caseService, router, logger }: RouteDeps) {
CasesFindRequestRt.decode(request.query),
fold(throwErrors(Boom.badRequest), identity)
);

const queryArgs = {
tags: queryParams.tags,
reporters: queryParams.reporters,
Expand All @@ -47,7 +46,6 @@ export function initFindCasesApi({ caseService, router, logger }: RouteDeps) {
};

const caseQueries = constructQueryOptions(queryArgs);

const cases = await caseService.findCasesGroupedByID({
client,
caseOptions: { ...queryParams, ...caseQueries.case },
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/case/server/routes/api/cases/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const addStatusFilter = ({
appendFilter,
type = CASE_SAVED_OBJECT,
}: {
status: CaseStatuses | undefined;
status?: CaseStatuses;
appendFilter?: string;
type?: string;
}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
backToCases,
createCase,
fillCasesMandatoryfields,
filterStatusOpen,
} from '../../tasks/create_new_case';
import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login';

Expand Down Expand Up @@ -74,6 +75,7 @@ describe('Cases', () => {
attachTimeline(this.mycase);
createCase();
backToCases();
filterStatusOpen();

cy.get(ALL_CASES_PAGE_TITLE).should('have.text', 'Cases');
cy.get(ALL_CASES_OPEN_CASES_STATS).should('have.text', 'Open cases1');
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/security_solution/cypress/screens/all_cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const ALL_CASES_NAME = '[data-test-subj="case-details-link"]';

export const ALL_CASES_OPEN_CASES_COUNT = '[data-test-subj="case-status-filter"]';

export const ALL_CASES_OPEN_FILTER = '[data-test-subj="case-status-filter-open"]';

export const ALL_CASES_OPEN_CASES_STATS = '[data-test-subj="openStatsHeader"]';

export const ALL_CASES_OPENED_ON = '[data-test-subj="case-table-column-createdAt"]';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ServiceNowconnectorOptions,
TestCase,
} from '../objects/case';
import { ALL_CASES_OPEN_CASES_COUNT, ALL_CASES_OPEN_FILTER } from '../screens/all_cases';

import {
BACK_TO_CASES_BTN,
Expand Down Expand Up @@ -40,6 +41,11 @@ export const backToCases = () => {
cy.get(BACK_TO_CASES_BTN).click({ force: true });
};

export const filterStatusOpen = () => {
cy.get(ALL_CASES_OPEN_CASES_COUNT).click();
cy.get(ALL_CASES_OPEN_FILTER).click();
};

export const fillCasesMandatoryfields = (newCase: TestCase) => {
cy.get(TITLE_INPUT).type(newCase.name, { force: true });
newCase.tags.forEach((tag) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@ import { Case, SubCase } from '../../containers/types';
import { UpdateCase } from '../../containers/use_get_cases';
import { statuses } from '../status';
import * as i18n from './translations';
import { isIndividual } from './helpers';

interface GetActions {
caseStatus: string;
dispatchUpdate: Dispatch<Omit<UpdateCase, 'refetchCasesStatus'>>;
deleteCaseOnClick: (deleteCase: Case) => void;
}

const hasSubCases = (subCases: SubCase[] | null | undefined) =>
subCases != null && subCases?.length > 0;

export const getActions = ({
caseStatus,
dispatchUpdate,
deleteCaseOnClick,
}: GetActions): Array<DefaultItemIconButtonAction<Case>> => {
const openCaseAction = {
available: (item: Case) => caseStatus !== CaseStatuses.open && !hasSubCases(item.subCases),
available: (item: Case | SubCase) => item.status !== CaseStatuses.open,
enabled: (item: Case | SubCase) => isIndividual(item),
description: statuses[CaseStatuses.open].actions.single.title,
icon: statuses[CaseStatuses.open].icon,
name: statuses[CaseStatuses.open].actions.single.title,
Expand All @@ -45,8 +44,8 @@ export const getActions = ({
};

const makeInProgressAction = {
available: (item: Case) =>
caseStatus !== CaseStatuses['in-progress'] && !hasSubCases(item.subCases),
available: (item: Case) => item.status !== CaseStatuses['in-progress'],
enabled: (item: Case | SubCase) => isIndividual(item),
description: statuses[CaseStatuses['in-progress']].actions.single.title,
icon: statuses[CaseStatuses['in-progress']].icon,
name: statuses[CaseStatuses['in-progress']].actions.single.title,
Expand All @@ -62,7 +61,8 @@ export const getActions = ({
};

const closeCaseAction = {
available: (item: Case) => caseStatus !== CaseStatuses.closed && !hasSubCases(item.subCases),
available: (item: Case | SubCase) => item.status !== CaseStatuses.closed,
enabled: (item: Case | SubCase) => isIndividual(item),
description: statuses[CaseStatuses.closed].actions.single.title,
icon: statuses[CaseStatuses.closed].icon,
name: statuses[CaseStatuses.closed].actions.single.title,
Expand All @@ -78,6 +78,9 @@ export const getActions = ({
};

return [
openCaseAction,
makeInProgressAction,
closeCaseAction,
{
description: i18n.DELETE_CASE,
icon: 'trash',
Expand All @@ -86,8 +89,5 @@ export const getActions = ({
type: 'icon',
'data-test-subj': 'action-delete',
},
openCaseAction,
makeInProgressAction,
closeCaseAction,
];
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services';
import styled from 'styled-components';
import { DefaultItemIconButtonAction } from '@elastic/eui/src/components/basic_table/action_types';

import { CaseStatuses } from '../../../../../case/common/api';
import { CaseStatuses, CaseType } from '../../../../../case/common/api';
import { getEmptyTagValue } from '../../../common/components/empty_value';
import { Case, SubCase } from '../../containers/types';
import { FormattedRelativePreferenceDate } from '../../../common/components/formatted_date';
Expand Down Expand Up @@ -204,7 +204,7 @@ export const getCasesColumns = (
name: i18n.STATUS,
render: (theCase: Case) => {
if (theCase?.subCases == null || theCase.subCases.length === 0) {
if (theCase.status == null) {
if (theCase.status == null || theCase.type === CaseType.collection) {
return getEmptyTagValue();
}
return <Status type={theCase.status} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
*/

import { filter } from 'lodash/fp';
import { AssociationType, CaseStatuses } from '../../../../../case/common/api';
import { AssociationType, CaseStatuses, CaseType } from '../../../../../case/common/api';
import { Case, SubCase } from '../../containers/types';
import { statuses } from '../status';

export const isSelectedCasesIncludeCollections = (selectedCases: Case[]) =>
selectedCases.length > 0 &&
selectedCases.some((caseObj: Case) => caseObj.type === CaseType.collection);

export const isSubCase = (theCase: Case | SubCase): theCase is SubCase =>
(theCase as SubCase).caseParentId !== undefined &&
(theCase as SubCase).associationType === AssociationType.subCase;

export const isCollection = (theCase: Case | SubCase | null | undefined) =>
theCase != null && (theCase as Case).type === CaseType.collection;

export const isIndividual = (theCase: Case | SubCase | null | undefined) =>
theCase != null && (theCase as Case).type === CaseType.individual;

export const getSubCasesStatusCountsBadges = (
subCases: SubCase[]
): Array<{ name: CaseStatuses; color: string; count: number }> => {
Expand Down
Loading