mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Extract Kibana Privilege Feature table into package (#189871)
## Summary This PR extracts the kibana privilege component into a package, to support the work that's been done to integrate role privilege selection within the newly improved spaces administration app, and is the last in the series of PR to make this possible. Without this undertaken we would be creating cyclic dependency between the security and spaces plugin, the image below provides a visual representation on how this PR resolves the aforementioned issue; [^legend] [^legend]: item marked in blue is the package created in this PR. This particular component, alongside the components that it's composed of will now be housed in `@kbn/security-ui-components` (P.S. I'm not too entirely sure about the naming, suggestions welcome). <!-- ### Checklist Delete any items that are not applicable to this PR. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### Risk Matrix Delete this section if it is not applicable to this PR. Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release. When forming the risk matrix, consider some of the following examples and how they may potentially impact the change: | Risk | Probability | Severity | Mitigation/Notes | |---------------------------|-------------|----------|-------------------------| | Multiple Spaces—unexpected behavior in non-default Kibana Space. | Low | High | Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces. | | Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. | High | Low | Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure. | | Code should gracefully handle cases when feature X or plugin Y are disabled. | Medium | High | Unit tests will verify that any feature flag or plugin combination still results in our service operational. | | [See more potential risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) | ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d3a9d48437
commit
fd312e30db
41 changed files with 116 additions and 39 deletions
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -774,6 +774,7 @@ x-pack/packages/security-solution/side_nav @elastic/security-threat-hunting-expl
|
|||
x-pack/packages/security-solution/storybook/config @elastic/security-threat-hunting-explore
|
||||
x-pack/packages/security-solution/upselling @elastic/security-threat-hunting-explore
|
||||
x-pack/test/security_functional/plugins/test_endpoints @elastic/kibana-security
|
||||
x-pack/packages/security/ui_components @elastic/kibana-security
|
||||
packages/kbn-securitysolution-autocomplete @elastic/security-detection-engine
|
||||
x-pack/packages/security-solution/data_table @elastic/security-threat-hunting-investigations
|
||||
packages/kbn-securitysolution-ecs @elastic/security-threat-hunting-explore
|
||||
|
|
|
@ -790,6 +790,7 @@
|
|||
"@kbn/security-solution-storybook-config": "link:x-pack/packages/security-solution/storybook/config",
|
||||
"@kbn/security-solution-upselling": "link:x-pack/packages/security-solution/upselling",
|
||||
"@kbn/security-test-endpoints-plugin": "link:x-pack/test/security_functional/plugins/test_endpoints",
|
||||
"@kbn/security-ui-components": "link:x-pack/packages/security/ui_components",
|
||||
"@kbn/securitysolution-autocomplete": "link:packages/kbn-securitysolution-autocomplete",
|
||||
"@kbn/securitysolution-data-table": "link:x-pack/packages/security-solution/data_table",
|
||||
"@kbn/securitysolution-ecs": "link:packages/kbn-securitysolution-ecs",
|
||||
|
|
|
@ -1542,6 +1542,8 @@
|
|||
"@kbn/security-solution-upselling/*": ["x-pack/packages/security-solution/upselling/*"],
|
||||
"@kbn/security-test-endpoints-plugin": ["x-pack/test/security_functional/plugins/test_endpoints"],
|
||||
"@kbn/security-test-endpoints-plugin/*": ["x-pack/test/security_functional/plugins/test_endpoints/*"],
|
||||
"@kbn/security-ui-components": ["x-pack/packages/security/ui_components"],
|
||||
"@kbn/security-ui-components/*": ["x-pack/packages/security/ui_components/*"],
|
||||
"@kbn/securitysolution-autocomplete": ["packages/kbn-securitysolution-autocomplete"],
|
||||
"@kbn/securitysolution-autocomplete/*": ["packages/kbn-securitysolution-autocomplete/*"],
|
||||
"@kbn/securitysolution-data-table": ["x-pack/packages/security-solution/data_table"],
|
||||
|
|
3
x-pack/packages/security/ui_components/README.md
Normal file
3
x-pack/packages/security/ui_components/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# @kbn/security-ui-components
|
||||
|
||||
Contains stateless components for RBAC administration within Kibana.
|
13
x-pack/packages/security/ui_components/index.ts
Normal file
13
x-pack/packages/security/ui_components/index.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export {
|
||||
FeatureTable as KibanaPrivilegeTable,
|
||||
FeatureTableCell,
|
||||
} from './src/kibana_privilege_table';
|
||||
export { PrivilegeFormCalculator } from './src/privilege_form_calculator';
|
||||
export * as constants from './src/constants';
|
15
x-pack/packages/security/ui_components/jest.config.js
Normal file
15
x-pack/packages/security/ui_components/jest.config.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/x-pack/packages/security/ui_components',
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: ['<rootDir>/x-pack/packages/security/ui_components/**/*.{ts,tsx}'],
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../..',
|
||||
roots: ['<rootDir>/x-pack/packages/security/ui_components'],
|
||||
};
|
5
x-pack/packages/security/ui_components/kibana.jsonc
Normal file
5
x-pack/packages/security/ui_components/kibana.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type": "shared-common",
|
||||
"id": "@kbn/security-ui-components",
|
||||
"owner": "@elastic/kibana-security"
|
||||
}
|
6
x-pack/packages/security/ui_components/package.json
Normal file
6
x-pack/packages/security/ui_components/package.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "@kbn/security-ui-components",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"license": "Elastic License 2.0"
|
||||
}
|
|
@ -18,7 +18,7 @@ import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers';
|
|||
|
||||
import { getDisplayedFeaturePrivileges } from './__fixtures__';
|
||||
import { FeatureTable } from './feature_table';
|
||||
import type { Role } from '../../../../../../../common';
|
||||
import type { Role } from '@kbn/security-plugin-types-common';
|
||||
import { PrivilegeFormCalculator } from '../privilege_form_calculator';
|
||||
|
||||
const createRole = (kibana: Role['kibana'] = []): Role => {
|
|
@ -35,7 +35,7 @@ import type { KibanaPrivileges, SecuredFeature } from '@kbn/security-role-manage
|
|||
import { ChangeAllPrivilegesControl } from './change_all_privileges';
|
||||
import { FeatureTableExpandedRow } from './feature_table_expanded_row';
|
||||
import { NO_PRIVILEGE_VALUE } from '../constants';
|
||||
import { FeatureTableCell } from '../feature_table_cell';
|
||||
import { FeatureTableCell } from './components/feature_table_cell';
|
||||
import type { PrivilegeFormCalculator } from '../privilege_form_calculator';
|
||||
|
||||
interface Props {
|
|
@ -15,7 +15,7 @@ import {
|
|||
import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers';
|
||||
|
||||
import { FeatureTableExpandedRow } from './feature_table_expanded_row';
|
||||
import type { Role } from '../../../../../../../common';
|
||||
import type { Role } from '@kbn/security-plugin-types-common';
|
||||
import { PrivilegeFormCalculator } from '../privilege_form_calculator';
|
||||
|
||||
const createRole = (kibana: Role['kibana'] = []): Role => {
|
|
@ -6,3 +6,4 @@
|
|||
*/
|
||||
|
||||
export { FeatureTable } from './feature_table';
|
||||
export { FeatureTableCell } from './components';
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from '@kbn/security-role-management-model/src/__fixtures__';
|
||||
|
||||
import { PrivilegeFormCalculator } from './privilege_form_calculator';
|
||||
import type { Role } from '../../../../../../../common';
|
||||
import type { Role } from '@kbn/security-plugin-types-common';
|
||||
|
||||
const createRole = (kibana: Role['kibana'] = []): Role => {
|
||||
return {
|
18
x-pack/packages/security/ui_components/tsconfig.json
Normal file
18
x-pack/packages/security/ui_components/tsconfig.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "target/types",
|
||||
"types": ["jest", "node", "react"]
|
||||
},
|
||||
"include": ["**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["target/**/*"],
|
||||
"kbn_references": [
|
||||
"@kbn/core",
|
||||
"@kbn/i18n",
|
||||
"@kbn/i18n-react",
|
||||
"@kbn/security-plugin-types-common",
|
||||
"@kbn/test-jest-helpers",
|
||||
"@kbn/security-role-management-model",
|
||||
"@kbn/features-plugin",
|
||||
]
|
||||
}
|
|
@ -775,7 +775,9 @@ export const EditRolePage: FunctionComponent<Props> = ({
|
|||
<EuiFlexGroup justifyContent="flexEnd" gutterSize="s">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiButton size="s" href={cloudOrgUrl}>
|
||||
Manage Members
|
||||
{i18n.translate('xpack.security.management.roles.manageRoleUsers', {
|
||||
defaultMessage: 'Manage Members',
|
||||
})}
|
||||
</EuiButton>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
import { EuiTableRow } from '@elastic/eui';
|
||||
import type { ReactWrapper } from 'enzyme';
|
||||
|
||||
import { FeatureTableCell } from '@kbn/security-ui-components';
|
||||
import { findTestSubject } from '@kbn/test-jest-helpers';
|
||||
|
||||
import type { Role, RoleKibanaPrivilege } from '../../../../../../../../common';
|
||||
import { FeatureTableCell } from '../../feature_table_cell';
|
||||
import { PrivilegeSummaryExpandedRow } from '../privilege_summary_expanded_row';
|
||||
|
||||
interface DisplayedFeaturePrivileges {
|
||||
|
|
|
@ -27,6 +27,7 @@ import {
|
|||
type PrimaryFeaturePrivilege,
|
||||
type SecuredFeature,
|
||||
} from '@kbn/security-role-management-model';
|
||||
import { FeatureTableCell } from '@kbn/security-ui-components';
|
||||
import type { Space, SpacesApiUi } from '@kbn/spaces-plugin/public';
|
||||
|
||||
import type { EffectiveFeaturePrivileges } from './privilege_summary_calculator';
|
||||
|
@ -34,7 +35,6 @@ import { PrivilegeSummaryCalculator } from './privilege_summary_calculator';
|
|||
import { PrivilegeSummaryExpandedRow } from './privilege_summary_expanded_row';
|
||||
import { SpaceColumnHeader } from './space_column_header';
|
||||
import { ALL_SPACES_ID } from '../../../../../../../common/constants';
|
||||
import { FeatureTableCell } from '../feature_table_cell';
|
||||
|
||||
export interface PrivilegeSummaryTableProps {
|
||||
role: Role;
|
||||
|
|
|
@ -9,7 +9,7 @@ import { EuiSelect } from '@elastic/eui';
|
|||
import type { ChangeEvent } from 'react';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { NO_PRIVILEGE_VALUE } from '../constants';
|
||||
import { constants } from '@kbn/security-ui-components';
|
||||
|
||||
interface Props {
|
||||
['data-test-subj']: string;
|
||||
|
@ -27,10 +27,10 @@ export class PrivilegeSelector extends Component<Props, {}> {
|
|||
public render() {
|
||||
const { availablePrivileges, value, disabled, allowNone, compressed } = this.props;
|
||||
|
||||
const options = [];
|
||||
const options: Array<{ value: string; text: string }> = [];
|
||||
|
||||
if (allowNone) {
|
||||
options.push({ value: NO_PRIVILEGE_VALUE, text: 'none' });
|
||||
options.push({ value: constants.NO_PRIVILEGE_VALUE, text: 'none' });
|
||||
}
|
||||
|
||||
options.push(
|
||||
|
|
|
@ -16,17 +16,19 @@ import {
|
|||
import React, { Component, Fragment } from 'react';
|
||||
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { Role, RoleKibanaPrivilege } from '@kbn/security-plugin-types-common';
|
||||
import {
|
||||
isGlobalPrivilegeDefinition,
|
||||
type KibanaPrivileges,
|
||||
} from '@kbn/security-role-management-model';
|
||||
import {
|
||||
constants,
|
||||
KibanaPrivilegeTable,
|
||||
PrivilegeFormCalculator,
|
||||
} from '@kbn/security-ui-components';
|
||||
|
||||
import { UnsupportedSpacePrivilegesWarning } from './unsupported_space_privileges_warning';
|
||||
import type { Role, RoleKibanaPrivilege } from '../../../../../../../common';
|
||||
import { copyRole } from '../../../../../../../common/model';
|
||||
import { CUSTOM_PRIVILEGE_VALUE, NO_PRIVILEGE_VALUE } from '../constants';
|
||||
import { FeatureTable } from '../feature_table';
|
||||
import { PrivilegeFormCalculator } from '../privilege_form_calculator';
|
||||
|
||||
interface Props {
|
||||
role: Role;
|
||||
|
@ -98,7 +100,7 @@ export class SimplePrivilegeSection extends Component<Props, State> {
|
|||
onChange={this.onKibanaPrivilegeChange}
|
||||
options={[
|
||||
{
|
||||
value: NO_PRIVILEGE_VALUE,
|
||||
value: constants.NO_PRIVILEGE_VALUE,
|
||||
inputDisplay: (
|
||||
<FormattedMessage
|
||||
id="xpack.security.management.editRole.simplePrivilegeForm.noPrivilegeInput"
|
||||
|
@ -179,7 +181,7 @@ export class SimplePrivilegeSection extends Component<Props, State> {
|
|||
),
|
||||
},
|
||||
{
|
||||
value: CUSTOM_PRIVILEGE_VALUE,
|
||||
value: constants.CUSTOM_PRIVILEGE_VALUE,
|
||||
inputDisplay: (
|
||||
<FormattedMessage
|
||||
id="xpack.security.management.editRole.simplePrivilegeForm.customPrivilegeInput"
|
||||
|
@ -213,7 +215,7 @@ export class SimplePrivilegeSection extends Component<Props, State> {
|
|||
</EuiFormRow>
|
||||
{this.state.isCustomizingGlobalPrivilege && (
|
||||
<EuiFormRow fullWidth>
|
||||
<FeatureTable
|
||||
<KibanaPrivilegeTable
|
||||
role={this.props.role}
|
||||
kibanaPrivileges={this.props.kibanaPrivileges}
|
||||
privilegeCalculator={
|
||||
|
@ -239,14 +241,14 @@ export class SimplePrivilegeSection extends Component<Props, State> {
|
|||
|
||||
public getDisplayedBasePrivilege = () => {
|
||||
if (this.state.isCustomizingGlobalPrivilege) {
|
||||
return CUSTOM_PRIVILEGE_VALUE;
|
||||
return constants.CUSTOM_PRIVILEGE_VALUE;
|
||||
}
|
||||
|
||||
const { role } = this.props;
|
||||
|
||||
const form = this.locateGlobalPrivilege(role);
|
||||
|
||||
return form && form.base.length > 0 ? form.base[0] : NO_PRIVILEGE_VALUE;
|
||||
return form && form.base.length > 0 ? form.base[0] : constants.NO_PRIVILEGE_VALUE;
|
||||
};
|
||||
|
||||
public onKibanaPrivilegeChange = (privilege: string) => {
|
||||
|
@ -254,10 +256,10 @@ export class SimplePrivilegeSection extends Component<Props, State> {
|
|||
|
||||
const form = this.locateGlobalPrivilege(role) || this.createGlobalPrivilegeEntry(role);
|
||||
|
||||
if (privilege === NO_PRIVILEGE_VALUE) {
|
||||
if (privilege === constants.NO_PRIVILEGE_VALUE) {
|
||||
// Remove global entry if no privilege value
|
||||
role.kibana = role.kibana.filter((entry) => !isGlobalPrivilegeDefinition(entry));
|
||||
} else if (privilege === CUSTOM_PRIVILEGE_VALUE) {
|
||||
} else if (privilege === constants.CUSTOM_PRIVILEGE_VALUE) {
|
||||
// Remove base privilege if customizing feature privileges
|
||||
form.base = [];
|
||||
} else {
|
||||
|
@ -267,7 +269,7 @@ export class SimplePrivilegeSection extends Component<Props, State> {
|
|||
|
||||
this.props.onChange(role);
|
||||
this.setState({
|
||||
isCustomizingGlobalPrivilege: privilege === CUSTOM_PRIVILEGE_VALUE,
|
||||
isCustomizingGlobalPrivilege: privilege === constants.CUSTOM_PRIVILEGE_VALUE,
|
||||
globalPrivsIndex: role.kibana.indexOf(form),
|
||||
});
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ import _ from 'lodash';
|
|||
import type { FC, ReactNode } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import { NO_PRIVILEGE_VALUE } from '../constants';
|
||||
import { constants } from '@kbn/security-ui-components';
|
||||
|
||||
interface Props extends PropsOf<typeof EuiText> {
|
||||
privilege: string | string[] | undefined;
|
||||
|
@ -40,7 +40,8 @@ function getDisplayValue(privilege: string | string[] | undefined) {
|
|||
let displayValue: string | ReactNode;
|
||||
|
||||
const isPrivilegeMissing =
|
||||
privileges.length === 0 || (privileges.length === 1 && privileges.includes(NO_PRIVILEGE_VALUE));
|
||||
privileges.length === 0 ||
|
||||
(privileges.length === 1 && privileges.includes(constants.NO_PRIVILEGE_VALUE));
|
||||
|
||||
if (isPrivilegeMissing) {
|
||||
displayValue = <EuiIcon color="subdued" type={'minusInCircle'} />;
|
||||
|
|
|
@ -13,14 +13,14 @@ import {
|
|||
createKibanaPrivileges,
|
||||
kibanaFeatures,
|
||||
} from '@kbn/security-role-management-model/src/__fixtures__';
|
||||
import { KibanaPrivilegeTable as FeatureTable } from '@kbn/security-ui-components';
|
||||
import { getDisplayedFeaturePrivileges } from '@kbn/security-ui-components/src/kibana_privilege_table/__fixtures__';
|
||||
import type { Space } from '@kbn/spaces-plugin/public';
|
||||
import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers';
|
||||
|
||||
import { PrivilegeSpaceForm } from './privilege_space_form';
|
||||
import { SpaceSelector } from './space_selector';
|
||||
import type { Role } from '../../../../../../../common';
|
||||
import { FeatureTable } from '../feature_table';
|
||||
import { getDisplayedFeaturePrivileges } from '../feature_table/__fixtures__';
|
||||
|
||||
const createRole = (kibana: Role['kibana'] = []): Role => {
|
||||
return {
|
||||
|
|
|
@ -30,15 +30,17 @@ import React, { Component, Fragment } from 'react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { KibanaPrivileges } from '@kbn/security-role-management-model';
|
||||
import {
|
||||
KibanaPrivilegeTable,
|
||||
PrivilegeFormCalculator,
|
||||
constants as UI_CONSTANTS,
|
||||
} from '@kbn/security-ui-components';
|
||||
import type { Space } from '@kbn/spaces-plugin/public';
|
||||
|
||||
import { SpaceSelector } from './space_selector';
|
||||
import type { FeaturesPrivileges, Role } from '../../../../../../../common';
|
||||
import { ALL_SPACES_ID } from '../../../../../../../common/constants';
|
||||
import { copyRole } from '../../../../../../../common/model';
|
||||
import { CUSTOM_PRIVILEGE_VALUE } from '../constants';
|
||||
import { FeatureTable } from '../feature_table';
|
||||
import { PrivilegeFormCalculator } from '../privilege_form_calculator';
|
||||
|
||||
interface Props {
|
||||
role: Role;
|
||||
|
@ -254,7 +256,7 @@ export class PrivilegeSpaceForm extends Component<Props, State> {
|
|||
|
||||
<EuiSpacer size="l" />
|
||||
|
||||
<FeatureTable
|
||||
<KibanaPrivilegeTable
|
||||
role={this.state.role}
|
||||
privilegeCalculator={this.state.privilegeCalculator}
|
||||
onChange={this.onFeaturePrivilegesChange}
|
||||
|
@ -447,7 +449,7 @@ export class PrivilegeSpaceForm extends Component<Props, State> {
|
|||
|
||||
let isCustomizingFeaturePrivileges = false;
|
||||
|
||||
if (privilegeName === CUSTOM_PRIVILEGE_VALUE) {
|
||||
if (privilegeName === UI_CONSTANTS.CUSTOM_PRIVILEGE_VALUE) {
|
||||
form.base = [];
|
||||
isCustomizingFeaturePrivileges = true;
|
||||
} else {
|
||||
|
@ -456,7 +458,8 @@ export class PrivilegeSpaceForm extends Component<Props, State> {
|
|||
}
|
||||
|
||||
this.setState({
|
||||
selectedBasePrivilege: privilegeName === CUSTOM_PRIVILEGE_VALUE ? [] : [privilegeName],
|
||||
selectedBasePrivilege:
|
||||
privilegeName === UI_CONSTANTS.CUSTOM_PRIVILEGE_VALUE ? [] : [privilegeName],
|
||||
role,
|
||||
isCustomizingFeaturePrivileges,
|
||||
privilegeCalculator: new PrivilegeFormCalculator(this.props.kibanaPrivileges, role),
|
||||
|
@ -507,7 +510,7 @@ export class PrivilegeSpaceForm extends Component<Props, State> {
|
|||
return `basePrivilege_${basePrivilege.id}`;
|
||||
}
|
||||
|
||||
return `basePrivilege_${CUSTOM_PRIVILEGE_VALUE}`;
|
||||
return `basePrivilege_${UI_CONSTANTS.CUSTOM_PRIVILEGE_VALUE}`;
|
||||
};
|
||||
|
||||
private onFeaturePrivilegesChange = (featureId: string, privileges: string[]) => {
|
||||
|
|
|
@ -12,11 +12,11 @@ import React from 'react';
|
|||
import { KibanaFeature } from '@kbn/features-plugin/public';
|
||||
import type { Role, RoleKibanaPrivilege } from '@kbn/security-plugin-types-common';
|
||||
import { createKibanaPrivileges } from '@kbn/security-role-management-model/src/__fixtures__';
|
||||
import { PrivilegeFormCalculator } from '@kbn/security-ui-components';
|
||||
import { findTestSubject, mountWithIntl } from '@kbn/test-jest-helpers';
|
||||
|
||||
import { PrivilegeDisplay } from './privilege_display';
|
||||
import { PrivilegeSpaceTable } from './privilege_space_table';
|
||||
import { PrivilegeFormCalculator } from '../privilege_form_calculator';
|
||||
|
||||
interface TableRow {
|
||||
spaces: string[];
|
||||
|
|
|
@ -24,13 +24,12 @@ import { i18n } from '@kbn/i18n';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { FeaturesPrivileges, Role } from '@kbn/security-plugin-types-common';
|
||||
import { isGlobalPrivilegeDefinition } from '@kbn/security-role-management-model';
|
||||
import { constants, type PrivilegeFormCalculator } from '@kbn/security-ui-components';
|
||||
import type { Space } from '@kbn/spaces-plugin/public';
|
||||
import { getSpaceColor } from '@kbn/spaces-plugin/public';
|
||||
|
||||
import { PrivilegeDisplay } from './privilege_display';
|
||||
import { copyRole } from '../../../../../../../common/model';
|
||||
import { CUSTOM_PRIVILEGE_VALUE } from '../constants';
|
||||
import type { PrivilegeFormCalculator } from '../privilege_form_calculator';
|
||||
|
||||
const SPACES_DISPLAY_COUNT = 4;
|
||||
|
||||
|
@ -120,7 +119,7 @@ export class PrivilegeSpaceTable extends Component<Props, State> {
|
|||
const isExpanded = this.state.expandedSpacesGroups.includes(record.privilegeIndex);
|
||||
const displayedSpaces = isExpanded ? spaces : spaces.slice(0, SPACES_DISPLAY_COUNT);
|
||||
|
||||
let button = null;
|
||||
let button: React.ReactElement | null = null;
|
||||
if (spaces.length > displayedSpaces.length) {
|
||||
button = (
|
||||
<EuiButtonEmpty
|
||||
|
@ -182,7 +181,7 @@ export class PrivilegeSpaceTable extends Component<Props, State> {
|
|||
|
||||
const basePrivilege =
|
||||
privilegeCalculator.getBasePrivilege(record.privilegeIndex)?.id ??
|
||||
CUSTOM_PRIVILEGE_VALUE;
|
||||
constants.CUSTOM_PRIVILEGE_VALUE;
|
||||
|
||||
const privilege = privilegeCalculator.isWildcardBasePrivilege(record.privilegeIndex)
|
||||
? '*'
|
||||
|
|
|
@ -22,13 +22,13 @@ import { i18n } from '@kbn/i18n';
|
|||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import type { Role } from '@kbn/security-plugin-types-common';
|
||||
import type { KibanaPrivileges } from '@kbn/security-role-management-model';
|
||||
import { PrivilegeFormCalculator } from '@kbn/security-ui-components';
|
||||
import type { Space, SpacesApiUi } from '@kbn/spaces-plugin/public';
|
||||
|
||||
import { PrivilegeSpaceForm } from './privilege_space_form';
|
||||
import { PrivilegeSpaceTable } from './privilege_space_table';
|
||||
import { isRoleReserved, isRoleWithWildcardBasePrivilege } from '../../../../../../../common';
|
||||
import type { RoleValidator } from '../../../validate_role';
|
||||
import { PrivilegeFormCalculator } from '../privilege_form_calculator';
|
||||
import { PrivilegeSummary } from '../privilege_summary';
|
||||
|
||||
interface Props {
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
"@kbn/core-security-server-mocks",
|
||||
"@kbn/security-authorization-core",
|
||||
"@kbn/security-role-management-model",
|
||||
"@kbn/security-ui-components",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -6339,6 +6339,10 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/security-ui-components@link:x-pack/packages/security/ui_components":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@kbn/securitysolution-autocomplete@link:packages/kbn-securitysolution-autocomplete":
|
||||
version "0.0.0"
|
||||
uid ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue