Skip to content

Commit

Permalink
update error msgs to info
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierM committed Mar 23, 2020
1 parent fb88c5c commit e311752
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const RedirectToConfigureCasesPage = () => (
const baseCaseUrl = `#/link-to/${SiemPageName.case}`;

export const getCaseUrl = () => baseCaseUrl;
export const getCaseDetailsUrl = (detailName: string) => `${baseCaseUrl}/${detailName}`;
export const getCreateCaseUrl = () => `${baseCaseUrl}/create`;
export const getConfigureCasesUrl = () => `${baseCaseUrl}/configure`;
export const getCaseDetailsUrl = (detailName: string, search: string) =>
`${baseCaseUrl}/${detailName}${search}`;
export const getCreateCaseUrl = (search: string) => `${baseCaseUrl}/create${search}`;
export const getConfigureCasesUrl = (search: string) => `${baseCaseUrl}/configure${search}`;
28 changes: 17 additions & 11 deletions x-pack/legacy/plugins/siem/public/components/links/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import {
import { FlowTarget, FlowTargetSourceDest } from '../../graphql/types';
import { useUiSetting$ } from '../../lib/kibana';
import { IP_REPUTATION_LINKS_SETTING } from '../../../common/constants';
import { navTabs } from '../../pages/home/home_navigations';
import * as i18n from '../page/network/ip_overview/translations';
import { isUrlInvalid } from '../../pages/detection_engine/rules/components/step_about_rule/helpers';
import { useGetUrlSearch } from '../navigation/use_get_url_search';
import { ExternalLinkIcon } from '../external_link_icon';

export const DEFAULT_NUMBER_OF_LINK = 5;
Expand Down Expand Up @@ -89,20 +91,24 @@ export const IPDetailsLink = React.memo(IPDetailsLinkComponent);
const CaseDetailsLinkComponent: React.FC<{ children?: React.ReactNode; detailName: string }> = ({
children,
detailName,
}) => (
<EuiLink
href={getCaseDetailsUrl(encodeURIComponent(detailName))}
data-test-subj="case-details-link"
>
{children ? children : detailName}
</EuiLink>
);
}) => {
const urlSearch = useGetUrlSearch(navTabs.case);
return (
<EuiLink
href={getCaseDetailsUrl(encodeURIComponent(detailName), urlSearch)}
data-test-subj="case-details-link"
>
{children ? children : detailName}
</EuiLink>
);
};
export const CaseDetailsLink = React.memo(CaseDetailsLinkComponent);
CaseDetailsLink.displayName = 'CaseDetailsLink';

export const CreateCaseLink = React.memo<{ children: React.ReactNode }>(({ children }) => (
<EuiLink href={getCreateCaseUrl()}>{children}</EuiLink>
));
export const CreateCaseLink = React.memo<{ children: React.ReactNode }>(({ children }) => {
const urlSearch = useGetUrlSearch(navTabs.case);
return <EuiLink href={getCreateCaseUrl(urlSearch)}>{children}</EuiLink>;
});

