-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
13 changed files
with
567 additions
and
363 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
apps/files/src/components/Collaborators/AdditionalPermissions.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template> | ||
<oc-grid gutter="small"> | ||
<label v-for="permission in permissions" :key="permission.name"> | ||
<oc-checkbox | ||
class="uk-margin-xsmall-right" | ||
v-model="permission.value" | ||
@change="permissionChecked" | ||
/> | ||
{{ permission.description }} | ||
</label> | ||
</oc-grid> | ||
</template> | ||
|
||
<script> | ||
import filterObject from 'filter-obj' | ||
export default { | ||
name: 'AdditionalPermissions', | ||
props: { | ||
/** | ||
* Available permissions for the role | ||
*/ | ||
availablePermissions: { | ||
type: Object, | ||
required: true | ||
}, | ||
/** | ||
* Additional permissions of the collaborator with values | ||
*/ | ||
collaboratorsPermissions: { | ||
type: Object, | ||
required: false | ||
} | ||
}, | ||
computed: { | ||
permissions () { | ||
const permissions = this.availablePermissions | ||
for (const permission in permissions) { | ||
if (this.collaboratorsPermissions && this.collaboratorsPermissions[permission]) { | ||
permissions[permission].value = true | ||
continue | ||
} | ||
permissions[permission].value = false | ||
} | ||
return permissions | ||
} | ||
}, | ||
methods: { | ||
permissionChecked () { | ||
const selectedPermissions = [] | ||
const permissions = filterObject(this.permissions, (key, value) => { | ||
return value.value === true | ||
}) | ||
for (const permission in permissions) { | ||
selectedPermissions.push(permission) | ||
} | ||
this.$emit('permissionChecked', selectedPermissions) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
apps/files/src/components/Collaborators/CollaboratorsEditOptions.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<oc-grid gutter="small" childWidth="1-1"> | ||
<roles-select | ||
:selectedRole="role" | ||
@roleSelected="selectRole" | ||
/> | ||
<additional-permissions | ||
:availablePermissions="role.additionalPermissions" | ||
:collaboratorsPermissions="collaboratorsPermissions" | ||
@permissionChecked="checkAdditionalPermissions" | ||
/> | ||
</oc-grid> | ||
</template> | ||
|
||
<script> | ||
import collaboratorsMixins from '../../mixins/collaborators' | ||
const RolesSelect = () => import('./RolesSelect.vue') | ||
const AdditionalPermissions = () => import('./AdditionalPermissions.vue') | ||
export default { | ||
name: 'CollaboratorsEditOptions', | ||
mixins: [ | ||
collaboratorsMixins | ||
], | ||
props: { | ||
existingRole: { | ||
type: Object, | ||
required: false | ||
}, | ||
collaboratorsPermissions: { | ||
type: Object, | ||
required: false | ||
} | ||
}, | ||
components: { | ||
RolesSelect, | ||
AdditionalPermissions | ||
}, | ||
data () { | ||
return { | ||
selectedRole: null, | ||
additionalPermissions: null | ||
} | ||
}, | ||
computed: { | ||
role () { | ||
// Returns default role | ||
if (!this.existingRole && !this.selectedRole) { | ||
const defaultRole = this.roles[Object.keys(this.roles)[0]] | ||
this.selectRole(defaultRole, false) | ||
return defaultRole | ||
} | ||
if ( | ||
( | ||
this.existingRole && this.existingRole.name === 'advancedRole' | ||
) || ( | ||
this.selectedRole && this.selectedRole.name === 'advancedRole' | ||
) | ||
) { | ||
this.selectRole(this.advancedRole, false) | ||
return this.advancedRole | ||
} | ||
if (this.existingRole && !this.selectedRole) { | ||
this.selectRole(this.existingRole, false) | ||
return this.existingRole | ||
} | ||
return this.selectedRole | ||
} | ||
}, | ||
methods: { | ||
selectRole (role, propagate = true) { | ||
this.selectedRole = role | ||
this.$emit('optionChange', { role: this.selectedRole, permissions: this.additionalPermissions, propagate: propagate }) | ||
}, | ||
checkAdditionalPermissions (permissions) { | ||
this.additionalPermissions = permissions | ||
this.$emit('optionChange', { role: this.selectedRole, permissions: this.additionalPermissions }) | ||
} | ||
} | ||
} | ||
</script> |
Oops, something went wrong.