Skip to content

Commit 4c51cfd

Browse files
authored
Merge pull request #63658 from nextcloud/backport/63227/stable34
[stable34] Fix cancelling the customization of a share
2 parents 0dd5b48 + d401166 commit 4c51cfd

22 files changed

Lines changed: 196 additions & 172 deletions

apps/files_sharing/src/components/SharingEntry.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,6 @@ export default {
128128
return (typeof this.share.status === 'object' && !Array.isArray(this.share.status))
129129
},
130130
},
131-
132-
methods: {
133-
/**
134-
* Save potential changed data on menu close
135-
*/
136-
onMenuClose() {
137-
this.onNoteSubmit()
138-
},
139-
},
140131
}
141132
</script>
142133

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@
147147
class="sharing-entry__actions"
148148
:aria-label="actionsTooltip"
149149
menu-align="right"
150-
:open.sync="open"
151-
@close="onMenuClose">
150+
:open.sync="open">
152151
<template v-if="share">
153152
<template v-if="share.canEdit && canReshare">
154153
<NcActionButton
@@ -452,30 +451,6 @@ export default {
452451
return OC.appswebroots.spreed !== undefined
453452
},
454453
455-
/**
456-
* Is it possible to protect the password by Talk?
457-
*
458-
* @return {boolean}
459-
*/
460-
isPasswordProtectedByTalkAvailable() {
461-
return this.isPasswordProtected && this.isTalkEnabled
462-
},
463-
464-
/**
465-
* Is the current share password protected by Talk?
466-
*
467-
* @return {boolean}
468-
*/
469-
isPasswordProtectedByTalk: {
470-
get() {
471-
return this.share.sendPasswordByTalk
472-
},
473-
474-
async set(enabled) {
475-
this.share.sendPasswordByTalk = enabled
476-
},
477-
},
478-
479454
/**
480455
* Is the current share an email share ?
481456
*
@@ -487,20 +462,6 @@ export default {
487462
: false
488463
},
489464
490-
canTogglePasswordProtectedByTalkAvailable() {
491-
if (!this.isPasswordProtected) {
492-
// Makes no sense
493-
return false
494-
} else if (this.isEmailShareType && !this.hasUnsavedPassword) {
495-
// For email shares we need a new password in order to enable or
496-
// disable
497-
return false
498-
}
499-
500-
// Anything else should be fine
501-
return true
502-
},
503-
504465
/**
505466
* Pending data.
506467
* If the share still doesn't have an id, it is not synced
@@ -863,46 +824,6 @@ export default {
863824
}
864825
},
865826
866-
/**
867-
* Menu have been closed or password has been submitted.
868-
* The only property that does not get
869-
* synced automatically is the password
870-
* So let's check if we have an unsaved
871-
* password.
872-
* expireDate is saved on datepicker pick
873-
* or close.
874-
*/
875-
onPasswordSubmit() {
876-
if (this.hasUnsavedPassword) {
877-
this.share.newPassword = this.share.newPassword.trim()
878-
this.queueUpdate('password')
879-
}
880-
},
881-
882-
/**
883-
* Update the password along with "sendPasswordByTalk".
884-
*
885-
* If the password was modified the new password is sent; otherwise
886-
* updating a mail share would fail, as in that case it is required that
887-
* a new password is set when enabling or disabling
888-
* "sendPasswordByTalk".
889-
*/
890-
onPasswordProtectedByTalkChange() {
891-
if (this.hasUnsavedPassword) {
892-
this.share.newPassword = this.share.newPassword.trim()
893-
}
894-
895-
this.queueUpdate('sendPasswordByTalk', 'password')
896-
},
897-
898-
/**
899-
* Save potential changed data on menu close
900-
*/
901-
onMenuClose() {
902-
this.onPasswordSubmit()
903-
this.onNoteSubmit()
904-
},
905-
906827
/**
907828
* @param {boolean} enabled True if expiration is enabled
908829
*/

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -261,27 +261,6 @@ export default {
261261
this.share.expireDate = this.formatDateToString(parsedDate)
262262
},
263263

264-
/**
265-
* Note changed, let's save it to a different key
266-
*
267-
* @param {string} note the share note
268-
*/
269-
onNoteChange(note) {
270-
this.$set(this.share, 'newNote', note.trim())
271-
},
272-
273-
/**
274-
* When the note change, we trim, save and dispatch
275-
*
276-
*/
277-
onNoteSubmit() {
278-
if (this.share.newNote) {
279-
this.share.note = this.share.newNote
280-
this.$delete(this.share, 'newNote')
281-
this.queueUpdate('note')
282-
}
283-
},
284-
285264
/**
286265
* Delete share button handler
287266
*/
@@ -348,7 +327,7 @@ export default {
348327
if (propertyNames.includes('password')) {
349328
// reset password state after sync
350329
this.share.password = this.share.newPassword || undefined
351-
this.$delete(this.share, 'newPassword')
330+
this.$set(this.share, 'newPassword', undefined)
352331

353332
// updates password expiration time after sync
354333
this.share.passwordExpirationTime = updatedShare.password_expiration_time
@@ -419,7 +398,7 @@ export default {
419398
if (this.share.newPassword === this.share.password) {
420399
this.share.password = ''
421400
}
422-
this.$delete(this.share, 'newPassword')
401+
this.$set(this.share, 'newPassword', undefined)
423402
}
424403

425404
// re-open menu if closed

apps/files_sharing/src/models/Share.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ export default class Share {
422422
const hasDisabledDownload = (attribute) => {
423423
return attribute.scope === 'permissions' && attribute.key === 'download' && attribute.value === false
424424
}
425-
return this.attributes.some(hasDisabledDownload)
425+
return !this.attributes.some(hasDisabledDownload)
426426
}
427427

428428
/**

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@
155155
</template>
156156
<NcCheckboxRadioSwitch
157157
v-if="canTogglePasswordProtectedByTalkAvailable"
158-
v-model="isPasswordProtectedByTalk"
159-
@update:modelValue="onPasswordProtectedByTalkChange">
158+
v-model="isPasswordProtectedByTalk">
160159
{{ t('files_sharing', 'Video verification') }}
161160
</NcCheckboxRadioSwitch>
162161
<NcCheckboxRadioSwitch v-model="hasExpirationDate" :disabled="isExpiryDateEnforced">
@@ -178,8 +177,7 @@
178177
<NcCheckboxRadioSwitch
179178
v-if="isPublicShare"
180179
v-model="share.hideDownload"
181-
:disabled="canChangeHideDownload"
182-
@update:modelValue="queueUpdate('hideDownload')">
180+
:disabled="canChangeHideDownload">
183181
{{ t('files_sharing', 'Hide download') }}
184182
</NcCheckboxRadioSwitch>
185183
<NcCheckboxRadioSwitch
@@ -400,6 +398,13 @@ export default {
400398
creating: false,
401399
initialToken: this.share.token,
402400
loadingToken: false,
401+
initialPermissions: undefined,
402+
initialExpireDate: undefined,
403+
initialNote: undefined,
404+
initialLabel: undefined,
405+
initialHideDownload: undefined,
406+
initialSendPasswordByTalk: undefined,
407+
initialHasDownloadPermission: undefined,
403408
404409
externalShareActions: getSidebarActions(),
405410
// legacy
@@ -867,6 +872,14 @@ export default {
867872
},
868873
869874
beforeMount() {
875+
this.initialPermissions = this.share.permissions
876+
this.initialExpireDate = this.share.expireDate
877+
this.initialNote = this.share.note
878+
this.initialLabel = this.share.label
879+
this.initialHideDownload = this.share.hideDownload
880+
this.initialSendPasswordByTalk = this.share.sendPasswordByTalk
881+
this.initialHasDownloadPermission = this.share.hasDownloadPermission
882+
870883
this.initializePermissions()
871884
this.initializeAttributes()
872885
logger.debug('Share object received', { share: this.share })
@@ -931,6 +944,16 @@ export default {
931944
932945
cancel() {
933946
this.share.token = this.initialToken
947+
this.share.permissions = this.initialPermissions
948+
this.share.expireDate = this.initialExpireDate
949+
this.share.note = this.initialNote
950+
this.share.label = this.initialLabel
951+
this.share.hideDownload = this.initialHideDownload
952+
this.share.sendPasswordByTalk = this.initialSendPasswordByTalk
953+
this.share.hasDownloadPermission = this.initialHasDownloadPermission
954+
955+
this.$set(this.share, 'newPassword', undefined)
956+
934957
this.$emit('close-sharing-details')
935958
},
936959
@@ -1065,7 +1088,7 @@ export default {
10651088
10661089
async saveShare() {
10671090
const permissionsAndAttributes = ['permissions', 'attributes', 'note', 'expireDate']
1068-
const publicShareAttributes = ['label', 'hideDownload']
1091+
const publicShareAttributes = ['label', 'hideDownload', 'sendPasswordByTalk']
10691092
// Only include password if it's being actively changed
10701093
if (this.hasUnsavedPassword) {
10711094
publicShareAttributes.push('password')
@@ -1099,6 +1122,13 @@ export default {
10991122
this.share.password = ''
11001123
}
11011124
1125+
// "Video verification" must be disabled if the password was
1126+
// disabled, as it does not make sense and would also prevent
1127+
// saving if it is still enabled.
1128+
if (this.isPasswordProtectedByTalk && !this.isPasswordProtected) {
1129+
this.isPasswordProtectedByTalk = false
1130+
}
1131+
11021132
if (!this.hasExpirationDate) {
11031133
this.share.expireDate = ''
11041134
}
@@ -1228,30 +1258,14 @@ export default {
12281258
*/
12291259
onPasswordChange(password) {
12301260
if (password === '') {
1231-
this.$delete(this.share, 'newPassword')
1261+
this.$set(this.share, 'newPassword', undefined)
12321262
this.passwordError = this.isNewShare && this.isPasswordEnforced
12331263
return
12341264
}
12351265
this.passwordError = !this.isValidShareAttribute(password)
12361266
this.$set(this.share, 'newPassword', password)
12371267
},
12381268
1239-
/**
1240-
* Update the password along with "sendPasswordByTalk".
1241-
*
1242-
* If the password was modified the new password is sent; otherwise
1243-
* updating a mail share would fail, as in that case it is required that
1244-
* a new password is set when enabling or disabling
1245-
* "sendPasswordByTalk".
1246-
*/
1247-
onPasswordProtectedByTalkChange() {
1248-
if (this.isEmailShareType || this.hasUnsavedPassword) {
1249-
this.queueUpdate('sendPasswordByTalk', 'password')
1250-
} else {
1251-
this.queueUpdate('sendPasswordByTalk')
1252-
}
1253-
},
1254-
12551269
isValidShareAttribute(value) {
12561270
if ([null, undefined].includes(value)) {
12571271
return false

build/eslint-baseline-legacy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"apps/files_sharing/src/views/SharingDetailsTab.vue": {
1818
"vue/no-mutating-props": {
19-
"count": 24
19+
"count": 31
2020
}
2121
},
2222
"apps/files_sharing/src/views/SharingLinkList.vue": {

dist/2373-2373.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/2373-2373.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/2577-2577.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/2577-2577.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)