diff --git a/apps/files_sharing/js/dist/files_sharing_tab.js b/apps/files_sharing/js/dist/files_sharing_tab.js index a6baedec6e884d9a6ebab213f1e2442af563303d..30bf61397606bf174714714592626a6787e9f0a8 100644 Binary files a/apps/files_sharing/js/dist/files_sharing_tab.js and b/apps/files_sharing/js/dist/files_sharing_tab.js differ diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 50ba39564ba428ac54111a7e8cb31703b705c312..78b2eb1bc536d9fa1e313428e92bcc0a535e1ed6 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1079,6 +1079,9 @@ class ShareAPIController extends OCSController { // only link shares have labels if ($share->getShareType() === IShare::TYPE_LINK && $label !== null) { + if (strlen($label) > 255) { + throw new OCSBadRequestException("Maxmimum label length is 255"); + } $share->setLabel($label); } diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue index 50d731ca3134bae9f9e48c9aeb2bfd71e2231401..67e5e4ae48d5c1824ea74e6446159af2a5376304 100644 --- a/apps/files_sharing/src/components/SharingEntryLink.vue +++ b/apps/files_sharing/src/components/SharingEntryLink.vue @@ -26,7 +26,7 @@ :class="isEmailShareType ? 'icon-mail-white' : 'icon-public-white'" class="sharing-entry__avatar" /> <div class="sharing-entry__desc"> - <h5>{{ title }}</h5> + <h5 :title="title">{{ title }}</h5> </div> <!-- clipboard --> @@ -124,6 +124,24 @@ @close="onMenuClose"> <template v-if="share"> <template v-if="share.canEdit"> + <!-- 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" + :placeholder="t('files_sharing', 'Share label')" + :aria-label="t('files_sharing', 'Share label')" + :value="share.newLabel || share.label" + icon="icon-edit" + maxlength="255" + @update:value="onLabelChange" + @submit="onLabelSubmit" /> <!-- folder --> <template v-if="isFolder && fileHasCreatePermission && config.isPublicUploadEnabled"> <ActionRadio :checked="sharePermissions === publicUploadRValue" @@ -391,7 +409,9 @@ export default { }) } if (this.share.label && this.share.label.trim() !== '') { - return this.share.label + return t('files_sharing', 'Share link ({label})', { + label: this.share.label.trim() + }) } if (this.isEmailShareType) { return this.share.shareWith @@ -712,6 +732,25 @@ export default { this.queueUpdate('permissions') }, + /** + * Label changed, let's save it to a different key + * @param {String} label the share label + */ + onLabelChange(label) { + this.$set(this.share, 'newLabel', label.trim()) + }, + + /** + * When the note change, we trim, save and dispatch + */ + onLabelSubmit() { + if (typeof this.share.newLabel === 'string') { + this.share.label = this.share.newLabel + this.$delete(this.share, 'newLabel') + this.queueUpdate('label') + } + }, + /** * Generate a valid policy password or * request a valid password if password_policy @@ -856,6 +895,13 @@ export default { justify-content: space-between; padding: 8px; line-height: 1.2em; + overflow: hidden; + + h5 { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + } } &:not(.sharing-entry--share) &__actions { diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js index 6bcf9fc79f7f1d7162ef1f2b02f2f15afe5c1bf5..31d37c7980d5f24f69973524319b47d8f21c0d11 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -274,6 +274,7 @@ export default { case 'password': case 'pending': case 'expireDate': + case 'label': case 'note': { // show error this.$set(this.errors, property, message) diff --git a/apps/files_sharing/src/models/Share.js b/apps/files_sharing/src/models/Share.js index 92ea314071f3eb9bd99a0ee3270992da5ffc9bd8..bf1b2ec9ac3065951644b615f1bca55249dff2c5 100644 --- a/apps/files_sharing/src/models/Share.js +++ b/apps/files_sharing/src/models/Share.js @@ -253,6 +253,29 @@ export default class Share { this.#share.note = note } + /** + * Get the share label if any + * Should only exist on link shares + * + * @returns {string} + * @readonly + * @memberof Share + */ + get label() { + return this.#share.label + } + + /** + * Set the share label if any + * Should only be set on link shares + * + * @param {string} label the label + * @memberof Share + */ + set label(label) { + this.#share.label = label + } + /** * Have a mail been sent * @@ -488,9 +511,6 @@ export default class Share { } // TODO: SORT THOSE PROPERTIES - get label() { - return this.#share.label - } get parent() { return this.#share.parent