-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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: update Permissions for right nav #19051
Conversation
7d8416b
to
fea9336
Compare
36f736c
to
fe33eaf
Compare
@@ -105,19 +129,22 @@ const RightMenu = ({ | |||
label: t('Upload CSV to database'), | |||
name: 'Upload a CSV', | |||
url: '/csvtodatabaseview/form', | |||
perm: CSV_EXTENSIONS, | |||
perm: CSV_EXTENSIONS && showUploads, | |||
upload: 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.
would these need to be variable for the upload param?
3f476c0
to
611b14b
Compare
Codecov Report
@@ Coverage Diff @@
## master #19051 +/- ##
==========================================
+ Coverage 66.30% 66.47% +0.17%
==========================================
Files 1681 1681
Lines 64408 64465 +57
Branches 6593 6607 +14
==========================================
+ Hits 42704 42856 +152
+ Misses 20020 19915 -105
- Partials 1684 1694 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -105,19 +129,19 @@ const RightMenu = ({ | |||
label: t('Upload CSV to database'), | |||
name: 'Upload a CSV', | |||
url: '/csvtodatabaseview/form', | |||
perm: CSV_EXTENSIONS, | |||
perm: CSV_EXTENSIONS && showUploads, |
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.
Nice like the dual perms checking!
/testenv up |
@pkdotson Container image not yet published for this PR. Please try again when build is complete. |
@pkdotson Ephemeral environment creation failed. Please check the Actions logs for details. |
superset/databases/api.py
Outdated
$ref: '#/components/responses/500' | ||
""" | ||
dbs_with_uploads = ( | ||
db.session.query(Database).filter_by(allow_file_upload=True).all() |
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.
What happens if the ORM query fails? Can we add try catch to manage what we'd return to the user?
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.
You could prolly just wrap it in a try/catch with a SupersetException
then return a SIP-40 compliant error
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.
What would a SIP-40 compliant error be? Also it is currently failing a test with:
No fallback response defined for GET to http://localhost/api/v1/database/upload_enabled".]
seems to be in a fetchMock. Are those related?
@@ -63,6 +79,9 @@ const StyledAnchor = styled.a` | |||
|
|||
const { SubMenu } = Menu; | |||
|
|||
// stole this from findPermission.ts | |||
const ADMIN_ROLE_NAME = 'admin'; |
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.
do you want to export this from findPermission.ts
so that if it changes there, it will change here, too?
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.
Found a couple of nits, nothing blocking
useEffect(() => { | ||
hasFileUploadEnabled(); | ||
}, []); |
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.
useEffect(() => { | |
hasFileUploadEnabled(); | |
}, []); | |
useEffect(() => hasFileUploadEnabled(), []); |
Small nit, not blocking, but this can be written on one line.
@@ -165,14 +201,39 @@ const RightMenu = ({ | |||
setShowModal(false); | |||
}; | |||
|
|||
const isDisabled = isUserAdmin && !allowUploads; | |||
|
|||
const tooltipText = "Enable 'Allow data upload' in any database's settings"; |
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.
Should this string be t()
translated?
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.
yes! Thank you.
5eb27e4
to
7527656
Compare
2945ef1
to
be027d0
Compare
selectable={false} | ||
mode="horizontal" | ||
onClick={handleMenuSelection} | ||
onOpenChange={() => hasFileUploadEnabled()} |
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.
nit, this can just be
onOpenChange={hasFileUploadEnabled}
but also when testing it looks like this is also triggering on close, which you prob don't need.
/testenv up |
@yousoph Ephemeral environment spinning up at http://34.217.3.104:8080. Credentials are |
b0a6d45
to
5d53bc8
Compare
…erset into ch36353_upload_menus
5d53bc8
to
f5cea78
Compare
Ephemeral environment shutdown and build artifacts deleted. |
/testenv up |
@AAfghahi Ephemeral environment spinning up at http://54.245.4.253:8080. Credentials are |
c1d1e00
to
e886b54
Compare
@AAfghahi I think we need to add these perms to the database crud view dropdown as well. |
Screen.Recording.2022-04-11.at.12.21.14.PM.mov |
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!
733d5d6
to
d27a8c5
Compare
b485d0d
to
7bfbe43
Compare
7bfbe43
to
0d2ec22
Compare
Ephemeral environment shutdown and build artifacts deleted. |
* draft pr * finished styling * add filter * added testing * added tests * added permissions tests * Empty-Commit * new test * Update superset-frontend/src/views/components/MenuRight.tsx Co-authored-by: Elizabeth Thompson <eschutho@gmail.com> * revisions * added to CRUD view Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
SUMMARY
Updating the permissions in the right nav bar to check that a user can upload csv and excel files to a database before showing them the options. Makes it so that non-Admin users only see menu items when they have a shared database.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
After:
as Admin
Screen.Recording.2022-03-09.at.1.35.55.PM.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION