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(frontend): fix edit/delete permissions for charts, dashboards, and datasets (#18870) (#32981) #32995

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

fnardin-maystreet
Copy link

@fnardin-maystreet fnardin-maystreet commented Apr 3, 2025

SUMMARY

In both Dashboards, Datasets, Charts pages the delete and edit buttons are shown on the only condition that the user has can_write permission even if not the owner. Attempting to delete or edit an object results in a Forbidden error.

This PR fixes the button disabled status in the frontend preventing the user from attempting to delete or edit a resource it has no permission to.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

All three pages will show the delete and edit buttons as disabled if the user is not an owner or an admin:

Screenshot 2025-04-04 at 12 59 11

fixes: #18870
fixes: #32981

TESTING INSTRUCTIONS

Create a dashboard, a chart, and a dataset with an user and try to edit / delete them with a different user.

ADDITIONAL INFORMATION

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

I've completed my review and didn't find any issues.

Suppressed issues based on your team's Korbit activity
This issue Is similar to Because
lines 412:414:

The owner check uses Array.map() followed by includes(), which is inefficient for checking existence.

It creates a new array unnecessarily.

Inefficient Array Operations

Similar issues were not addressed in the past

When you react to issues (for example, an upvote or downvote) or you fix them, Korbit will tune future reviews based on these signals.

Files scanned
File Path Reviewed
superset-frontend/src/pages/DashboardList/index.tsx
superset-frontend/src/pages/ChartList/index.tsx
superset-frontend/src/pages/DatasetList/index.tsx

Explore our documentation to understand the languages and file types we support and the files we ignore.

Need a new review? Comment /korbit-review on this PR and I'll review your latest changes.

Korbit Guide: Usage and Customization

Interacting with Korbit

  • You can manually ask Korbit to review your PR using the /korbit-review command in a comment at the root of your PR.
  • You can ask Korbit to generate a new PR description using the /korbit-generate-pr-description command in any comment on your PR.
  • Too many Korbit comments? I can resolve all my comment threads if you use the /korbit-resolve command in any comment on your PR.
  • On any given comment that Korbit raises on your pull request, you can have a discussion with Korbit by replying to the comment.
  • Help train Korbit to improve your reviews by giving a 👍 or 👎 on the comments Korbit posts.

Customizing Korbit

  • Check out our docs on how you can make Korbit work best for you and your team.
  • Customize Korbit for your organization through the Korbit Console.

Current Korbit Configuration

General Settings
Setting Value
Review Schedule Automatic excluding drafts
Max Issue Count 10
Automatic PR Descriptions
Issue Categories
Category Enabled
Documentation
Logging
Error Handling
Readability
Design
Performance
Security
Functionality

Feedback and Support

Note

Korbit Pro is free for open source projects 🎉

Looking to add Korbit to your team? Get started with a free 2 week trial here

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@pull-request-size pull-request-size bot added size/L and removed size/M labels Apr 3, 2025
@sadpandajoe
Copy link
Member

This might be a backend problem and not a front end problem. We used to have a can_delete permission but that was collapsed into can_write. CC: @dpgaspar as he might know what is going on.

@fnardin-maystreet
Copy link
Author

This might be a backend problem and not a front end problem. We used to have a can_delete permission but that was collapsed into can_write. CC: @dpgaspar as he might know what is going on.

@sadpandajoe Permissions are obtained through the api/v1/dashboard/_info?q=(keys:!(permissions)) endpoint and apply generically to all dashboards. A can_delete permission is not sufficient to determine if a user can delete a resource, as that also depends on the owner of that resource.

const iconCss = css`
color: ${iconColor || theme.colors.grayscale.base};
font-size: ${iconSize
? `${theme.typography.sizes[iconSize] || theme.typography.sizes.m}px`
: '24px'};
`;
const disabledIconCss = css`
opacity: 0.5;
cursor: default;
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but we could use not-allowed if we want to be all fancy :)

Copy link
Author

Choose a reason for hiding this comment

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

updated to be fancy :)

placement="bottom"
>
<span
role="button"
tabIndex={0}
className="action-button"
onClick={confirmDelete}
onClick={allowEdit ? confirmDelete : undefined}
Copy link
Member

Choose a reason for hiding this comment

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

should we use null rather than undefined? ¯\_(ツ)_/¯

Copy link
Author

Choose a reason for hiding this comment

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

the type is actually onClick?: MouseEventHandler<T> | undefined;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:frontend Requires changing the frontend size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User can attempt to delete a dataset even if it's not the owner Gamma user can attempt to Delete dashboards
3 participants