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

fix: [M3-7862] - Fix display of TagsPanel in read-only entities #10275

Conversation

hkhalil-akamai
Copy link
Contributor

@hkhalil-akamai hkhalil-akamai commented Mar 11, 2024

Description 📝

#10227 disables the TagPanel component for read-only entities. However, this change would not work correctly for non-Linode entities, such as domains and nodebalancers, since it was hard-coded to grantType: 'linode'.

Changes 🔄

  • Fixes hard-coded grantType value
  • Moves useIsResourceRestricted out of TagsPanel and into each respective component

Target release date 🗓️

3/18/2024

How to test 🧪

Prerequisites

  • Create and log in to a restricted user with a read-only Domain and NodeBalancer.

Reproduction steps

  • While logged in to the restricted user, navigate to the read-only Domain/NodeBalancer
  • Observe that the Add Tag button is not disabled
  • Observe that trying to add a tag results in an Unauthorized Error.

Verification steps

  • Follow reproduction steps above
  • Verify that Add Tag button is disabled

As an Author I have considered 🤔

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@hkhalil-akamai hkhalil-akamai self-assigned this Mar 11, 2024
@hkhalil-akamai hkhalil-akamai requested a review from a team as a code owner March 11, 2024 21:25
@hkhalil-akamai hkhalil-akamai requested review from dwiley-akamai and hana-akamai and removed request for a team March 11, 2024 21:25
Comment on lines -69 to -74
const isLinodesGrantReadOnly = useIsResourceRestricted({
grantLevel: 'read_only',
grantType: 'linode',
id: entityId,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's better to call this hook in each respective component instead of cluttering TagsPanel with unrelated logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like restricted users can't view Kubernetes clusters at all, so the logic in this file may have no effect.

Copy link

github-actions bot commented Mar 11, 2024

Coverage Report:
Base Coverage: 81.64%
Current Coverage: 81.63%

Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

For Domains, should we provide some sort of indication as to why the tags are disabled? For NodeBalancers, we have a notice at the top so the reason can at least be ascertained. Maybe explanatory hover text could be appropriate here in the Domain case? Alternatively, we could give a similar treatment to Domains, with a notice at the top (this could be a separate ticket).

NodeBalancer Domain
Screenshot 2024-03-13 at 11 19 26 AM Screenshot 2024-03-13 at 11 20 46 AM

@hkhalil-akamai
Copy link
Contributor Author

For Domains, should we provide some sort of indication as to why the tags are disabled? For NodeBalancers, we have a notice at the top so the reason can at least be ascertained. Maybe explanatory hover text could be appropriate here in the Domain case? Alternatively, we could give a similar treatment to Domains, with a notice at the top (this could be a separate ticket).

Going to defer to @jaalah-akamai, who's leading this project -- maybe this should be a follow-up change?

@jaalah-akamai
Copy link
Contributor

For Domains, should we provide some sort of indication as to why the tags are disabled?

@dwiley-akamai No because we're going to update the domains section next, so it will also have a banner. We're currently working our way through each feature or resource entity.

Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

Disabled TagsPanel for restricted users on read-only entities for Linodes (card view & on Details page), Domains, and NodeBalancers ✅

Copy link
Contributor

Choose a reason for hiding this comment

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

If the read-only logic isn't doing anything for LKE, we should remove the code IMO. Or if API will support it in the future, add a @todo placeholder about it and comment the grant-related code out

@jaalah-akamai jaalah-akamai added the Approved Multiple approvals and ready to merge! label Mar 21, 2024
Copy link
Contributor

@hana-akamai hana-akamai left a comment

Choose a reason for hiding this comment

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

There seems to be an issue loading tags for a restricted user that has r/w Nodebalancer access

Screen.Recording.2024-03-22.at.10.55.46.AM.mov

@hkhalil-akamai
Copy link
Contributor Author

hkhalil-akamai commented Mar 22, 2024

There seems to be an issue loading tags for a restricted user that has r/w Nodebalancer access

Screen.Recording.2024-03-22.at.10.55.46.AM.mov

Good catch! Seems to be caused by the way react query v4 defines isLoading. Addressed in c14561.

@hkhalil-akamai hkhalil-akamai merged commit d7b6b88 into linode:develop Mar 25, 2024
18 checks passed
@hkhalil-akamai hkhalil-akamai deleted the M3-7862-tags-panel-restricted-access branch March 25, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants