Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
84141fc
Merge branch 'master' into cases_obs
stephmilovic May 18, 2021
e3d3e8c
Cases routing
stephmilovic May 18, 2021
eb7fdd7
Adding cases feature
jonathan-buttner May 18, 2021
ce68009
wip
stephmilovic May 18, 2021
77b5a54
Merge pull request #3 from jonathan-buttner/obs-cases-feature
stephmilovic May 18, 2021
722649e
i made a case
stephmilovic May 18, 2021
85e3de7
cases in obs
stephmilovic May 19, 2021
1c7b613
add back in user permissions
stephmilovic May 20, 2021
ccd7e79
Merge branch 'master' into cases_obs
stephmilovic May 24, 2021
fb7e7a9
in middle of removing alerts stuff
stephmilovic May 25, 2021
9f9f936
Merge branch 'cases-rbac-poc' into cases_obs
stephmilovic May 25, 2021
882d97c
removed alerting and fixing types
stephmilovic May 25, 2021
fe20f5c
fix submitCase when no alerting
stephmilovic May 25, 2021
5345d40
fix up breadcrumbs
stephmilovic May 25, 2021
8c2cc61
Fix jest
stephmilovic May 25, 2021
528c9be
Fix types
stephmilovic May 25, 2021
bd694ca
change key for message storage
stephmilovic May 25, 2021
9ef3ab4
may it please CI
stephmilovic May 25, 2021
5df7d33
arrys rbac changes
stephmilovic May 26, 2021
fd54706
fix type
stephmilovic May 27, 2021
bee51fd
midst of nathans pr changes
stephmilovic Jun 1, 2021
359df83
merge conflicts and EuiPage to ObsPage on cases
stephmilovic Jun 1, 2021
bf02730
redirect after delete
stephmilovic Jun 1, 2021
c0f2105
does not exist page
stephmilovic Jun 2, 2021
9266b17
fix tests
stephmilovic Jun 2, 2021
1edb767
fix types
stephmilovic Jun 2, 2021
8f2cb30
fix jest
stephmilovic Jun 3, 2021
6a66a6c
Merge branch 'cases-rbac-poc' into cases_obs
stephmilovic Jun 3, 2021
9d87078
fixing links
stephmilovic Jun 3, 2021
28152b8
Merge branch 'cases-rbac-poc' into cases_obs
stephmilovic Jun 3, 2021
1211f7f
Merge branch 'cases-rbac-poc' into cases_obs
kibanamachine Jun 7, 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
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ interface AllCasesGenericProps {
caseDetailsNavigation?: CasesNavigation<CaseDetailsHrefSchema, 'configurable'>; // if not passed, case name is not displayed as a link (Formerly dependant on isSelectorView)
configureCasesNavigation?: CasesNavigation; // if not passed, header with nav is not displayed (Formerly dependant on isSelectorView)
createCaseNavigation: CasesNavigation;
disableAlerts?: boolean;
hiddenStatuses?: CaseStatusWithAllStatus[];
isSelectorView?: boolean;
onRowClick?: (theCase?: Case | SubCase) => void;
showTitle?: boolean;
updateCase?: (newCase: Case) => void;
userCanCrud: boolean;
}
Expand All @@ -75,9 +77,11 @@ export const AllCasesGeneric = React.memo<AllCasesGenericProps>(
caseDetailsNavigation,
configureCasesNavigation,
createCaseNavigation,
disableAlerts,
hiddenStatuses = [],
isSelectorView,
onRowClick,
showTitle,
updateCase,
userCanCrud,
}) => {
Expand Down Expand Up @@ -190,6 +194,7 @@ export const AllCasesGeneric = React.memo<AllCasesGenericProps>(

const columns = useCasesColumns({
caseDetailsNavigation,
disableAlerts,
dispatchUpdateCaseProperty,
filterStatus: filterOptions.status,
handleIsLoading,
Expand Down Expand Up @@ -271,6 +276,7 @@ export const AllCasesGeneric = React.memo<AllCasesGenericProps>(
createCaseNavigation={createCaseNavigation}
configureCasesNavigation={configureCasesNavigation}
refresh={refresh}
showTitle={showTitle}
userCanCrud={userCanCrud}
/>
)}
Expand Down
24 changes: 15 additions & 9 deletions x-pack/plugins/cases/public/components/all_cases/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const renderStringField = (field: string, dataTestSubj: string) =>

export interface GetCasesColumn {
caseDetailsNavigation?: CasesNavigation<CaseDetailsHrefSchema, 'configurable'>;
disableAlerts?: boolean;
dispatchUpdateCaseProperty: (u: UpdateCase) => void;
filterStatus: string;
handleIsLoading: (a: boolean) => void;
Expand All @@ -64,6 +65,7 @@ export interface GetCasesColumn {
}
export const useCasesColumns = ({
caseDetailsNavigation,
disableAlerts = false,
dispatchUpdateCaseProperty,
filterStatus,
handleIsLoading,
Expand Down Expand Up @@ -203,15 +205,19 @@ export const useCasesColumns = ({
},
truncateText: true,
},
{
align: RIGHT_ALIGNMENT,
field: 'totalAlerts',
name: ALERTS,
render: (totalAlerts: Case['totalAlerts']) =>
totalAlerts != null
? renderStringField(`${totalAlerts}`, `case-table-column-alertsCount`)
: getEmptyTagValue(),
},
...(!disableAlerts
? [
{
align: RIGHT_ALIGNMENT,
field: 'totalAlerts',
name: ALERTS,
render: (totalAlerts: Case['totalAlerts']) =>
totalAlerts != null
? renderStringField(`${totalAlerts}`, `case-table-column-alertsCount`)
: getEmptyTagValue(),
},
]
: []),
{
align: RIGHT_ALIGNMENT,
field: 'totalComment',
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/cases/public/components/all_cases/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface OwnProps {
configureCasesNavigation: CasesNavigation;
createCaseNavigation: CasesNavigation;
refresh: number;
showTitle?: boolean;
userCanCrud: boolean;
}

Expand All @@ -40,9 +41,10 @@ export const CasesTableHeader: FunctionComponent<Props> = ({
configureCasesNavigation,
createCaseNavigation,
refresh,
showTitle = true,
userCanCrud,
}) => (
<CaseHeaderPage title={i18n.PAGE_TITLE}>
<CaseHeaderPage title={showTitle ? i18n.PAGE_TITLE : ''}>
<EuiFlexGroup
alignItems="center"
gutterSize="m"
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/cases/public/components/all_cases/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface AllCasesProps extends Owner {
caseDetailsNavigation: CasesNavigation<CaseDetailsHrefSchema, 'configurable'>; // if not passed, case name is not displayed as a link (Formerly dependant on isSelector)
configureCasesNavigation: CasesNavigation; // if not passed, header with nav is not displayed (Formerly dependant on isSelector)
createCaseNavigation: CasesNavigation;
disableAlerts?: boolean;
showTitle?: boolean;
userCanCrud: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ describe('CaseView actions', () => {
it('clicking trash toggles modal', () => {
const wrapper = mount(
<TestProviders>
<Actions caseData={basicCase} currentExternalIncident={null} />
<Actions
allCasesNavigation={{
href: 'all-cases-href',
onClick: jest.fn(),
}}
caseData={basicCase}
currentExternalIncident={null}
/>
</TestProviders>
);

Expand All @@ -67,7 +74,14 @@ describe('CaseView actions', () => {
}));
const wrapper = mount(
<TestProviders>
<Actions caseData={basicCase} currentExternalIncident={null} />
<Actions
allCasesNavigation={{
href: 'all-cases-href',
onClick: jest.fn(),
}}
caseData={basicCase}
currentExternalIncident={null}
/>
</TestProviders>
);

Expand All @@ -82,6 +96,10 @@ describe('CaseView actions', () => {
const wrapper = mount(
<TestProviders>
<Actions
allCasesNavigation={{
href: 'all-cases-href',
onClick: jest.fn(),
}}
caseData={basicCase}
currentExternalIncident={{
...basicPush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,27 @@

import { isEmpty } from 'lodash/fp';
import React, { useMemo } from 'react';
import { useHistory } from 'react-router-dom';
import * as i18n from '../case_view/translations';
import { useDeleteCases } from '../../containers/use_delete_cases';
import { ConfirmDeleteCaseModal } from '../confirm_delete_case';
import { PropertyActions } from '../property_actions';
import { Case } from '../../containers/types';
import { Case } from '../../../common';
import { CaseService } from '../../containers/use_get_case_user_actions';
import { CasesNavigation } from '../links';

interface CaseViewActions {
allCasesNavigation: CasesNavigation;
caseData: Case;
currentExternalIncident: CaseService | null;
disabled?: boolean;
}

const ActionsComponent: React.FC<CaseViewActions> = ({
allCasesNavigation,
caseData,
currentExternalIncident,
disabled = false,
}) => {
const history = useHistory();
// Delete case
const {
handleToggleModal,
Expand Down Expand Up @@ -57,7 +58,7 @@ const ActionsComponent: React.FC<CaseViewActions> = ({
);

if (isDeleted) {
history.push('/');
allCasesNavigation.onClick(({ preventDefault: () => null } as unknown) as MouseEvent);
return null;
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ describe('CaseActionBar', () => {
const onRefresh = jest.fn();
const onUpdateField = jest.fn();
const defaultProps = {
allCasesNavigation: {
href: 'all-cases-href',
onClick: jest.fn(),
},
caseData: basicCase,
isAlerting: true,
isLoading: false,
onRefresh,
onUpdateField,
Expand Down
49 changes: 28 additions & 21 deletions x-pack/plugins/cases/public/components/case_action_bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import {
EuiFlexItem,
EuiIconTip,
} from '@elastic/eui';
import { CaseStatuses, CaseType } from '../../../common';
import { Case, CaseStatuses, CaseType } from '../../../common';
import * as i18n from '../case_view/translations';
import { FormattedRelativePreferenceDate } from '../formatted_date';
import { Actions } from './actions';
import { Case } from '../../containers/types';
import { CaseService } from '../../containers/use_get_case_user_actions';
import { StatusContextMenu } from './status_context_menu';
import { getStatusDate, getStatusTitle } from './helpers';
import { SyncAlertsSwitch } from '../case_settings/sync_alerts_switch';
import { OnUpdateFields } from '../case_view';
import { CasesNavigation } from '../links';

const MyDescriptionList = styled(EuiDescriptionList)`
${({ theme }) => css`
Expand All @@ -37,17 +37,21 @@ const MyDescriptionList = styled(EuiDescriptionList)`
`;

interface CaseActionBarProps {
allCasesNavigation: CasesNavigation;
caseData: Case;
currentExternalIncident: CaseService | null;
disabled?: boolean;
isAlerting: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: disableAlerts seems a better name for this variable.

Copy link
Copy Markdown
Contributor Author

@stephmilovic stephmilovic May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its confusing to me because L42 disabled property is for alerts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depending on userCanCrud

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I might have added that 😆 feel free to rename it, it was just trying to fix an issue where the status button was enabled when the user only had read only permissions.

isLoading: boolean;
onRefresh: () => void;
onUpdateField: (args: OnUpdateFields) => void;
}
const CaseActionBarComponent: React.FC<CaseActionBarProps> = ({
allCasesNavigation,
caseData,
currentExternalIncident,
disabled = false,
isAlerting,
isLoading,
onRefresh,
onUpdateField,
Expand Down Expand Up @@ -104,32 +108,35 @@ const CaseActionBarComponent: React.FC<CaseActionBarProps> = ({
<EuiFlexItem grow={false}>
<EuiDescriptionList compressed>
<EuiFlexGroup gutterSize="l" alignItems="center">
<EuiFlexItem>
<EuiDescriptionListTitle>
<EuiFlexGroup component="span" alignItems="center" gutterSize="xs">
<EuiFlexItem grow={false}>
<span>{i18n.SYNC_ALERTS}</span>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIconTip content={i18n.SYNC_ALERTS_HELP} />
</EuiFlexItem>
</EuiFlexGroup>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
<SyncAlertsSwitch
disabled={disabled || isLoading}
isSynced={caseData.settings.syncAlerts}
onSwitchChange={onSyncAlertsChanged}
/>
</EuiDescriptionListDescription>
</EuiFlexItem>
{isAlerting && (
<EuiFlexItem>
<EuiDescriptionListTitle>
<EuiFlexGroup component="span" alignItems="center" gutterSize="xs">
<EuiFlexItem grow={false}>
<span>{i18n.SYNC_ALERTS}</span>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiIconTip content={i18n.SYNC_ALERTS_HELP} />
</EuiFlexItem>
</EuiFlexGroup>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
<SyncAlertsSwitch
disabled={disabled || isLoading}
isSynced={caseData.settings.syncAlerts}
onSwitchChange={onSyncAlertsChanged}
/>
</EuiDescriptionListDescription>
</EuiFlexItem>
)}
<EuiFlexItem>
<EuiButtonEmpty data-test-subj="case-refresh" iconType="refresh" onClick={onRefresh}>
{i18n.CASE_REFRESH}
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false} data-test-subj="case-view-actions">
<Actions
allCasesNavigation={allCasesNavigation}
caseData={caseData}
currentExternalIncident={currentExternalIncident}
disabled={disabled}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React from 'react';

import { EuiEmptyPrompt, EuiButton } from '@elastic/eui';
import * as i18n from './translations';
import { CasesNavigation } from '../links';
interface Props {
allCasesNavigation: CasesNavigation;
caseId: string;
}
export const DoesNotExist = ({ allCasesNavigation, caseId }: Props) => (
<EuiEmptyPrompt
// @ts-ignore remove once https://github.com/elastic/eui/issues/4850 is resolved
iconColor={null}
iconType="addDataApp"
title={<h2>{i18n.DOES_NOT_EXIST_TITLE}</h2>}
titleSize="xs"
body={<p>{i18n.DOES_NOT_EXIST_DESCRIPTION(caseId)}</p>}
actions={
<EuiButton onClick={allCasesNavigation.onClick} size="s" color="primary" fill>
{i18n.DOES_NOT_EXIST_BUTTON}
</EuiButton>
}
/>
);
Loading