Skip to content

fix(SavedQueries): allow other admin users see "saved queries" (#20604)#21769

Draft
pengwk wants to merge 2 commits into
apache:masterfrom
pengwk:allow-other-admin-view-saved-queries
Draft

fix(SavedQueries): allow other admin users see "saved queries" (#20604)#21769
pengwk wants to merge 2 commits into
apache:masterfrom
pengwk:allow-other-admin-view-saved-queries

Conversation

@pengwk

@pengwk pengwk commented Oct 11, 2022

Copy link
Copy Markdown

SUMMARY

Show the list of all saved queries despite of creators. If the fix is acceptable, then add the test.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Follow #20604 issue's description.

ADDITIONAL INFORMATION

@pengwk

pengwk commented Oct 12, 2022

Copy link
Copy Markdown
Author

@dpgaspar Any time to look at this fix?

@codecov

codecov Bot commented Oct 12, 2022

Copy link
Copy Markdown

Codecov Report

Merging #21769 (242893a) into master (406e44b) will decrease coverage by 11.38%.
The diff coverage is 25.00%.

❗ Current head 242893a differs from pull request most recent head a7bdb78. Consider uploading reports for the commit a7bdb78 to get more accurate results

@@             Coverage Diff             @@
##           master   #21769       +/-   ##
===========================================
- Coverage   66.88%   55.50%   -11.39%     
===========================================
  Files        1800     1800               
  Lines       68967    68970        +3     
  Branches     7339     7339               
===========================================
- Hits        46128    38281     -7847     
- Misses      20943    28793     +7850     
  Partials     1896     1896               
Flag Coverage Δ
hive 52.92% <25.00%> (-0.01%) ⬇️
mysql ?
postgres ?
presto 52.82% <25.00%> (-0.01%) ⬇️
python 57.93% <25.00%> (-23.53%) ⬇️
sqlite ?
unit 51.05% <25.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/queries/saved_queries/filters.py 74.07% <25.00%> (-21.76%) ⬇️
superset/utils/dashboard_import_export.py 0.00% <0.00%> (-100.00%) ⬇️
superset/tags/core.py 4.54% <0.00%> (-95.46%) ⬇️
superset/key_value/commands/update.py 0.00% <0.00%> (-90.91%) ⬇️
superset/key_value/commands/delete.py 0.00% <0.00%> (-87.88%) ⬇️
superset/key_value/commands/delete_expired.py 0.00% <0.00%> (-84.00%) ⬇️
superset/dashboards/commands/importers/v0.py 15.62% <0.00%> (-76.25%) ⬇️
superset/datasets/commands/update.py 25.00% <0.00%> (-69.05%) ⬇️
superset/datasets/commands/importers/v0.py 24.03% <0.00%> (-69.00%) ⬇️
superset/datasets/commands/create.py 31.25% <0.00%> (-68.75%) ⬇️
... and 284 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@yousoph

yousoph commented Oct 13, 2022

Copy link
Copy Markdown
Member

Hi @pengwk ! Thanks for opening this PR

Would it be possible to make the following additions to help make sure the Saved Queries page is still usable for admins?

  1. Add a "Created by" column to the list view, between "Modified" and "Actions"
  2. Add a "Created by" filter to the top of the page, to the left of "Search"
  3. If possible, default the "Created by" filter to the current user so that admin users can easily find their own Saved queries and the initial state of the page is similar to how it is currently.

Thanks!

@pengwk

pengwk commented Oct 13, 2022

Copy link
Copy Markdown
Author

Hi @yousoph ! Thank you very much for your guidance and I am happy to be able to contribute to the project. Need to add a filter to the homepage?

image

@yousoph

yousoph commented Oct 13, 2022

Copy link
Copy Markdown
Member

Hi @yousoph ! Thank you very much for your guidance and I am happy to be able to contribute to the project. Need to add a filter to the homepage?

image

Good question! I think having the current "Mine" filter on the home page is enough. The other sections have "Favorite" and "Examples" filters which I don't think we need here

@pengwk

pengwk commented Oct 17, 2022

Copy link
Copy Markdown
Author

Hi @pengwk ! Thanks for opening this PR

Would it be possible to make the following additions to help make sure the Saved Queries page is still usable for admins?

  1. Add a "Created by" column to the list view, between "Modified" and "Actions"
  2. Add a "Created by" filter to the top of the page, to the left of "Search"
  3. If possible, default the "Created by" filter to the current user so that admin users can easily find their own Saved queries and the initial state of the page is similar to how it is currently.

Thanks!

Hi, @yousoph! Both tasks 1 and 2 have been achieved, but I don't know how to do task 3. Can you find someone familiar with you for some guidance?

@mayurnewase

Copy link
Copy Markdown
Contributor

can you add tests?

@pengwk

pengwk commented Dec 21, 2022

Copy link
Copy Markdown
Author

Yes, I can add tests, wait for me. Thanks for your reply.

@matt-lessig

Copy link
Copy Markdown

Will this fix also apply to the REST API? We are trying to use an administrative service account to pull all saved queries for all users via the REST API.

@Bill0412

Bill0412 commented Apr 20, 2023

Copy link
Copy Markdown

Yes, I can add tests, wait for me. Thanks for your reply.

It would be great if you could write tests.

@pengwk

pengwk commented May 27, 2023

Copy link
Copy Markdown
Author

@Bill0412 I'm working on it, I was too busy with work, sorry.

@Bill0412

Copy link
Copy Markdown

I've already started using it without test. Don't worry about that too much.

@rusackas

rusackas commented Aug 1, 2024

Copy link
Copy Markdown
Member

Looks like this is in need of a rebase. Personally, I think we might be able to merge it without added filters and tests. While they'd be ideal, it seems like this is still an improvement and closes a long-outstanding Issue. Curious if you agree @yousoph

@pengwk

pengwk commented Sep 9, 2024

Copy link
Copy Markdown
Author

It looks like this PR is still useful, I will complete the rest @rusackas @yousoph

@Bill0412

Bill0412 commented Oct 29, 2024

Copy link
Copy Markdown

It looks like this PR is still useful, I will complete the rest @rusackas @yousoph

Yes, it will be really helpful if it's merged.

@zachoooo

Copy link
Copy Markdown

Would love to have this PR merged in

@rusackas

Copy link
Copy Markdown
Member

Needs a rebase (sorry!)

A couple questions about this came up here: #20604 (comment)

This might warrant a little bit more Discussion (cc @yousoph @eschutho @michael-s-molina)

@rusackas

Copy link
Copy Markdown
Member

Hi @pengwk, this PR has been open for a long time and there's clearly a lot of community interest in seeing it land — thank you for sticking with it. It currently has merge conflicts and there are some open design questions raised in the last comment that need discussion (cc @yousoph @eschutho @michael-s-molina). We're converting it to draft for now. When you're ready, please rebase on the latest master, address the design questions from the linked discussion, and mark it as "Ready for review" so we can move it forward.

@rusackas rusackas marked this pull request as draft March 13, 2026 23:01
pengwk added 2 commits June 13, 2026 09:06
… "Actions"

2. Add a "Created by" filter to the top of the page, to the left of "Search"
@rusackas rusackas force-pushed the allow-other-admin-view-saved-queries branch from a7bdb78 to 5475330 Compare June 13, 2026 16:14
@github-actions github-actions Bot added the api Related to the REST API label Jun 13, 2026
@rusackas

Copy link
Copy Markdown
Member

Picked this back up @pengwk - it had drifted ~8k commits behind and gone conflicting. I rebased it onto current master and resolved the conflicts on your branch (force-pushed, your authorship kept). Worth knowing: master has since grown its own changed_by related filter and already lists created_by in allowed_rel_fields, so the net diff is smaller now. I kept that changed_by work and added created_by alongside it, ported the 'Created by' column + filter to the relocated src/pages/SavedQueryList/index.tsx (using the current RelationOneMany conventions), and the actual fix - gating the owner-only filter behind can_access_all_queries so admins see each other's saved queries - is intact. Mergeable again and CI's running. It's still a draft; want to mark it ready? A small unit test on the SavedQueryFilter gating would be a nice addition before merge, happy to add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API review:draft size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Other admin users can't see "saved queries" created by another admin users

7 participants