Skip to content

Commit

Permalink
NMC-434 - changed the process of file sharing for internal and extern…
Browse files Browse the repository at this point in the history
…al sharee

Signed-off-by: Yogesh Shejwadkar <yogesh.shejwadkar@t-systems.com>
  • Loading branch information
TSI-yogeshshejwadkar committed Sep 14, 2021
1 parent d314560 commit 9e5264f
Show file tree
Hide file tree
Showing 9 changed files with 1,034 additions and 316 deletions.
100 changes: 76 additions & 24 deletions apps/files_sharing/src/components/SharingEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@
<span>{{ share.status.message || '' }}</span>
</p>
</component>
<Actions
<Actions v-if="open === false"
menu-align="right"
class="sharing-entry__actions"
@close="onMenuClose">
<<<<<<< HEAD
<template v-if="share.canEdit">
<!-- edit permission -->
<ActionCheckbox
Expand Down Expand Up @@ -135,6 +136,22 @@
</template>
</template>

=======
<ActionButton v-if="share.canEdit"
icon="icon-settings"
:disabled="saving"
:share="share"
@click.prevent="editPermissions">
{{ t('files_sharing', 'Advanced permission') }}
</ActionButton>
<ActionButton v-if="share.canEdit"
icon="icon-mail"
:disabled="saving"
:share="share"
@click.prevent="editNotes">
{{ t('files_sharing', 'Send new mail') }}
</ActionButton>
>>>>>>> e994a1f60d... NMC-434 - changed the process of file sharing for internal and external sharee
<ActionButton v-if="share.canDelete"
icon="icon-close"
:disabled="saving"
Expand Down Expand Up @@ -181,10 +198,33 @@ export default {
permissionsDelete: OC.PERMISSION_DELETE,
permissionsRead: OC.PERMISSION_READ,
permissionsShare: OC.PERMISSION_SHARE,

publicUploadRWValue: OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE | OC.PERMISSION_READ | OC.PERMISSION_DELETE,
publicUploadRValue: OC.PERMISSION_READ,
publicUploadWValue: OC.PERMISSION_CREATE,
publicUploadEValue: OC.PERMISSION_UPDATE | OC.PERMISSION_READ,
}
},

computed: {
/**
* Return the current share permissions
* We always ignore the SHARE permission as this is used for the
* federated sharing.
* @returns {number}
*/
sharePermissions() {
return this.share.permissions & ~OC.PERMISSION_SHARE
},

/**
* Generate a unique random id for this SharingEntry only
* @returns {string}
*/
randomId() {
return Math.random().toString(27).substr(2)
},

title() {
let title = this.share.shareWithDisplayName
if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_GROUP) {
Expand Down Expand Up @@ -348,28 +388,28 @@ export default {
* Does the current share have an expiration date
* @returns {boolean}
*/
hasExpirationDate: {
get() {
return this.config.isDefaultInternalExpireDateEnforced || !!this.share.expireDate
},
set(enabled) {
this.share.expireDate = enabled
? this.config.defaultInternalExpirationDateString !== ''
? this.config.defaultInternalExpirationDateString
: moment().format('YYYY-MM-DD')
: ''
},
},

dateMaxEnforced() {
if (!this.isRemote) {
return this.config.isDefaultInternalExpireDateEnforced
&& moment().add(1 + this.config.defaultInternalExpireDate, 'days')
} else {
return this.config.isDefaultRemoteExpireDateEnforced
&& moment().add(1 + this.config.defaultRemoteExpireDate, 'days')
}
},
// hasExpirationDate: {
// get() {
// return this.config.isDefaultInternalExpireDateEnforced || !!this.share.expireDate
// },
// set(enabled) {
// this.share.expireDate = enabled
// ? this.config.defaultInternalExpirationDateString !== ''
// ? this.config.defaultInternalExpirationDateString
// : moment().format('YYYY-MM-DD')
// : ''
// },
// },

// dateMaxEnforced() {
// if (!this.isRemote) {
// return this.config.isDefaultInternalExpireDateEnforced
// && moment().add(1 + this.config.defaultInternalExpireDate, 'days')
// } else {
// return this.config.isDefaultRemoteExpireDateEnforced
// && moment().add(1 + this.config.defaultRemoteExpireDate, 'days')
// }
// },

/**
* @returns {bool}
Expand Down Expand Up @@ -404,6 +444,18 @@ export default {
onMenuClose() {
this.onNoteSubmit()
},

editPermissions() {
this.$store.commit('addFromInput', false)
this.$store.commit('addShare', this.share)
this.$store.commit('addCurrentTab', 'permissions')
},

editNotes() {
this.$store.commit('addFromInput', false)
this.$store.commit('addShare', this.share)
this.$store.commit('addCurrentTab', 'notes')
},
},
}
</script>
Expand All @@ -412,7 +464,7 @@ export default {
.sharing-entry {
display: flex;
align-items: center;
height: 44px;
min-height: 44px;
&__desc {
display: flex;
flex-direction: column;
Expand Down
185 changes: 24 additions & 161 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,160 +131,6 @@
:open.sync="open"
@close="onMenuClose">
<template v-if="share">
<template v-if="share.canEdit && canReshare">
<!-- Custom Label -->
<ActionInput
ref="label"
v-tooltip.auto="{
content: errors.label,
show: errors.label,
trigger: 'manual',
defaultContainer: '.app-sidebar'
}"
:class="{ error: errors.label }"
:disabled="saving"
:aria-label="t('files_sharing', 'Share label')"
:value="share.newLabel !== undefined ? share.newLabel : share.label"
icon="icon-edit"
maxlength="255"
@update:value="onLabelChange"
@submit="onLabelSubmit">
{{ t('files_sharing', 'Share label') }}
</ActionInput>
<!-- folder -->
<template v-if="isFolder && fileHasCreatePermission && config.isPublicUploadEnabled">
<ActionRadio :checked="sharePermissions === publicUploadRValue"
:value="publicUploadRValue"
:name="randomId"
:disabled="saving"
@change="togglePermissions">
{{ t('files_sharing', 'Read only') }}
</ActionRadio>
<ActionRadio :checked="sharePermissions === publicUploadRWValue"
:value="publicUploadRWValue"
:disabled="saving"
:name="randomId"
@change="togglePermissions">
{{ t('files_sharing', 'Allow upload and editing') }}
</ActionRadio>
<ActionRadio :checked="sharePermissions === publicUploadWValue"
:value="publicUploadWValue"
:disabled="saving"
:name="randomId"
class="sharing-entry__action--public-upload"
@change="togglePermissions">
{{ t('files_sharing', 'File drop (upload only)') }}
</ActionRadio>
</template>

<!-- file -->
<ActionCheckbox v-else
:checked.sync="canUpdate"
:disabled="saving"
@change="queueUpdate('permissions')">
{{ t('files_sharing', 'Allow editing') }}
</ActionCheckbox>

<ActionCheckbox
:checked.sync="share.hideDownload"
:disabled="saving"
@change="queueUpdate('hideDownload')">
{{ t('files_sharing', 'Hide download') }}
</ActionCheckbox>

<!-- password -->
<ActionCheckbox :checked.sync="isPasswordProtected"
:disabled="config.enforcePasswordForPublicLink || saving"
class="share-link-password-checkbox"
@uncheck="onPasswordDisable">
{{ config.enforcePasswordForPublicLink
? t('files_sharing', 'Password protection (enforced)')
: t('files_sharing', 'Password protect') }}
</ActionCheckbox>
<ActionInput v-if="isPasswordProtected"
ref="password"
v-tooltip.auto="{
content: errors.password,
show: errors.password,
trigger: 'manual',
defaultContainer: '#app-sidebar'
}"
class="share-link-password"
:class="{ error: errors.password}"
:disabled="saving"
:required="config.enforcePasswordForPublicLink"
:value="hasUnsavedPassword ? share.newPassword : '***************'"
icon="icon-password"
autocomplete="new-password"
:type="hasUnsavedPassword ? 'text': 'password'"
@update:value="onPasswordChange"
@submit="onPasswordSubmit">
{{ t('files_sharing', 'Enter a password') }}
</ActionInput>

<!-- password protected by Talk -->
<ActionCheckbox v-if="isPasswordProtectedByTalkAvailable"
:checked.sync="isPasswordProtectedByTalk"
:disabled="!canTogglePasswordProtectedByTalkAvailable || saving"
class="share-link-password-talk-checkbox"
@change="onPasswordProtectedByTalkChange">
{{ t('files_sharing', 'Video verification') }}
</ActionCheckbox>

<!-- expiration date -->
<ActionCheckbox :checked.sync="hasExpirationDate"
:disabled="config.isDefaultExpireDateEnforced || saving"
class="share-link-expire-date-checkbox"
@uncheck="onExpirationDisable">
{{ config.isDefaultExpireDateEnforced
? t('files_sharing', 'Expiration date (enforced)')
: t('files_sharing', 'Set expiration date') }}
</ActionCheckbox>
<ActionInput v-if="hasExpirationDate"
ref="expireDate"
v-tooltip.auto="{
content: errors.expireDate,
show: errors.expireDate,
trigger: 'manual',
defaultContainer: '#app-sidebar'
}"
class="share-link-expire-date"
:class="{ error: errors.expireDate}"
:disabled="saving"
:first-day-of-week="firstDay"
:lang="lang"
:value="share.expireDate"
value-type="format"
icon="icon-calendar-dark"
type="date"
:disabled-date="disabledDate"
@update:value="onExpirationChange">
{{ t('files_sharing', 'Enter a date') }}
</ActionInput>

<!-- note -->
<ActionCheckbox :checked.sync="hasNote"
:disabled="saving"
@uncheck="queueUpdate('note')">
{{ t('files_sharing', 'Note to recipient') }}
</ActionCheckbox>
<ActionTextEditable v-if="hasNote"
ref="note"
v-tooltip.auto="{
content: errors.note,
show: errors.note,
trigger: 'manual',
defaultContainer: '#app-sidebar'
}"
:class="{ error: errors.note}"
:disabled="saving"
:placeholder="t('files_sharing', 'Enter a note for the share recipient')"
:value="share.newNote || share.note"
icon="icon-edit"
@update:value="onNoteChange"
@submit="onNoteSubmit" />
</template>

<!-- external sharing via url (social...) -->
<ActionLink v-for="({icon, url, name}, index) in externalActions"
:key="index"
Expand All @@ -293,6 +139,18 @@
target="_blank">
{{ name }}
</ActionLink>
<ActionButton v-if="share.canEdit"
icon="icon-settings"
:disabled="saving"
@click.prevent="editPermissions">
{{ t('files_sharing', 'Advanced permission') }}
</ActionButton>
<ActionButton v-if="share.canEdit"
icon="icon-mail"
:disabled="saving"
@click.prevent="editNotes">
{{ t('files_sharing', 'Send new mail') }}
</ActionButton>

<ActionButton v-if="share.canDelete"
icon="icon-close"
Expand Down Expand Up @@ -328,10 +186,8 @@ import Vue from 'vue'

import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import ActionCheckbox from '@nextcloud/vue/dist/Components/ActionCheckbox'
import ActionRadio from '@nextcloud/vue/dist/Components/ActionRadio'
import ActionInput from '@nextcloud/vue/dist/Components/ActionInput'
import ActionText from '@nextcloud/vue/dist/Components/ActionText'
import ActionTextEditable from '@nextcloud/vue/dist/Components/ActionTextEditable'
import ActionLink from '@nextcloud/vue/dist/Components/ActionLink'
import Actions from '@nextcloud/vue/dist/Components/Actions'
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
Expand All @@ -348,11 +204,9 @@ export default {
Actions,
ActionButton,
ActionCheckbox,
ActionRadio,
ActionInput,
ActionLink,
ActionText,
ActionTextEditable,
Avatar,
},

Expand Down Expand Up @@ -397,8 +251,6 @@ export default {
},
/**
* Generate a unique random id for this SharingEntryLink only
* This allows ActionRadios to have the same name prop
* but not to impact others SharingEntryLink
* @returns {string}
*/
randomId() {
Expand Down Expand Up @@ -898,8 +750,19 @@ export default {
// YET. We can safely delete the share :)
this.$emit('remove:share', this.share)
},
},

editPermissions() {
this.$store.commit('addFromInput', false)
this.$store.commit('addShare', this.share)
this.$store.commit('addCurrentTab', 'permissions')
},

editNotes() {
this.$store.commit('addFromInput', false)
this.$store.commit('addShare', this.share)
this.$store.commit('addCurrentTab', 'notes')
},
},
}
</script>

Expand Down
Loading

0 comments on commit 9e5264f

Please sign in to comment.