-
Notifications
You must be signed in to change notification settings - Fork 159
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
Refactor collaborators to use helper classes and to map permissions #2373
Conversation
@PVince81 Let's see how tests will behave now. PR should be ready for review. There is still some technical debt left but it is already getting really big so let's follow up on that in new PRs when we start working on the new "version" of collaborators. I'm leaving all the commits in case it could maybe make it a little bit easier to review. When it will be ready to merge - I'll squash them. |
Agh... need to bring back some references, classes and adjust the custom role to advanced permissions. Code still can be reviewed, I'll then do it in one commit together with potential changes. |
let bitmask = 0 | ||
|
||
for (const permission of role.permissions) { | ||
bitmask += permissionsBitmask[permission] |
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.
use |=
to be safe
@@ -116,7 +83,11 @@ export default { | |||
}, | |||
|
|||
originalRole () { | |||
return this.roles[this.collaborator.role].tag | |||
if (this.collaborator.role.name === 'unknownRole') { |
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 just call the string "advancedRole" for consistency
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.
or have it return null
for the role
apps/files/src/components/Collaborators/AdditionalPermissions.vue
Outdated
Show resolved
Hide resolved
apps/files/src/components/Collaborators/AdditionalPermissions.vue
Outdated
Show resolved
Hide resolved
apps/files/src/components/Collaborators/CollaboratorsEditOptions.vue
Outdated
Show resolved
Hide resolved
}, | ||
methods: { | ||
selectRole (role) { | ||
this.$emit('roleSelected', role) |
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.
optional: would it make sense to rename to "input" event ? as far as I remember Vue JS will automatically map the value to the ":model" directive if used
|
||
// Get bitmask of basic permissions | ||
currentRole.permissions.forEach(permission => { | ||
rolePermissionsBitmask += permissionsBitmask[permission] |
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.
use |=
@@ -78,6 +98,16 @@ export default { | |||
.finally(_ => { | |||
this.loading = false | |||
}) | |||
}, | |||
|
|||
collaboratorOptionChanged ({ role, permissions, propagate = 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.
I suggest to have an attribute on the collaboratorRoles file that tells the name of the default role.
Then the parent view can pre-set the default role to this.selectedRole
to avoid the "propagate = false" gymnastics.
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.
also I assume that the roles API in the future will also provide a field for the default role (or we make it default to the one with the least permissions?)
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.
=> later
if (s.permissions === '3' || s.permissions === '15' || s.permissions === '19' || s.permissions === '31') { | ||
share.role = 'editor' | ||
} | ||
share.role = bitmaskToRole(s.permissions, file.type === 'folder') |
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.
if we inject the "roles" object as discussed above, the bitmaskToRole
does not need to know any more if folder or not because said logic would be done by the caller.
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.
=> later
apps/files/src/components/Collaborators/AdditionalPermissions.vue
Outdated
Show resolved
Hide resolved
b8a24c7
to
1fc797a
Compare
Added permissionsToRole function and restructured roles object Fixed wrong type in jsdocs Changed functions to interact with bitmask Moved collaborators mixins into mixins folder and used roles helper file Moved roles back into mixin Move permissions bitmask to own file and introduce permissions sets for files and folders Use custom permissions object Split collaborators into smaller components Move permissions bitmask back to collaborators helper file Added object filter package and emit events from child components Refactored default role Added current role Use smaller components in collaborator component Added translations Added docs and provide default function to return original strings Added custom role Implemented bitmaskToRole function Bring bitmaskToRole into store Fixed displaying of custom role Fixed display of existing role Fixed roleToBitmask function and add new collaborators method Fixed passing of file into buildShare function Fixed default role Implement values of additional permissions Add read permission to advanced role Implemented change of collaborator Fixed parentheses around group suffix) Implemented requested changes Renamed collaboratorRoles
1fc797a
to
ea2d4a1
Compare
💥 Acceptance tests SharingPermissionsUsers failed. Please find the screenshots inside ...https://drone.owncloud.com/owncloud/phoenix/6549/
|
💥 Acceptance tests SharingPermissionsGroups failed. Please find the screenshots inside ...https://drone.owncloud.com/owncloud/phoenix/6549/
|
ea2d4a1
to
11774c5
Compare
|
Add permissions only if they exist for the role Removed eslint rule for epect Fixed epectations for custom role Check permission for correct collaborator
11774c5
to
098f71a
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.
👍
Description
Introduced helper functions roleToBitmask and bitmaskToRole, separated collaborators into smaller components and small refactoring.
Related Issue
Motivation and Context
Cleaner code
How Has This Been Tested?
Types of changes
Checklist: