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

[Fleet] Handle unavailable spaces in agent policy space selector #201251

Conversation

jillguyonnet
Copy link
Contributor

@jillguyonnet jillguyonnet commented Nov 21, 2024

Summary

Closes #193827

This PR improves the space selector in agent policy setting to handle the case where the user does not have access to all policy spaces.

In this case:

  • Space selection is disabled
  • The "Create space" link is hidden
  • A tooltip is shown to inform the user why the input is disabled
  • The inaccessible space badges are given an Unavailable space badge

Screenshots

For a user with access to all policy spaces (no change):
Screenshot 2024-11-21 at 17 11 00

For a user with access to only a subset of policy spaces:
Screenshot 2024-11-21 at 17 11 09

Checklist

@jillguyonnet jillguyonnet self-assigned this Nov 21, 2024
@jillguyonnet jillguyonnet added Team:Fleet Team label for Observability Data Collection Fleet team release_note:skip Skip the PR/issue when compiling release notes labels Nov 21, 2024
@nchaulet
Copy link
Member

This looks a good solution to me, we should probably remove the space_ids property when that field is disabled from the data we send to update the policy here https://github.com/elastic/kibana/blob/main/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/details_page/components/settings/index.tsx#L108

@jillguyonnet
Copy link
Contributor Author

we should probably remove the space_ids property when that field is disabled from the data

Good catch, thanks! I pushed a fix. I kept it local to the component instead of centralising the userHasAccessToAllPolicySpaces logic as it is small enough, let me know what you think.

One general concern I had is that this fix relies on the Saved Objects API returning ? for the id of unavailable spaces. It allows the fix to be small, but I'm not sure how reliable this will be in the future. Any thoughts?

@jillguyonnet jillguyonnet marked this pull request as ready for review November 22, 2024 13:28
@jillguyonnet jillguyonnet requested a review from a team as a code owner November 22, 2024 13:28
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@jillguyonnet jillguyonnet added the backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) label Nov 22, 2024
@nchaulet
Copy link
Member

One general concern I had is that this fix relies on the Saved Objects API returning ? for the id of unavailable spaces. It allows the fix to be small, but I'm not sure how reliable this will be in the future. Any thoughts?

It seems pretty reliable, the space plugin seems to use that behavior frequently in their code, it seems also they expose a UNKNOWN_SPACE constant that we may want to use

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@jillguyonnet
Copy link
Contributor Author

It seems pretty reliable, the space plugin seems to use that behavior frequently in their code, it seems also they expose a UNKNOWN_SPACE constant that we may want to use

Cheers 👍 I pushed a commit to use the constant.

@kpollich
Copy link
Member

Is there anything preventing us from hiding the spaces entirely instead of displaying "unavailable space"? This badge isn't actionable for users with limited space access, and seems like it's adding UI noise for them.

@jillguyonnet
Copy link
Contributor Author

Is there anything preventing us from hiding the spaces entirely instead of displaying "unavailable space"? This badge isn't actionable for users with limited space access, and seems like it's adding UI noise for them.

Nothing preventing, it's a small change. My thinking was that this shows more clearly why the input is disabled, but with the tooltip it shouldn't be a concern. If showing how many unavailable spaces are assigned is a concern, then I'm definitely happy to hide them instead.

@kpollich
Copy link
Member

If showing how many unavailable spaces are assigned is a concern, then I'm definitely happy to hide them instead.

If we're relying on spaces as an information/data isolation mechanism, I think a user with permissions to only 2 spaces should not know there are 12 available spaces in Kibana. Hiding the spaces entirely seems like the more "proper" thing to do when it comes to data isolation. I'd be in favor of making this change here.

@jillguyonnet
Copy link
Contributor Author

Hiding the spaces entirely seems like the more "proper" thing to do when it comes to data isolation.

Thank you, agreed and done. I've updated the PR description.

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@jillguyonnet
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #9 / MultipleAgentPolicySummaryLine it should render the first policy name and the badge when there are multiple policies
  • [job] [logs] Jest Tests #9 / RootPrivilegesCallout should render callout requiring root privileges
  • [job] [logs] Jest Tests #9 / useActionStatus should refresh statuses on refresh flag

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 1241 1242 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 1.7MB 1.7MB +419.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 174.3KB 174.4KB +43.0B

History

cc @jillguyonnet

@jillguyonnet jillguyonnet merged commit db49418 into elastic:main Nov 25, 2024
24 checks passed
@jillguyonnet jillguyonnet deleted the fleet/193827-fix-agent-policy-space-selector branch November 25, 2024 12:49
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12010381205

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 25, 2024
…stic#201251)

## Summary

Closes elastic#193827

This PR improves the space selector in agent policy setting to handle
the case where the user does not have access to all policy spaces.

In this case:
* Space selection is disabled
* The "Create space" link is hidden
* A tooltip is shown to inform the user why the input is disabled
* The inaccessible space badges are given an `Unavailable space` badge

### Screenshots

