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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

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.

🚀

@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 22, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #11 / AgentStatusFilter Shows tour and inactive count if first time seeing newly inactive agents
  • [job] [logs] FTR Configs #79 / discover/group4 data view flyout "after all" hook for "update data view with no time field"
  • [job] [logs] FTR Configs #79 / discover/group4 data view flyout create saved data view
  • [job] [logs] Jest Tests #11 / step select agent policy should select first agent policy by default if multiple exists

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
fleet 1240 1241 +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.2KB 174.3KB +43.0B

History

cc @jillguyonnet

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
Projects
None yet
4 participants