Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spaces UI] Role Editor Flyout Should Match in Roles Mgmt #198182

Merged
merged 31 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
da90427
Update size of info callout above button group to small for consistency
tsullivan Nov 1, 2024
5d16629
Update button group label text to consistent, simpler version
tsullivan Nov 1, 2024
6727c66
Remove descriptions under headers
tsullivan Nov 1, 2024
21072b8
Align headers for assign/edit states
tsullivan Nov 1, 2024
aef52b8
Align info callout text
tsullivan Nov 1, 2024
bc575a6
Align helper texts
tsullivan Nov 1, 2024
ef11ba1
update button text to make more descriptive
tsullivan Nov 1, 2024
bae8163
Hide privileges controls if no spaces are selected
tsullivan Nov 1, 2024
1a83565
update placeholders for selector box when assigning privileges
tsullivan Nov 6, 2024
398f99d
set "Customize" as the default selected option when assigning new pri…
tsullivan Nov 6, 2024
5fdde38
Unify the info callouts regarding combination of privileges
tsullivan Nov 7, 2024
3b3b5da
Remove the warning callout regarding global privileges that impact ot…
tsullivan Nov 7, 2024
537a84b
fix functional a11y test
tsullivan Nov 8, 2024
3a4cd52
fix i18n
tsullivan Nov 11, 2024
3e77b8f
Remove features visible column
tsullivan Oct 25, 2024
d17b09f
fix vertical alignment of non-current space name in table
tsullivan Oct 25, 2024
2485b4d
update column widths
tsullivan Oct 25, 2024
15d5318
fix unit test
tsullivan Oct 31, 2024
c0f6678
Removing a role from the space shows a confirmation modal
tsullivan Nov 1, 2024
242a331
Ordered the listing of assigned roles during and after search
tsullivan Nov 1, 2024
8774335
Fix kibana package type for ui-component package
tsullivan Nov 1, 2024
d646de1
fix i18n
tsullivan Nov 12, 2024
7ee2813
fix jest test
tsullivan Nov 12, 2024
fedbc20
Remove 'Additional Stack Managemetn permissions...' callout from Spac…
tsullivan Nov 13, 2024
992d791
Remove the 'By default your current view...' callout
tsullivan Nov 13, 2024
d6ebf47
Reduce text size for "Manage roles" link
tsullivan Nov 13, 2024
6a51ea4
Merge branch 'main' into spaces/spaces-grid-fixes-iii
tsullivan Nov 14, 2024
ad882f6
Merge branch 'main' into spaces/spaces-grid-fixes-iii
tsullivan Nov 18, 2024
932c871
Merge branch 'main' into spaces/spaces-grid-fixes-iii
tsullivan Nov 19, 2024
c49dba7
re-update translations
tsullivan Nov 19, 2024
303dcf5
use showAdditionalPermissionsMessage prop name
tsullivan Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/packages/security/ui_components/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "shared-common",
"type": "shared-browser",
"id": "@kbn/security-ui-components",
"owner": "@elastic/kibana-security"
}
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@ const setup = (config: TestConfig) => {
kibanaPrivileges={kibanaPrivileges}
onChange={onChange}
onChangeAll={onChangeAll}
showAdditionalPermissionsMessage={true}
canCustomizeSubFeaturePrivileges={config.canCustomizeSubFeaturePrivileges}
privilegeIndex={config.privilegeIndex}
allSpacesSelected={true}
Original file line number Diff line number Diff line change
@@ -45,13 +45,10 @@ interface Props {
privilegeIndex: number;
onChange: (featureId: string, privileges: string[]) => void;
onChangeAll: (privileges: string[]) => void;
showAdditionalPermissionsMessage: boolean;
canCustomizeSubFeaturePrivileges: boolean;
allSpacesSelected: boolean;
disabled?: boolean;
/**
* default is true, to remain backwards compatible
*/
showTitle?: boolean;
}

interface State {
@@ -62,7 +59,6 @@ export class FeatureTable extends Component<Props, State> {
public static defaultProps = {
privilegeIndex: -1,
showLocks: true,
showTitle: true,
};

private featureCategories: Map<string, SecuredFeature[]> = new Map();
@@ -189,20 +185,7 @@ export class FeatureTable extends Component<Props, State> {
return (
<div>
<EuiFlexGroup alignItems={'flexEnd'}>
<EuiFlexItem>
{this.props.showTitle && (
<EuiText size="xs">
<b>
{i18n.translate(
'xpack.security.management.editRole.featureTable.featureVisibilityTitle',
{
defaultMessage: 'Customize feature privileges',
}
)}
</b>
</EuiText>
)}
</EuiFlexItem>
<EuiFlexItem />
{!this.props.disabled && (
<EuiFlexItem grow={false}>
<ChangeAllPrivilegesControl
@@ -397,7 +380,7 @@ export class FeatureTable extends Component<Props, State> {
};

private getCategoryHelpText = (category: AppCategory) => {
if (category.id === 'management') {
if (category.id === 'management' && this.props.showAdditionalPermissionsMessage) {
return i18n.translate(
'xpack.security.management.editRole.featureTable.managementCategoryHelpText',
{
Original file line number Diff line number Diff line change
@@ -226,6 +226,7 @@ export class SimplePrivilegeSection extends Component<Props, State> {
privilegeIndex={this.props.role.kibana.findIndex((k) =>
isGlobalPrivilegeDefinition(k)
)}
showAdditionalPermissionsMessage={true}
canCustomizeSubFeaturePrivileges={this.props.canCustomizeSubFeaturePrivileges}
allSpacesSelected
disabled={!this.props.editable}
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ 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';

const createRole = (kibana: Role['kibana'] = []): Role => {
@@ -57,7 +56,7 @@ const renderComponent = (props: React.ComponentProps<typeof PrivilegeSpaceForm>)
};

describe('PrivilegeSpaceForm', () => {
it('renders an empty form when the role contains no Kibana privileges', () => {
it('renders no form when no role is selected', () => {
const role = createRole();
const kibanaPrivileges = createKibanaPrivileges(kibanaFeatures);

@@ -71,40 +70,9 @@ describe('PrivilegeSpaceForm', () => {
onCancel: jest.fn(),
});

expect(
wrapper.find(EuiButtonGroup).filter('[name="basePrivilegeButtonGroup"]').props().idSelected
).toEqual(`basePrivilege_custom`);
expect(wrapper.find(FeatureTable).props().disabled).toEqual(true);
expect(getDisplayedFeaturePrivileges(wrapper)).toMatchInlineSnapshot(`
Object {
"excluded_from_base": Object {
"primaryFeaturePrivilege": "none",
"subFeaturePrivileges": Array [],
},
"no_sub_features": Object {
"primaryFeaturePrivilege": "none",
"subFeaturePrivileges": Array [],
},
"with_excluded_sub_features": Object {
"primaryFeaturePrivilege": "none",
"subFeaturePrivileges": Array [],
},
"with_require_all_spaces_for_feature_and_sub_features": Object {
"primaryFeaturePrivilege": "none",
"subFeaturePrivileges": Array [],
},
"with_require_all_spaces_sub_features": Object {
"primaryFeaturePrivilege": "none",
"subFeaturePrivileges": Array [],
},
"with_sub_features": Object {
"primaryFeaturePrivilege": "none",
"subFeaturePrivileges": Array [],
},
}
`);

expect(findTestSubject(wrapper, 'spaceFormGlobalPermissionsSupersedeWarning')).toHaveLength(0);
expect(wrapper.find(EuiButtonGroup).filter('[name="basePrivilegeButtonGroup"]')).toHaveLength(
0
);
});

it('renders when a base privilege is selected', () => {
@@ -232,43 +200,6 @@ describe('PrivilegeSpaceForm', () => {
expect(findTestSubject(wrapper, 'spaceFormGlobalPermissionsSupersedeWarning')).toHaveLength(0);
});

it('renders a warning when configuring a global privilege after space privileges are already defined', () => {
const role = createRole([
{
base: [],
feature: {
with_sub_features: ['read'],
},
spaces: ['foo'],
},
{
base: [],
feature: {
with_sub_features: ['all'],
},
spaces: ['*'],
},
]);

const kibanaPrivileges = createKibanaPrivileges(kibanaFeatures);

const wrapper = renderComponent({
role,
spaces: displaySpaces,
kibanaPrivileges,
privilegeIndex: -1,
canCustomizeSubFeaturePrivileges: true,
onChange: jest.fn(),
onCancel: jest.fn(),
});

wrapper.find(SpaceSelector).props().onChange(['*']);

wrapper.update();

expect(findTestSubject(wrapper, 'globalPrivilegeWarning')).toHaveLength(1);
});

it('renders a warning when space privileges are less permissive than configured global privileges', () => {
const role = createRole([
{
Loading