-
Notifications
You must be signed in to change notification settings - Fork 3
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
Object Permissions #23
Conversation
Code Climate has analyzed commit 39051a3 and detected 11 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 67.0% (-15.5% change). View more on Code Climate. |
39051a3
to
16ecd0d
Compare
await Promise.all([ | ||
bucketStore.getBucketPermissionsForUser(route.query.bucketId?.toString() || ''), | ||
objectStore.listObjects({ bucketId: route.query.bucketId }) |
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 if you directly navigate to a object list landing page, you will have your perms for that bucket populated.
d617137
to
4e34a6f
Compare
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.
Semantically looks good. Just a few comments for consideration.
for (const [, value] of Object.entries(Permissions)) { | ||
await objectService.deletePermission(bucketId, { | ||
userId, | ||
permCode: value, | ||
}); | ||
} |
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.
Two thoughts:
- If we're only using the values and don't need the key/value pairing, we should probably be using
Object.values()
instead.
for (const value of Object.values(Permissions)) {
- Since this looks like a general async dispatcher pattern, it may be better to wrap this into a
Promise.all()
for synchronization purposes:
await Promise.all(
Object.values(Permissions)
.map(perm => objectService.deletePermission(bucketId, {
userId,
permCode: value,
}));
);
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.
Used the same logic as in existing bucketStore removeBucketUser.
Think there's possibly a way to take in the service method and have this permission logic extracted to a common util function (for buckets and objects). So someone could take a look at that at some point and implement your logic above for both (ideally in one palce)
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.
a lot of good stuff in here!
frontend/src/store/objectStore.ts
Outdated
|
||
// Add the permissions to each object list item |
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 think in line 77 we are removing the perms and then adding them again here in line 91. not sure if that could be optimized.
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 think the line 77 being referred to is just stashing the specific IDs from the permissions to fetch the objects? So not removing them?
(file has changed since so line 77 might be something else from original 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.
my point was: we are looping through permResponse in line 77, the perms can be added there instead of doing another loop. only mention this because for a bucket full of objects this could impact the speed
just ran this in the browser and it's looking good.
update:
|
Signed-off-by: Lucas ONeil <[email protected]>
Signed-off-by: Lucas ONeil <[email protected]>
Remove extra merge line Signed-off-by: Lucas ONeil <[email protected]>
Signed-off-by: Lucas ONeil <[email protected]>
Signed-off-by: Lucas ONeil <[email protected]>
4e34a6f
to
b57f8d1
Compare
Signed-off-by: Lucas ONeil <[email protected]>
Signed-off-by: Lucas ONeil <[email protected]>
Signed-off-by: Lucas ONeil <[email protected]>
Description
Allow users to set object permissions on files they have manage permissions for. The "Add User" part is on an upcoming ticket.
Don't show the actions on a file that you don't have the corresponding permission for.
Additionally a fix for
https://apps.nrs.gov.bc.ca/int/jira/browse/SHOWCASE-3012
Types of changes
New feature (non-breaking change which adds functionality)
Checklist
Further comments
There's probably some efficiencies that can be done here. This is mostly the same code as the bucket permissions screen and table, but with enough changes I couldn't quickly figure out how to generalize it. There's some differences between the 2 things.
Possibly could be refactored to a common component and/or composable, but need to be sure the behavior would stay the same.
At the very least the component SCSS should be extracted out so that it's not duplicated. Would need to decide if above path would be looked at, if not, move to global scss for this type of checkbox table.