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

Admin can not overwrite chart from another owner #24399

Open
2 of 3 tasks
mattitoo opened this issue Jun 14, 2023 · 11 comments
Open
2 of 3 tasks

Admin can not overwrite chart from another owner #24399

mattitoo opened this issue Jun 14, 2023 · 11 comments
Assignees

Comments

@mattitoo
Copy link
Contributor

When an Admin opens a chart which is owned by a different user, the Admin can not save and overwrite the existing chart

How to reproduce the bug

  1. Login as Admin
  2. Open an existing chart owned by another user
  3. Click on Save

Expected results

Admin can choose to overwrite the chart

Actual results

The Overwrite option is disabled

Screenshots

image

Environment

  • superset version: 2.1.0
  • python version: python --version
  • node.js version: node -v
  • any feature flags active:
    FEATURE_FLAGS = {
    "DASHBOARD_NATIVE_FILTERS": True,
    "THUMBNAILS": False,
    "LISTVIEWS_DEFAULT_CARD_VIEW" : False,
    "THUMBNAILS_SQLA_LISTENERS": False,
    "ENABLE_EXPLORE_DRAG_AND_DROP": True,
    "ENABLE_TEMPLATE_PROCESSING": True,
    "DASHBOARD_CROSS_FILTERS": True,
    "GENERIC_CHART_AXES": True,
    "ENABLE_DND_WITH_CLICK_UX": True,
    "UX_BETA": True,
    "ALERT_REPORTS": True,
    "DASHBOARD_RBAC": True,
    "ALLOW_ADHOC_SUBQUERY" : True,
    "HORIZONTAL_FILTER_BAR": True,
    }

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

Add any other context about the problem here.

@benjamin-musil
Copy link

I also have this same issue. I am an admin and another admin created a chart but I have to save a new chart instead of being able to overwrite.

@davidgcameron
Copy link

As a workaround you can create a database trigger which will automatically give all admins ownership of newly created charts:

CREATE TRIGGER add_admin_role AFTER INSERT ON slices
FOR EACH ROW
  INSERT INTO slice_user(user_id, slice_id)
  SELECT user_id, NEW.id FROM ab_user_role
    WHERE role_id=(SELECT id FROM ab_role WHERE name='Admin') AND
    user_id != NEW.created_by_fk;

And you can give admins ownership of existing charts by running this query for each admin user id (replacing <user_id> with the user_id):

INSERT INTO slice_user (user_id, slice_id)
SELECT distinct <user_id>, slice_id FROM slice_user
WHERE slice_id NOT IN
  (SELECT slice_id FROM slice_user WHERE user_id=<user_id>)
  AND slice_id IN (SELECT id FROM slices);

Hope this helps.

@iercan
Copy link
Contributor

iercan commented Oct 6, 2023

This bug exist from 2.0. Hoped to see it fixed on 2.1.1 but disappointed.

@eschutho
Copy link
Member

Thanks @iercan for reporting! Do you know if this is still broken in 3.0?

@iercan
Copy link
Contributor

iercan commented Oct 10, 2023

Thanks @iercan for reporting! Do you know if this is still broken in 3.0?

I don't know about 3.0

@lf-floriandin
Copy link

@eschutho Still exists in 3.0

@rusackas
Copy link
Member

Is anyone able to validate if this is still unresolved in 3.1 or the 4.0 release candidate?

@carmoIn
Copy link

carmoIn commented Apr 19, 2024

@rusackas Yes it still exists in version 4.0.0

@Physicalpixel
Copy link

As a workaround you can create a database trigger which will automatically give all admins ownership of newly created charts:

CREATE TRIGGER add_admin_role AFTER INSERT ON slices
FOR EACH ROW
  INSERT INTO slice_user(user_id, slice_id)
  SELECT user_id, NEW.id FROM ab_user_role
    WHERE role_id=(SELECT id FROM ab_role WHERE name='Admin') AND
    user_id != NEW.created_by_fk;

And you can give admins ownership of existing charts by running this query for each admin user id (replacing <user_id> with the user_id):

INSERT INTO slice_user (user_id, slice_id)
SELECT distinct <user_id>, slice_id FROM slice_user
WHERE slice_id NOT IN
  (SELECT slice_id FROM slice_user WHERE user_id=<user_id>)
  AND slice_id IN (SELECT id FROM slices);

Hope this helps.

Hi, I am importing a csv and facing this issue, where exactly do I create a scheme like this? Any help you can provide will be much appreciated.

@mtrentz
Copy link

mtrentz commented May 24, 2024

I'm on 4.0.1 and also have this issue. Really wish that admins had the power to edit any chart without having to add yourself as owner :)

@mtrentz
Copy link

mtrentz commented May 24, 2024

To contribute to the SQL solutions here this query adds all admins as owner into all existing charts:

INSERT INTO slice_user (user_id, slice_id)
SELECT DISTINCT u.user_id, s.id
FROM slices s
     JOIN ab_user_role u ON u.user_id NOT IN (SELECT user_id FROM slice_user WHERE slice_id = s.id)
WHERE u.role_id = (SELECT id FROM ab_role WHERE name = 'Admin');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests