Skip to content

Commit

Permalink
feat: use computed prop for advanced role selection and create new la…
Browse files Browse the repository at this point in the history
…bels
  • Loading branch information
LukasHirt committed Aug 13, 2021
1 parent aefb690 commit 5900f3e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
appearance="raw"
justify-content="left"
gap-size="xsmall"
aria-describedby="files-recipient-role-btn-sr-hint"
>
<translate v-if="selectedRole.name === 'advancedRole'" key="advanced-permissions-select"
<translate v-if="isAdvancedRoleSelected" key="advanced-permissions-select"
>Invite with custom permissions</translate
>
<translate
v-else
key="role-select"
:translate-params="{ name: selectedRole.label.toLowerCase() }"
<translate v-else key="role-select" :translate-params="{ name: selectedRole.inlineLabel }"
>Invite as %{ name }</translate
>
<oc-icon name="expand_more" />
Expand All @@ -37,17 +33,14 @@
</oc-list>
</template>
</oc-drop>
<translate id="files-recipient-role-btn-sr-hint" tag="p" class="oc-invisible-sr">
Choose a role for all selected recipients.
</translate>
<template v-if="$_ocCollaborators_hasAdditionalPermissions">
<label v-if="selectedRole.name !== 'advancedRole'" class="oc-label oc-mt-s">
<label v-if="!isAdvancedRoleSelected" class="oc-label oc-mt-s">
<translate>Additional permissions</translate>
</label>
<additional-permissions
:available-permissions="selectedRole.additionalPermissions"
:collaborators-permissions="collaboratorsPermissions"
:class="{ 'oc-mt-s': selectedRole.name === 'advancedRole' }"
:class="{ 'oc-mt-s': isAdvancedRoleSelected }"
@permissionChecked="checkAdditionalPermissions"
/>
</template>
Expand Down Expand Up @@ -249,6 +242,10 @@ export default {
canResetExpirationDate() {
return !this.expirationDateEnforced && this.enteredExpirationDate
},
isAdvancedRoleSelected() {
return this.selectedRole.name === 'advancedRole'
}
},
Expand All @@ -261,7 +258,7 @@ export default {
created() {
if (
(this.existingRole && this.existingRole.name === 'advancedRole' && !this.selectedRole) ||
(this.selectedRole && this.selectedRole.name === 'advancedRole')
(this.selectedRole && this.isAdvancedRoleSelected)
) {
this.selectedRole = this.advancedRole
} else if (this.existingRole && !this.selectedRole) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default ({ isFolder = false, $gettext = returnOriginal, allowSharePerm =
{
name: 'viewer',
label: $gettext('Viewer'),
inlineLabel: $gettext('viewer'),
description: allowSharePerm
? $gettext('Download, preview and share')
: $gettext('Download and preview'),
Expand All @@ -25,6 +26,7 @@ export default ({ isFolder = false, $gettext = returnOriginal, allowSharePerm =
{
name: 'editor',
label: $gettext('Editor'),
inlineLabel: $gettext('editor'),
description: allowSharePerm
? $gettext('Upload, edit, delete, download, preview and share')
: $gettext('Upload, edit, delete, download and preview'),
Expand All @@ -39,6 +41,7 @@ export default ({ isFolder = false, $gettext = returnOriginal, allowSharePerm =
{
name: 'viewer',
label: $gettext('Viewer'),
inlineLabel: $gettext('viewer'),
description: allowSharePerm
? $gettext('Download, preview and share')
: $gettext('Download and preview'),
Expand All @@ -47,6 +50,7 @@ export default ({ isFolder = false, $gettext = returnOriginal, allowSharePerm =
{
name: 'editor',
label: $gettext('Editor'),
inlineLabel: $gettext('editor'),
description: allowSharePerm
? $gettext('Edit, download, preview and share')
: $gettext('Edit, download and preview'),
Expand Down
3 changes: 2 additions & 1 deletion packages/web-app-files/src/mixins/collaborators.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default {
advancedRole() {
const advancedRole = {
name: 'advancedRole',
label: this.$gettext('Advanced permissions'),
label: this.$gettext('Custom permissions'),
inlineLabel: this.$gettext('custom permissions'),
description: this.$gettext('Set detailed permissions'),
permissions: ['read'],
additionalPermissions: {
Expand Down

0 comments on commit 5900f3e

Please sign in to comment.