Skip to content

Commit

Permalink
[Security Solution][Detections] Adds additional context to the "needs…
Browse files Browse the repository at this point in the history
… index permissions" prompt (#73547)

* Adds conditional context to the "needs index permissions" prompt

In an effort to assist the user in their configuration, this adds
additional context to this configuration prompt. We now distinguish
which indexes need configuration: signals, lists, or both.

* Use latin pluralization consistently

* Rename component file to be more accurate

* Refactor message construction to separate function

* Remove unused translations

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
rylnd and elasticmachine committed Jul 29, 2020
1 parent a0366aa commit 3cc2293
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { alertsHistogramOptions } from '../../components/alerts_histogram_panel/
import { useUserInfo } from '../../components/user_info';
import { EVENTS_VIEWER_HEADER_HEIGHT } from '../../../common/components/events_viewer/events_viewer';
import { OverviewEmpty } from '../../../overview/components/overview_empty';
import { DetectionEngineNoIndex } from './detection_engine_no_signal_index';
import { DetectionEngineNoIndex } from './detection_engine_no_index';
import { DetectionEngineHeaderPage } from '../../components/detection_engine_header_page';
import { useListsConfig } from '../../containers/detection_engine/lists/use_lists_config';
import { DetectionEngineUserUnauthenticated } from './detection_engine_user_unauthenticated';
Expand Down Expand Up @@ -144,7 +144,10 @@ export const DetectionEnginePageComponent: React.FC<PropsFromRedux> = ({
return (
<WrapperPage>
<DetectionEngineHeaderPage border title={i18n.PAGE_TITLE} />
<DetectionEngineNoIndex />
<DetectionEngineNoIndex
needsSignalsIndex={isSignalIndexExists === false}
needsListsIndex={needsListsConfiguration}
/>
</WrapperPage>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import React from 'react';
import { shallow } from 'enzyme';

import { DetectionEngineNoIndex } from './detection_engine_no_signal_index';
import { DetectionEngineNoIndex } from './detection_engine_no_index';
jest.mock('../../../common/lib/kibana');

describe('DetectionEngineNoIndex', () => {
it('renders correctly', () => {
const wrapper = shallow(<DetectionEngineNoIndex />);
const wrapper = shallow(
<DetectionEngineNoIndex needsSignalsIndex={true} needsListsIndex={false} />
);

expect(wrapper.find('EmptyPage')).toHaveLength(1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@ import { EmptyPage } from '../../../common/components/empty_page';
import * as i18n from './translations';
import { useKibana } from '../../../common/lib/kibana';

export const DetectionEngineNoIndex = React.memo(() => {
const buildMessage = (needsListsIndex: boolean, needsSignalsIndex: boolean): string => {
if (needsSignalsIndex && needsListsIndex) {
return i18n.NEEDS_INDEX_PERMISSIONS(i18n.NEEDS_SIGNALS_AND_LISTS_INDEXES);
} else if (needsSignalsIndex) {
return i18n.NEEDS_INDEX_PERMISSIONS(i18n.NEEDS_SIGNALS_INDEX);
} else if (needsListsIndex) {
return i18n.NEEDS_INDEX_PERMISSIONS(i18n.NEEDS_LISTS_INDEXES);
} else {
return i18n.NEEDS_INDEX_PERMISSIONS('');
}
};

const DetectionEngineNoIndexComponent: React.FC<{
needsListsIndex: boolean;
needsSignalsIndex: boolean;
}> = ({ needsListsIndex, needsSignalsIndex }) => {
const docLinks = useKibana().services.docLinks;
const actions = useMemo(
() => ({
Expand All @@ -23,15 +38,16 @@ export const DetectionEngineNoIndex = React.memo(() => {
}),
[docLinks]
);
const message = buildMessage(needsListsIndex, needsSignalsIndex);

return (
<EmptyPage
actions={actions}
message={i18n.NO_INDEX_MSG_BODY}
data-test-subj="no_index"
message={message}
title={i18n.NO_INDEX_TITLE}
/>
);
});
};

DetectionEngineNoIndex.displayName = 'DetectionEngineNoIndex';
export const DetectionEngineNoIndex = React.memo(DetectionEngineNoIndexComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,34 @@ export const NO_INDEX_TITLE = i18n.translate(
}
);

export const NO_INDEX_MSG_BODY = i18n.translate(
'xpack.securitySolution.detectionEngine.noIndexMsgBody',
export const NEEDS_SIGNALS_AND_LISTS_INDEXES = i18n.translate(
'xpack.securitySolution.detectionEngine.needsSignalsAndListsIndexesMessage',
{
defaultMessage:
'To use the detection engine, a user with the required cluster and index privileges must first access this page. For more help, contact your administrator.',
defaultMessage: 'You need permissions for the signals and lists indices.',
}
);

export const NEEDS_SIGNALS_INDEX = i18n.translate(
'xpack.securitySolution.detectionEngine.needsSignalsIndexMessage',
{
defaultMessage: 'You need permissions for the signals index.',
}
);

export const NEEDS_LISTS_INDEXES = i18n.translate(
'xpack.securitySolution.detectionEngine.needsListsIndexesMessage',
{
defaultMessage: 'You need permissions for the lists indices.',
}
);

export const NEEDS_INDEX_PERMISSIONS = (additionalContext: string) =>
i18n.translate('xpack.securitySolution.detectionEngine.needsIndexPermissionsMessage', {
values: { additionalContext },
defaultMessage:
'To use the detection engine, a user with the required cluster and index privileges must first access this page. {additionalContext} For more help, contact your Elastic Stack administrator.',
});

export const GO_TO_DOCUMENTATION = i18n.translate(
'xpack.securitySolution.detectionEngine.goToDocumentationButton',
{
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -13865,7 +13865,6 @@
"xpack.securitySolution.detectionEngine.mlUnavailableTitle": "{totalRules} {totalRules, plural, =1 {個のルール} other {個のルール}}で機械学習を有効にする必要があります。",
"xpack.securitySolution.detectionEngine.noApiIntegrationKeyCallOutMsg": "Kibanaを起動するごとに保存されたオブジェクトの新しい暗号化キーを作成します。永続キーがないと、Kibanaの再起動後にルールを削除または修正することができません。永続キーを設定するには、kibana.ymlファイルに32文字以上のテキスト値を付けてxpack.encryptedSavedObjects.encryptionKey設定を追加してください。",
"xpack.securitySolution.detectionEngine.noApiIntegrationKeyCallOutTitle": "API統合キーが必要です",
"xpack.securitySolution.detectionEngine.noIndexMsgBody": "検出エンジンを使用するには、必要なクラスターとインデックス権限のユーザーが最初にこのページにアクセスする必要があります。ヘルプについては、管理者にお問い合わせください。",
"xpack.securitySolution.detectionEngine.noIndexTitle": "検出エンジンを設定しましょう",
"xpack.securitySolution.detectionEngine.pageTitle": "検出エンジン",
"xpack.securitySolution.detectionEngine.panelSubtitleShowing": "表示中",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -13871,7 +13871,6 @@
"xpack.securitySolution.detectionEngine.mlUnavailableTitle": "{totalRules} 个 {totalRules, plural, =1 {规则需要} other {规则需要}}启用 Machine Learning。",
"xpack.securitySolution.detectionEngine.noApiIntegrationKeyCallOutMsg": "每次启动 Kibana,都会为已保存对象生成新的加密密钥。没有持久性密钥,在 Kibana 重新启动后,将无法删除或修改规则。要设置持久性密钥,请将文本值为 32 个或更多任意字符的 xpack.encryptedSavedObjects.encryptionKey 设置添加到 kibana.yml 文件。",
"xpack.securitySolution.detectionEngine.noApiIntegrationKeyCallOutTitle": "需要 API 集成密钥",
"xpack.securitySolution.detectionEngine.noIndexMsgBody": "要使用检测引擎,具有所需集群和索引权限的用户必须首先访问此页面。若需要更多帮助,请联系您的管理员。",
"xpack.securitySolution.detectionEngine.noIndexTitle": "让我们来设置您的检测引擎",
"xpack.securitySolution.detectionEngine.pageTitle": "检测引擎",
"xpack.securitySolution.detectionEngine.panelSubtitleShowing": "正在显示",
Expand Down

0 comments on commit 3cc2293

Please sign in to comment.