[Enterprise Search] Warn about Kibana access when adding single user role mappings (#114567)

* Warn about Kibana access when adding single user role mappings to Enterprise Search

* i18n and sentence case for the Kibana access warning title
This commit is contained in:
James Rucker 2021-10-11 17:08:49 -07:00 committed by GitHub
parent 8e72e17648
commit 6cb91c472d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 118 additions and 3 deletions

View file

@ -69,6 +69,7 @@ export const User: React.FC = () => {
username={singleUserRoleMapping.elasticsearchUser.username}
email={singleUserRoleMapping.elasticsearchUser.email as string}
roleType={singleUserRoleMapping.roleMapping.roleType}
showKibanaAccessWarning={!singleUserRoleMapping.hasEnterpriseSearchRole}
/>
);

View file

@ -448,3 +448,25 @@ export const SMTP_CALLOUT_LABEL = i18n.translate(
export const SMTP_LINK_LABEL = i18n.translate('xpack.enterpriseSearch.roleMapping.smtpLinkLabel', {
defaultMessage: 'SMTP configuration is provided',
});
export const KIBANA_ACCESS_WARNING_TITLE = i18n.translate(
'xpack.enterpriseSearch.roleMapping.kibanaAccessWarningTitle',
{
defaultMessage: 'Kibana access warning',
}
);
export const KIBANA_ACCESS_WARNING_ERROR_MESSAGE = i18n.translate(
'xpack.enterpriseSearch.roleMapping.kibanaAccessWarningErrorMessage',
{
defaultMessage:
'This Elasticsearch user does not have an Enterprise Search role in Elasticsearch. They may not have access to Kibana.',
}
);
export const KIBANA_ACCESS_WARNING_DESCRIPTION = i18n.translate(
'xpack.enterpriseSearch.roleMapping.kibanaAccessWarningDescription',
{
defaultMessage: 'Consider giving them the "enterprise-search-user" role.',
}
);

View file

@ -16,6 +16,7 @@ describe('UserAddedInfo', () => {
username: 'user1',
email: 'test@test.com',
roleType: 'user',
showKibanaAccessWarning: false,
};
it('renders with email', () => {
@ -117,4 +118,70 @@ describe('UserAddedInfo', () => {
</Fragment>
`);
});
it('renders with the Kibana access warning', () => {
const wrapper = shallow(<UserAddedInfo {...props} showKibanaAccessWarning />);
expect(wrapper).toMatchInlineSnapshot(`
<Fragment>
<EuiCallOut
color="warning"
iconType="help"
title="Kibana access warning"
>
<EuiText
size="s"
>
This Elasticsearch user does not have an Enterprise Search role in Elasticsearch. They may not have access to Kibana.
</EuiText>
<EuiSpacer />
<EuiText
size="s"
>
Consider giving them the "enterprise-search-user" role.
</EuiText>
</EuiCallOut>
<EuiSpacer />
<EuiText
size="s"
>
<strong>
Username
</strong>
</EuiText>
<EuiText
size="s"
>
user1
</EuiText>
<EuiSpacer />
<EuiText
size="s"
>
<strong>
Email
</strong>
</EuiText>
<EuiText
size="s"
>
test@test.com
</EuiText>
<EuiSpacer />
<EuiText
size="s"
>
<strong>
Role
</strong>
</EuiText>
<EuiText
size="s"
>
user
</EuiText>
<EuiSpacer />
</Fragment>
`);
});
});

View file

@ -7,22 +7,45 @@
import React from 'react';
import { EuiSpacer, EuiText, EuiTextColor } from '@elastic/eui';
import { EuiCallOut, EuiSpacer, EuiText, EuiTextColor } from '@elastic/eui';
import { USERNAME_LABEL, EMAIL_LABEL } from '../constants';
import { ROLE_LABEL } from './constants';
import {
KIBANA_ACCESS_WARNING_TITLE,
KIBANA_ACCESS_WARNING_DESCRIPTION,
KIBANA_ACCESS_WARNING_ERROR_MESSAGE,
ROLE_LABEL,
} from './constants';
interface Props {
username: string;
email: string;
roleType: string;
showKibanaAccessWarning: boolean;
}
const kibanaAccessWarning = (
<>
<EuiCallOut title={KIBANA_ACCESS_WARNING_TITLE} color="warning" iconType="help">
<EuiText size="s">{KIBANA_ACCESS_WARNING_ERROR_MESSAGE}</EuiText>
<EuiSpacer />
<EuiText size="s">{KIBANA_ACCESS_WARNING_DESCRIPTION}</EuiText>
</EuiCallOut>
<EuiSpacer />
</>
);
const noItemsPlaceholder = <EuiTextColor color="subdued">&mdash;</EuiTextColor>;
export const UserAddedInfo: React.FC<Props> = ({ username, email, roleType }) => (
export const UserAddedInfo: React.FC<Props> = ({
username,
email,
roleType,
showKibanaAccessWarning,
}) => (
<>
{showKibanaAccessWarning && kibanaAccessWarning}
<EuiText size="s">
<strong>{USERNAME_LABEL}</strong>
</EuiText>

View file

@ -55,4 +55,5 @@ export interface SingleUserRoleMapping<T> {
invitation: Invitation | null;
elasticsearchUser: ElasticsearchUser;
roleMapping: T;
hasEnterpriseSearchRole?: boolean;
}

View file

@ -66,6 +66,7 @@ export const User: React.FC = () => {
username={singleUserRoleMapping.elasticsearchUser.username}
email={singleUserRoleMapping.elasticsearchUser.email as string}
roleType={singleUserRoleMapping.roleMapping.roleType}
showKibanaAccessWarning={!singleUserRoleMapping.hasEnterpriseSearchRole}
/>
);