superset icon indicating copy to clipboard operation
superset copied to clipboard

chore(tags): Handle tagging as part of asset update call

Open Vitor-Avila opened this issue 1 year ago • 3 comments

SUMMARY

Currently, if a change is made to the Tags configuration for an asset via the PropertiesModal, the modification is handled in a separate request. This causes two issues:

  • Content owners with write access on $asset_type have the impression they can change the tags configuration (since they can save it).
  • The operation silently fails -- no error in the UI.

This PR moves the tag handling to the API call to update asset, providing an error to the user if permissions are missing. The PR also introduces a new permission so that users that don't have can write on Tag can still add existing tags to the assets they own (and have permission to modify).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE

https://github.com/apache/superset/assets/96086495/916eab85-63a8-4425-ae05-fdef310400e2

AFTER

Had to add to GDrive due to filesize

https://drive.google.com/file/d/1141h-OqqvOFH4Ok4yXISwKCzIs3TP9gZ/view?usp=sharing

TESTING INSTRUCTIONS

Added both integration and unit tests. For manual testing:

  1. Log in with a role that doesn't have can write on Tag but has can write on Dashboard.
  2. Edit the properties for a dashboard, changing the Tags config.
  3. Validate the change happens in the same network call and that errors are properly displayed.

ADDITIONAL INFORMATION

  • [ ] Has associated issue:
  • [ ] Required feature flags:
  • [ ] Changes UI
  • [ ] Includes DB Migration (follow approval process in SIP-59)
    • [ ] Migration is atomic, supports rollback & is backwards-compatible
    • [ ] Confirm DB migration upgrade and downgrade tested
    • [ ] Runtime estimates and downtime expectations provided
  • [ ] Introduces new feature or API
  • [ ] Removes existing feature or API

Vitor-Avila avatar May 18 '24 07:05 Vitor-Avila

Codecov Report

Attention: Patch coverage is 86.74699% with 11 lines in your changes missing coverage. Please review.

Project coverage is 70.28%. Comparing base (76d897e) to head (31aeaae). Report is 1094 commits behind head on master.

Files with missing lines Patch % Lines
...src/dashboard/components/PropertiesModal/index.tsx 42.85% 3 Missing and 1 partial :warning:
...d/src/explore/components/PropertiesModal/index.tsx 40.00% 3 Missing :warning:
superset/commands/chart/update.py 83.33% 2 Missing :warning:
superset/commands/dashboard/update.py 83.33% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #28570      +/-   ##
==========================================
+ Coverage   60.48%   70.28%   +9.79%     
==========================================
  Files        1931     1949      +18     
  Lines       76236    77586    +1350     
  Branches     8568     8731     +163     
==========================================
+ Hits        46114    54530    +8416     
+ Misses      28017    20927    -7090     
- Partials     2105     2129      +24     
Flag Coverage Δ
hive 49.08% <33.80%> (-0.08%) :arrow_down:
javascript 57.86% <41.66%> (+0.14%) :arrow_up:
mysql 77.19% <90.14%> (?)
postgres 77.32% <90.14%> (?)
presto 53.63% <33.80%> (-0.18%) :arrow_down:
python 83.52% <94.36%> (+20.04%) :arrow_up:
sqlite 76.77% <90.14%> (?)
unit 58.98% <66.19%> (+1.35%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 18 '24 07:05 codecov[bot]

Also @Vitor-Avila we need to update the calls for Query and Dataset to make sure they have the same ability to update the tags as well

hughhhh avatar May 21 '24 18:05 hughhhh

Also @Vitor-Avila we need to update the calls for Query and Dataset to make sure they have the same ability to update the tags as well

@hughhhh for Saved Queries I'm not sure if it makes sense since you can't really assign a Tag via the UI to a single query -- you can only assign tags to Saved Queries via the BULK SELECT (and in this case I think it makes sense to use the bulk_create approach which is already the case).

Tags are not fully supported with Datasets yet (not sure if the association works, but the Datasets list doesn't show Tags, the Datasets properties modal doesn't show tags, Datasets schemas don't have tags, etc) so this would be a bigger change a bit out of the scope of this PR.

Vitor-Avila avatar May 22 '24 03:05 Vitor-Avila