For a user with access to all policy spaces (no change):
![Screenshot 2024-11-21 at 17 11
00](https://github.com/user-attachments/assets/79c4fcc5-17d5-4273-912c-07eecfd73715)

For a user with access to only a subset of policy spaces:
![Screenshot 2024-11-21 at 17 11
09](https://github.com/user-attachments/assets/19ca162a-7ed6-45fd-8ecc-98e6e085af27)

### Checklist

- [x] 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)
- [x] [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
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit db49418)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine kibanamachine mentioned this pull request Nov 25, 2024
2 tasks
kibanamachine added a commit that referenced this pull request Nov 25, 2024
#201251) (#201580)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Fleet] Handle unavailable spaces in agent policy space selector
(#201251)](#201251)

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

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

<!--BACKPORT [{"author":{"name":"Jill
Guyonnet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-25T12:49:23Z","message":"[Fleet]
Handle unavailable spaces in agent policy space selector (#201251)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/193827\r\n\r\nThis PR improves
the space selector in agent policy setting to handle\r\nthe case where
the user does not have access to all policy spaces.\r\n\r\nIn this
case:\r\n* Space selection is disabled\r\n* The \"Create space\" link is
hidden\r\n* A tooltip is shown to inform the user why the input is
disabled\r\n* The inaccessible space badges are given an `Unavailable
space` badge\r\n\r\n### Screenshots\r\n\r\nFor a user with access to all
policy spaces (no change):\r\n![Screenshot 2024-11-21 at 17
11\r\n00](https://github.com/user-attachments/assets/79c4fcc5-17d5-4273-912c-07eecfd73715)\r\n\r\nFor
a user with access to only a subset of policy spaces:\r\n![Screenshot
2024-11-21 at 17
11\r\n09](https://github.com/user-attachments/assets/19ca162a-7ed6-45fd-8ecc-98e6e085af27)\r\n\r\n###
Checklist\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-
[x] [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- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"db494181e37a3f3477361fc1c1919fc7ed3a1329","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v9.0.0","backport:prev-minor"],"title":"[Fleet]
Handle unavailable spaces in agent policy space
selector","number":201251,"url":"https://github.com/elastic/kibana/pull/201251","mergeCommit":{"message":"[Fleet]
Handle unavailable spaces in agent policy space selector (#201251)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/193827\r\n\r\nThis PR improves
the space selector in agent policy setting to handle\r\nthe case where
the user does not have access to all policy spaces.\r\n\r\nIn this
case:\r\n* Space selection is disabled\r\n* The \"Create space\" link is
hidden\r\n* A tooltip is shown to inform the user why the input is
disabled\r\n* The inaccessible space badges are given an `Unavailable
space` badge\r\n\r\n### Screenshots\r\n\r\nFor a user with access to all
policy spaces (no change):\r\n![Screenshot 2024-11-21 at 17
11\r\n00](https://github.com/user-attachments/assets/79c4fcc5-17d5-4273-912c-07eecfd73715)\r\n\r\nFor
a user with access to only a subset of policy spaces:\r\n![Screenshot
2024-11-21 at 17
11\r\n09](https://github.com/user-attachments/assets/19ca162a-7ed6-45fd-8ecc-98e6e085af27)\r\n\r\n###
Checklist\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-
[x] [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- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"db494181e37a3f3477361fc1c1919fc7ed3a1329"}},"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/201251","number":201251,"mergeCommit":{"message":"[Fleet]
Handle unavailable spaces in agent policy space selector (#201251)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/193827\r\n\r\nThis PR improves
the space selector in agent policy setting to handle\r\nthe case where
the user does not have access to all policy spaces.\r\n\r\nIn this
case:\r\n* Space selection is disabled\r\n* The \"Create space\" link is
hidden\r\n* A tooltip is shown to inform the user why the input is
disabled\r\n* The inaccessible space badges are given an `Unavailable
space` badge\r\n\r\n### Screenshots\r\n\r\nFor a user with access to all
policy spaces (no change):\r\n![Screenshot 2024-11-21 at 17
11\r\n00](https://github.com/user-attachments/assets/79c4fcc5-17d5-4273-912c-07eecfd73715)\r\n\r\nFor
a user with access to only a subset of policy spaces:\r\n![Screenshot
2024-11-21 at 17
11\r\n09](https://github.com/user-attachments/assets/19ca162a-7ed6-45fd-8ecc-98e6e085af27)\r\n\r\n###
Checklist\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-
[x] [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- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_note:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"db494181e37a3f3477361fc1c1919fc7ed3a1329"}}]}]
BACKPORT-->

Co-authored-by: Jill Guyonnet <[email protected]>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
…stic#201251)

## Summary

Closes elastic#193827

This PR improves the space selector in agent policy setting to handle
the case where the user does not have access to all policy spaces.

In this case:
* Space selection is disabled
* The "Create space" link is hidden
* A tooltip is shown to inform the user why the input is disabled
* The inaccessible space badges are given an `Unavailable space` badge

### Screenshots

For a user with access to all policy spaces (no change):
![Screenshot 2024-11-21 at 17 11
00](https://github.com/user-attachments/assets/79c4fcc5-17d5-4273-912c-07eecfd73715)

For a user with access to only a subset of policy spaces:
![Screenshot 2024-11-21 at 17 11
09](https://github.com/user-attachments/assets/19ca162a-7ed6-45fd-8ecc-98e6e085af27)

### Checklist

- [x] 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)
- [x] [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
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Elastic Machine <[email protected]>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
…stic#201251)

## Summary

Closes elastic#193827

This PR improves the space selector in agent policy setting to handle
the case where the user does not have access to all policy spaces.

In this case:
* Space selection is disabled
* The "Create space" link is hidden
* A tooltip is shown to inform the user why the input is disabled
* The inaccessible space badges are given an `Unavailable space` badge

### Screenshots

For a user with access to all policy spaces (no change):
![Screenshot 2024-11-21 at 17 11
00](https://github.com/user-attachments/assets/79c4fcc5-17d5-4273-912c-07eecfd73715)

For a user with access to only a subset of policy spaces:
![Screenshot 2024-11-21 at 17 11
09](https://github.com/user-attachments/assets/19ca162a-7ed6-45fd-8ecc-98e6e085af27)

### Checklist

- [x] 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)
- [x] [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
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.18.0 v9.0.0
Projects
None yet
5 participants