CreateCaseLink.displayName = 'CreateCaseLink';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ describe('AllCases', () => {
.find(`a[data-test-subj="case-details-link"]`)
.first()
.prop('href')
).toEqual(`#/link-to/case/${useGetCasesMockState.data.cases[0].id}`);
).toEqual(
`#/link-to/case/${useGetCasesMockState.data.cases[0].id}?timerange=(global:(linkTo:!(timeline),timerange:(from:0,fromStr:now-24h,kind:relative,to:1,toStr:now)),timeline:(linkTo:!(global),timerange:(from:0,fromStr:now-24h,kind:relative,to:1,toStr:now)))`
);
expect(
wrapper
.find(`a[data-test-subj="case-details-link"]`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ import {
UtilityBarText,
} from '../../../../components/utility_bar';
import { getConfigureCasesUrl, getCreateCaseUrl } from '../../../../components/link_to';

import { useUpdateCases } from '../../../../containers/case/use_bulk_update_case';
import { useGetUrlSearch } from '../../../../components/navigation/use_get_url_search';
import { navTabs } from '../../../home/home_navigations';
import { getBulkItems } from '../bulk_actions';
import { CaseHeaderPage } from '../case_header_page';
import { ConfirmDeleteCaseModal } from '../confirm_delete_case';
import { OpenClosedStats } from '../open_closed_stats';

import { getActions } from './actions';
import { CasesTableFilters } from './table_filters';
import { useUpdateCases } from '../../../../containers/case/use_bulk_update_case';

const CONFIGURE_CASES_URL = getConfigureCasesUrl();
const CREATE_CASE_URL = getCreateCaseUrl();

const Div = styled.div`
margin-top: ${({ theme }) => theme.eui.paddingSizes.m};
Expand Down Expand Up @@ -78,6 +76,7 @@ const getSortField = (field: string): SortFieldCase => {
return SortFieldCase.createdAt;
};
export const AllCases = React.memo(() => {
const urlSearch = useGetUrlSearch(navTabs.case);
const {
countClosedCases,
countOpenCases,
Expand Down Expand Up @@ -276,12 +275,12 @@ export const AllCases = React.memo(() => {
/>
</FlexItemDivider>
<EuiFlexItem grow={false}>
<EuiButton href={CONFIGURE_CASES_URL} iconType="controlsHorizontal">
<EuiButton href={getConfigureCasesUrl(urlSearch)} iconType="controlsHorizontal">
{i18n.CONFIGURE_CASES_BUTTON}
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton fill href={CREATE_CASE_URL} iconType="plusInCircle">
<EuiButton fill href={getCreateCaseUrl(urlSearch)} iconType="plusInCircle">
{i18n.CREATE_TITLE}
</EuiButton>
</EuiFlexItem>
Expand Down Expand Up @@ -342,7 +341,12 @@ export const AllCases = React.memo(() => {
titleSize="xs"
body={i18n.NO_CASES_BODY}
actions={
<EuiButton fill size="s" href={CREATE_CASE_URL} iconType="plusInCircle">
<EuiButton
fill
size="s"
href={getCreateCaseUrl(urlSearch)}
iconType="plusInCircle"
>
{i18n.ADD_NEW_CASE}
</EuiButton>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiButton, EuiToolTip } from '@elastic/eui';
import { EuiButton, EuiLink, EuiToolTip } from '@elastic/eui';
import React, { useCallback, useState, useMemo } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';

import { useCaseConfigure } from '../../../../containers/case/configure/use_configure';
import { Case } from '../../../../containers/case/types';
import { useGetActionLicense } from '../../../../containers/case/use_get_action_license';
import { usePostPushToService } from '../../../../containers/case/use_post_push_to_service';

import * as i18n from './translations';
import { getConfigureCasesUrl } from '../../../../components/link_to';
import { useGetUrlSearch } from '../../../../components/navigation/use_get_url_search';
import { navTabs } from '../../../home/home_navigations';
import { ErrorsPushServiceCallOut } from '../errors_push_service_callout';
import * as i18n from './translations';

interface UsePushToService {
caseId: string;
Expand All @@ -38,6 +41,7 @@ export const usePushToService = ({
updateCase,
isNew,
}: UsePushToService): ReturnUsePushToService => {
const urlSearch = useGetUrlSearch(navTabs.case);
const [connector, setConnector] = useState<Connector | null>(null);

const { isLoading, postPushToService } = usePostPushToService();
Expand All @@ -63,13 +67,25 @@ export const usePushToService = ({
}, [caseId, connector, postPushToService, updateCase]);

const errorsMsg = useMemo(() => {
let errors: Array<{ title: string; description: string }> = [];
if (caseStatus === 'closed') {
let errors: Array<{ title: string; description: JSX.Element }> = [];
if (actionLicense != null && !actionLicense.enabledInLicense) {
errors = [
...errors,
{
title: i18n.PUSH_DISABLE_BECAUSE_CASE_CLOSED_TITLE,
description: i18n.PUSH_DISABLE_BECAUSE_CASE_CLOSED_DESCRIPTION,
title: i18n.PUSH_DISABLE_BY_LICENSE_TITLE,
description: (
<FormattedMessage
defaultMessage="To open cases in external systems, you must update your license to Platinum, start a free 30-day trial, or spin up a {link} on AWS, GCP, or Azure."
id="xpack.siem.case.caseView.pushToServiceDisableByLicenseDescription"
values={{
link: (
<EuiLink href="https://www.elastic.co/cloud/" target="_blank">
{i18n.LINK_CLOUD_DEPLOYMENT}
</EuiLink>
),
}}
/>
),
},
];
}
Expand All @@ -78,16 +94,33 @@ export const usePushToService = ({
...errors,
{
title: i18n.PUSH_DISABLE_BY_NO_CASE_CONFIG_TITLE,
description: i18n.PUSH_DISABLE_BY_NO_CASE_CONFIG_DESCRIPTION,
description: (
<FormattedMessage
defaultMessage="To open and update cases in external systems, you must configure a {link}."
id="xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigDescription"
values={{
link: (
<EuiLink href={getConfigureCasesUrl(urlSearch)} target="_blank">
{i18n.LINK_CONNECTOR_CONFIGURE}
</EuiLink>
),
}}
/>
),
},
];
}
if (actionLicense != null && !actionLicense.enabledInLicense) {
if (caseStatus === 'closed') {
errors = [
...errors,
{
title: i18n.PUSH_DISABLE_BY_LICENSE_TITLE,
description: i18n.PUSH_DISABLE_BY_LICENSE_DESCRIPTION,
title: i18n.PUSH_DISABLE_BECAUSE_CASE_CLOSED_TITLE,
description: (
<FormattedMessage
defaultMessage="Closed cases cannot be sent to external systems. Reopen the case if you want to open or update it in an external system."
id="xpack.siem.case.caseView.pushToServiceDisableBecauseCaseClosedDescription"
/>
),
},
];
}
Expand All @@ -96,12 +129,24 @@ export const usePushToService = ({
...errors,
{
title: i18n.PUSH_DISABLE_BY_KIBANA_CONFIG_TITLE,
description: i18n.PUSH_DISABLE_BY_KIBANA_CONFIG_DESCRIPTION,
description: (
<FormattedMessage
defaultMessage="The kibana.yml file is configured to only allow specific connectors. To enable opening a case in external systems, add .servicenow to the xpack.actions.enabledActiontypes setting. For more information, see link."
id="xpack.siem.case.caseView.pushToServiceDisableByConfigDescription"
values={{
link: (
<EuiLink href="#" target="_blank">
{'coming soon...'}
</EuiLink>
),
}}
/>
),
},
];
}
return errors;
}, [actionLicense, caseStatus, connector, loadingCaseConfigure, loadingLicense]);
}, [actionLicense, caseStatus, connector, loadingCaseConfigure, loadingLicense, urlSearch]);

const pushToServiceButton = useMemo(
() => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,55 +117,41 @@ export const UPDATE_PUSH_SERVICENOW = i18n.translate(
export const PUSH_DISABLE_BY_NO_CASE_CONFIG_TITLE = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigTitle',
{
defaultMessage: 'Configure case',
}
);

export const PUSH_DISABLE_BY_NO_CASE_CONFIG_DESCRIPTION = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableByNoCaseConfigDescription',
{
defaultMessage: 'You did not configure you case system',
defaultMessage: 'Configure external connector',
}
);

export const PUSH_DISABLE_BECAUSE_CASE_CLOSED_TITLE = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableBecauseCaseClosedTitle',
{
defaultMessage: 'Case closed',
}
);

export const PUSH_DISABLE_BECAUSE_CASE_CLOSED_DESCRIPTION = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableBecauseCaseClosedDescription',
{
defaultMessage: 'You cannot push a case who have been closed',
defaultMessage: 'Reopen the case',
}
);

export const PUSH_DISABLE_BY_KIBANA_CONFIG_TITLE = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableByConfigTitle',
{
defaultMessage: 'Connector kibana config',
defaultMessage: 'Enable ServiceNow in Kibana configuration file',
}
);

export const PUSH_DISABLE_BY_KIBANA_CONFIG_DESCRIPTION = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableByConfigDescription',
export const PUSH_DISABLE_BY_LICENSE_TITLE = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableByLicenseTitle',
{
defaultMessage: 'ServiceNow connector have been disabled in kibana config',
defaultMessage: 'Upgrade to Elastic Platinum',
}
);

export const PUSH_DISABLE_BY_LICENSE_TITLE = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableByLicenseTitle',
export const LINK_CLOUD_DEPLOYMENT = i18n.translate(
'xpack.siem.case.caseView.cloudDeploymentLink',
{
defaultMessage: 'Elastic Stack subscriptions',
defaultMessage: 'cloud deployment',
}
);

export const PUSH_DISABLE_BY_LICENSE_DESCRIPTION = i18n.translate(
'xpack.siem.case.caseView.pushToServiceDisableByLicenseDescription',
export const LINK_CONNECTOR_CONFIGURE = i18n.translate(
'xpack.siem.case.caseView.connectorConfigureLink',
{
defaultMessage: 'ServiceNow is disabled because you do not have the right license',
defaultMessage: 'connector',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiCallOut, EuiButton, EuiDescriptionList } from '@elastic/eui';
import { EuiCallOut, EuiButton, EuiDescriptionList, EuiSpacer } from '@elastic/eui';
import React, { memo, useCallback, useState } from 'react';

import * as i18n from './translations';

interface ErrorsPushServiceCallOut {
errors: Array<{ title: string; description: string }>;
errors: Array<{ title: string; description: JSX.Element }>;
}

const ErrorsPushServiceCallOutComponent = ({ errors }: ErrorsPushServiceCallOut) => {
const [showCallOut, setShowCallOut] = useState(true);
const handleCallOut = useCallback(() => setShowCallOut(false), [setShowCallOut]);

return showCallOut ? (
<EuiCallOut title={i18n.ERROR_PUSH_SERVICE_CALLOUT_TITLE} color="danger" iconType="alert">
<EuiDescriptionList listItems={errors} />
<EuiButton color="danger" onClick={handleCallOut}>
{i18n.DISMISS_CALLOUT}
</EuiButton>
</EuiCallOut>
<>
<EuiCallOut title={i18n.ERROR_PUSH_SERVICE_CALLOUT_TITLE} color="primary" iconType="gear">
<EuiDescriptionList listItems={errors} />
<EuiButton color="primary" onClick={handleCallOut}>
{i18n.DISMISS_CALLOUT}
</EuiButton>
</EuiCallOut>
<EuiSpacer />
</>
) : null;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
export const ERROR_PUSH_SERVICE_CALLOUT_TITLE = i18n.translate(
'xpack.siem.case.errorsPushServiceCallOutTitle',
{
defaultMessage: 'You can not push to ServiceNow because of the errors below',
defaultMessage: 'To send cases to external systems, you need to:',
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const CONFIGURE_CASES_PAGE_TITLE = i18n.translate(
);

export const CONFIGURE_CASES_BUTTON = i18n.translate('xpack.siem.case.configureCasesButton', {
defaultMessage: 'Edit third-party connection',
defaultMessage: 'Edit external connection',
});

export const ADD_COMMENT = i18n.translate('xpack.siem.case.caseView.comment.addComment', {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/siem/public/pages/case/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export const getBreadcrumbs = (params: RouteSpyState): Breadcrumb[] => {
...breadcrumb,
{
text: i18n.CREATE_BC_TITLE,
href: getCreateCaseUrl(),
href: getCreateCaseUrl(''),
},
];
} else if (params.detailName != null) {
breadcrumb = [
...breadcrumb,
{
text: params.state?.caseTitle ?? '',
href: getCaseDetailsUrl(params.detailName),
href: getCaseDetailsUrl(params.detailName, ''),
},
];
}
Expand Down

0 comments on commit e311752

Please sign in to comment.