-
Notifications
You must be signed in to change notification settings - Fork 14k
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
chore(tags): Handle tagging as part of asset update call #28570
Conversation
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -284,7 +285,9 @@ class ChartPutSchema(Schema): | |||
) | |||
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False) | |||
external_url = fields.String(allow_none=True) | |||
tags = fields.Nested(TagSchema, many=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are we removing the TagSchema
reference here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good catch -- I scanned for un-used imports but didn't realize that TagSchema
was actually defined in this same file. I'll remove its definition in a follow up commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll hold on committing this change ☝️ until I get your feedback on the other comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we should prolly centralize TagSchema
somewhere it could be used in all the resource update schemas
superset/commands/utils.py
Outdated
|
||
|
||
def validate_tags( | ||
object_type: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't this be ENUM of resource CHART || DASHBOARD || QUERY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def could! I was already using ObjectType
for the update_tags
method, but here thought about going with string
because I'm using security_manager.can_access
to check if the user has the required perm, which is case sensitive. We have two options here:
- Create a new
enum
with:
class AssetTypes(enum.Enum):
CHART = "Chart"
DASHBOARD = "Dashboard"
- Use the existing
ObjectType
and then callcan_access
usingcapitalize()
:
if not security_manager.can_access("can_tag", object_type.name.capitalize()):
@hughhhh would you have any preferences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with #2 using ObjectType
enum
Also @Vitor-Avila we need to update the calls for |
@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 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 LGTM
(cherry picked from commit 0fdb4b7)
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:
write access on $asset_type
have the impression they can change the tags configuration (since they can save it).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
Before.mov
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:
can write on Tag
but hascan write on Dashboard
.ADDITIONAL INFORMATION