Skip to content

Commit

Permalink
[8.x] [Spaces] update privilege selection text and icon (elastic#199498
Browse files Browse the repository at this point in the history
…) (elastic#199568)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Spaces] update privilege selection text and icon
(elastic#199498)](elastic#199498)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Eyo O.
Eyo","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-08T22:23:16Z","message":"[Spaces]
update privilege selection text and icon (elastic#199498)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana-team/issues/1257\r\n\r\nThis PR
modifies the spaces bulk edit context menu items to match the\r\nnew
design icons and text\r\n\r\n#### Visuals\r\n\r\n##### After\r\n<img
width=\"223\" alt=\"Screenshot 2024-11-08 at 16 06
20\"\r\nsrc=\"https://github.com/user-attachments/assets/4c09145a-c614-4d9f-a680-7fe28ef3087f\">\r\n\r\n\r\n#####
Before\r\n<img width=\"262\" alt=\"Screenshot 2024-11-08 at 15 59
02\"\r\nsrc=\"https://github.com/user-attachments/assets/14669115-8d98-46f9-b8c3-afb243e861d2\">\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n<!--\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed -->\r\n- [x] Any UI touched in this PR
is usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n<!--\r\n- [
] Any UI touched in this PR does not create any new axe failures\r\n(run
axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-->\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n<!--\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[ ] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n-->","sha":"cb7e5f6a0a70a35a46ce577d31476eabe4f1555e","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","release_note:skip","v9.0.0","backport:prev-minor"],"title":"[Spaces]
update privilege selection text and
icon","number":199498,"url":"https://github.com/elastic/kibana/pull/199498","mergeCommit":{"message":"[Spaces]
update privilege selection text and icon (elastic#199498)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana-team/issues/1257\r\n\r\nThis PR
modifies the spaces bulk edit context menu items to match the\r\nnew
design icons and text\r\n\r\n#### Visuals\r\n\r\n##### After\r\n<img
width=\"223\" alt=\"Screenshot 2024-11-08 at 16 06
20\"\r\nsrc=\"https://github.com/user-attachments/assets/4c09145a-c614-4d9f-a680-7fe28ef3087f\">\r\n\r\n\r\n#####
Before\r\n<img width=\"262\" alt=\"Screenshot 2024-11-08 at 15 59
02\"\r\nsrc=\"https://github.com/user-attachments/assets/14669115-8d98-46f9-b8c3-afb243e861d2\">\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n<!--\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed -->\r\n- [x] Any UI touched in this PR
is usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n<!--\r\n- [
] Any UI touched in this PR does not create any new axe failures\r\n(run
axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-->\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n<!--\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[ ] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n-->","sha":"cb7e5f6a0a70a35a46ce577d31476eabe4f1555e"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199498","number":199498,"mergeCommit":{"message":"[Spaces]
update privilege selection text and icon (elastic#199498)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana-team/issues/1257\r\n\r\nThis PR
modifies the spaces bulk edit context menu items to match the\r\nnew
design icons and text\r\n\r\n#### Visuals\r\n\r\n##### After\r\n<img
width=\"223\" alt=\"Screenshot 2024-11-08 at 16 06
20\"\r\nsrc=\"https://github.com/user-attachments/assets/4c09145a-c614-4d9f-a680-7fe28ef3087f\">\r\n\r\n\r\n#####
Before\r\n<img width=\"262\" alt=\"Screenshot 2024-11-08 at 15 59
02\"\r\nsrc=\"https://github.com/user-attachments/assets/14669115-8d98-46f9-b8c3-afb243e861d2\">\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n<!--\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed -->\r\n- [x] Any UI touched in this PR
is usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n<!--\r\n- [
] Any UI touched in this PR does not create any new axe failures\r\n(run
axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-->\r\n-
[x] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n<!--\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n-
[ ] This will appear in the **Release Notes** and follow
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n-->","sha":"cb7e5f6a0a70a35a46ce577d31476eabe4f1555e"}}]}]
BACKPORT-->

Co-authored-by: Eyo O. Eyo <[email protected]>
  • Loading branch information
kibanamachine and eokoneyo authored Nov 9, 2024
1 parent 401b00d commit 5f02f1f
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 184 deletions.
2 changes: 1 addition & 1 deletion x-pack/packages/security/ui_components/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
* 2.0.
*/

export const NO_PRIVILEGE_VALUE: string = 'none';
export const NO_PRIVILEGE_VALUE = 'none' as const;
export const CUSTOM_PRIVILEGE_VALUE: string = 'custom';
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
EuiPopover,
EuiText,
} from '@elastic/eui';
import _ from 'lodash';
import React, { Component } from 'react';

import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import type { KibanaPrivilege } from '@kbn/security-role-management-model';

Expand All @@ -38,6 +38,43 @@ export class ChangeAllPrivilegesControl extends Component<Props, State> {
isPopoverOpen: false,
};

private getPrivilegeCopy = (privilege: string): { label?: string; icon?: string } => {
switch (privilege) {
case 'all':
return {
icon: 'documentEdit',
label: i18n.translate(
'xpack.security.management.editRole.changeAllPrivileges.allSelectionLabel',
{
defaultMessage: 'Grant full access for all',
}
),
};
case 'read':
return {
icon: 'glasses',
label: i18n.translate(
'xpack.security.management.editRole.changeAllPrivileges.readSelectionLabel',
{
defaultMessage: 'Grant read access for all',
}
),
};
case 'none':
return {
icon: 'trash',
label: i18n.translate(
'xpack.security.management.editRole.changeAllPrivileges.noneSelectionLabel',
{
defaultMessage: 'Revoke access to all',
}
),
};
default:
return {};
}
};

public render() {
const button = (
<EuiLink
Expand All @@ -56,30 +93,35 @@ export class ChangeAllPrivilegesControl extends Component<Props, State> {
);

const items = this.props.privileges.map((privilege) => {
const { icon, label } = this.getPrivilegeCopy(privilege.id);
return (
<EuiContextMenuItem
icon={icon}
key={privilege.id}
data-test-subj={`changeAllPrivileges-${privilege.id}`}
onClick={() => {
this.onSelectPrivilege(privilege.id);
}}
disabled={this.props.disabled}
>
{_.upperFirst(privilege.id)}
{label}
</EuiContextMenuItem>
);
});

items.push(
<EuiContextMenuItem
icon={this.getPrivilegeCopy(NO_PRIVILEGE_VALUE).icon}
key={NO_PRIVILEGE_VALUE}
data-test-subj={`changeAllPrivileges-${NO_PRIVILEGE_VALUE}`}
onClick={() => {
this.onSelectPrivilege(NO_PRIVILEGE_VALUE);
}}
disabled={this.props.disabled}
// @ts-expect-error leaving this here so that when https://github.com/elastic/eui/issues/8123 is fixed we remove this comment
css={({ euiTheme }) => ({ color: euiTheme.colors.danger })}
>
{_.upperFirst(NO_PRIVILEGE_VALUE)}
{this.getPrivilegeCopy(NO_PRIVILEGE_VALUE).label}
</EuiContextMenuItem>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { EuiAccordion, EuiIconTip } from '@elastic/eui';
import { EuiAccordion, EuiIconTip, EuiThemeProvider } from '@elastic/eui';
import React from 'react';

import type { KibanaFeature, SubFeatureConfig } from '@kbn/features-plugin/public';
Expand Down Expand Up @@ -47,16 +47,18 @@ const setup = (config: TestConfig) => {
const onChange = jest.fn();
const onChangeAll = jest.fn();
const wrapper = mountWithIntl(
<FeatureTable
role={config.role}
privilegeCalculator={calculator}
kibanaPrivileges={kibanaPrivileges}
onChange={onChange}
onChangeAll={onChangeAll}
canCustomizeSubFeaturePrivileges={config.canCustomizeSubFeaturePrivileges}
privilegeIndex={config.privilegeIndex}
allSpacesSelected={true}
/>
<EuiThemeProvider>
<FeatureTable
role={config.role}
privilegeCalculator={calculator}
kibanaPrivileges={kibanaPrivileges}
onChange={onChange}
onChangeAll={onChangeAll}
canCustomizeSubFeaturePrivileges={config.canCustomizeSubFeaturePrivileges}
privilegeIndex={config.privilegeIndex}
allSpacesSelected={true}
/>
</EuiThemeProvider>
);

const displayedPrivileges = config.calculateDisplayedPrivileges
Expand Down
Loading

0 comments on commit 5f02f1f

Please sign in to comment.