mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Workplace Search] Port RoleMappings changes (#93458)
This PR ports changes from the ent-search RoleMappings to Kibana Reference PR: https://github.com/elastic/ent-search/pull/3148
This commit is contained in:
parent
a3b848a5be
commit
5755d7907c
5 changed files with 3 additions and 38 deletions
|
@ -40,7 +40,7 @@ interface Props {
|
|||
selectedAuthProviders?: string[];
|
||||
availableAuthProviders?: string[];
|
||||
elasticsearchRoles: string[];
|
||||
disabled: boolean;
|
||||
disabled?: boolean;
|
||||
multipleAuthProvidersConfig: boolean;
|
||||
handleAttributeSelectorChange(value: string, elasticsearchRole: string): void;
|
||||
handleAttributeValueChange(value: string): void;
|
||||
|
|
|
@ -9,7 +9,7 @@ import React from 'react';
|
|||
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { EuiRadio, EuiCallOut } from '@elastic/eui';
|
||||
import { EuiRadio } from '@elastic/eui';
|
||||
|
||||
import { RoleSelector } from './role_selector';
|
||||
|
||||
|
@ -41,9 +41,7 @@ describe('RoleSelector', () => {
|
|||
|
||||
it('renders callout when disabled', () => {
|
||||
const wrapper = shallow(<RoleSelector {...props} disabled />);
|
||||
const radio = wrapper.find(EuiRadio);
|
||||
|
||||
expect(radio.dive().find(EuiCallOut)).toHaveLength(1);
|
||||
expect(wrapper.find(EuiRadio).prop('checked')).toEqual(false);
|
||||
});
|
||||
|
||||
|
|
|
@ -9,15 +9,7 @@ import React from 'react';
|
|||
|
||||
import { startCase } from 'lodash';
|
||||
|
||||
import {
|
||||
EuiCallOut,
|
||||
EuiFormRow,
|
||||
EuiRadio,
|
||||
EuiSpacer,
|
||||
EuiText,
|
||||
EuiTextColor,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
import { EuiFormRow, EuiRadio, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui';
|
||||
|
||||
interface Props {
|
||||
disabled?: boolean;
|
||||
|
@ -30,7 +22,6 @@ interface Props {
|
|||
|
||||
export const RoleSelector: React.FC<Props> = ({
|
||||
disabled,
|
||||
disabledText,
|
||||
roleType,
|
||||
roleTypeOption,
|
||||
description,
|
||||
|
@ -49,13 +40,6 @@ export const RoleSelector: React.FC<Props> = ({
|
|||
<EuiTitle size="xs">
|
||||
<h4 className="usersLayout__users--roletype">{startCase(roleTypeOption)}</h4>
|
||||
</EuiTitle>
|
||||
{disabled && disabledText && (
|
||||
<EuiCallOut
|
||||
size="s"
|
||||
title={<EuiTextColor color="subdued">{disabledText}</EuiTextColor>}
|
||||
iconType="alert"
|
||||
/>
|
||||
)}
|
||||
<EuiSpacer size="xs" />
|
||||
<EuiText size="s">
|
||||
<p>{description}</p>
|
||||
|
|
|
@ -38,14 +38,6 @@ export const USER_ROLE_TYPE_DESCRIPTION = i18n.translate(
|
|||
}
|
||||
);
|
||||
|
||||
export const ROLE_SELECTOR_DISABLED_TEXT = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.roleMapping.roleSelectorDisabledText',
|
||||
{
|
||||
defaultMessage:
|
||||
'You need at least one admin role mapping before you can create a user role mapping.',
|
||||
}
|
||||
);
|
||||
|
||||
export const GROUP_ASSIGNMENT_TITLE = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.roleMapping.groupAssignmentTitle',
|
||||
{
|
||||
|
|
|
@ -37,7 +37,6 @@ import { Role } from '../../types';
|
|||
import {
|
||||
ADMIN_ROLE_TYPE_DESCRIPTION,
|
||||
USER_ROLE_TYPE_DESCRIPTION,
|
||||
ROLE_SELECTOR_DISABLED_TEXT,
|
||||
GROUP_ASSIGNMENT_TITLE,
|
||||
GROUP_ASSIGNMENT_INVALID_ERROR,
|
||||
GROUP_ASSIGNMENT_ALL_GROUPS_LABEL,
|
||||
|
@ -86,7 +85,6 @@ export const RoleMapping: React.FC<RoleMappingProps> = ({ isNew }) => {
|
|||
elasticsearchRoles,
|
||||
dataLoading,
|
||||
roleType,
|
||||
roleMappings,
|
||||
attributeValue,
|
||||
attributeName,
|
||||
availableGroups,
|
||||
|
@ -121,11 +119,6 @@ export const RoleMapping: React.FC<RoleMappingProps> = ({ isNew }) => {
|
|||
</EuiButton>
|
||||
);
|
||||
|
||||
const hasAdminRoleMapping = roleMappings.some(
|
||||
({ roleType: roleMappingRoleType }: { roleType: string }) =>
|
||||
roleMappingRoleType === ('admin' as string)
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ViewContentHeader title={SAVE_ROLE_MAPPING_LABEL} action={saveRoleMappingButton} />
|
||||
|
@ -160,8 +153,6 @@ export const RoleMapping: React.FC<RoleMappingProps> = ({ isNew }) => {
|
|||
onChange={handleRoleChange}
|
||||
roleTypeOption={type}
|
||||
description={description}
|
||||
disabled={!(type === 'admin' || hasAdminRoleMapping)}
|
||||
disabledText={ROLE_SELECTOR_DISABLED_TEXT}
|
||||
/>
|
||||
))}
|
||||
</EuiPanel>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue