Skip to content

Commit 8ff7cdd

Browse files
committed
Consider share type for enforced share expiry dates
We have three kind of share expiry date enforcements. - `isDefaultExpireDateEnforced` - `isDefaultInternalExpireDateEnforced` - `isDefaultRemoteExpireDateEnforced` Before these commit, `isExpiryDateEnforced` that is used to disable/enable the set expiry date checkbox does not take those into consideration which is problematic as those have different applications. In addition, this commit now uses `isExpiryDateEnforced` to disable/enable the input for expiry date that shows up before the creation of link shares. Here, `hasExpirationDate` is also removed from 'SharingEntryLink` component as it is not used. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
1 parent fe4d002 commit 8ff7cdd

9 files changed

Lines changed: 27 additions & 37 deletions

File tree

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
</NcActionText>
9999
<NcActionInput v-if="pendingExpirationDate"
100100
class="share-link-expire-date"
101-
:disabled="saving"
101+
:disabled="saving || isExpiryDateEnforced"
102102
:is-native-picker="true"
103103
:hide-label="true"
104104
:value="new Date(share.expireDate)"
@@ -304,34 +304,12 @@ export default {
304304
}
305305
return null
306306
},
307-
308-
/**
309-
* Does the current share have an expiration date
310-
*
311-
* @return {boolean}
312-
*/
313-
hasExpirationDate: {
314-
get() {
315-
return this.config.isDefaultExpireDateEnforced
316-
|| !!this.share.expireDate
317-
},
318-
set(enabled) {
319-
const defaultExpirationDate = this.config.defaultExpirationDate
320-
|| new Date(new Date().setDate(new Date().getDate() + 1))
321-
this.share.expireDate = enabled
322-
? this.formatDateToString(defaultExpirationDate)
323-
: ''
324-
console.debug('Expiration date status', enabled, this.share.expireDate)
325-
},
326-
},
327-
328307
dateMaxEnforced() {
329308
if (this.config.isDefaultExpireDateEnforced) {
330309
return new Date(new Date().setDate(new Date().getDate() + this.config.defaultExpireDate))
331310
}
332311
return null
333312
},
334-
335313
/**
336314
* Is the current share password protected ?
337315
*

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ export default {
135135
isShareOwner() {
136136
return this.share && this.share.owner === getCurrentUser().uid
137137
},
138+
isExpiryDateEnforced() {
139+
if (this.isPublicShare) {
140+
return this.config.isDefaultExpireDateEnforced
141+
}
142+
if (this.isRemoteShare) {
143+
return this.config.isDefaultRemoteExpireDateEnforced || this.config.isDefaultExpireDateEnforced
144+
}
145+
return this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
146+
},
138147
hasCustomPermissions() {
139148
const bundledPermissions = [
140149
BUNDLED_PERMISSIONS.ALL,

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,13 @@ export default {
360360
*/
361361
hasExpirationDate: {
362362
get() {
363-
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced
363+
if (this.isPublicShare) {
364+
return !!this.share.expireDate || this.config.isDefaultExpireDateEnforced
365+
}
366+
if (this.isRemoteShare) {
367+
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
368+
}
369+
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
364370
},
365371
set(enabled) {
366372
this.share.expireDate = enabled
@@ -393,7 +399,7 @@ export default {
393399
return this.fileInfo.type === 'dir'
394400
},
395401
dateMaxEnforced() {
396-
if (!this.isRemote && this.config.isDefaultInternalExpireDateEnforced) {
402+
if (!this.isRemoteShare && this.config.isDefaultInternalExpireDateEnforced) {
397403
return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultInternalExpireDate))
398404
} else if (this.config.isDefaultRemoteExpireDateEnforced) {
399405
return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultRemoteExpireDate))
@@ -422,9 +428,6 @@ export default {
422428
isPasswordEnforced() {
423429
return this.isPublicShare && this.config.enforcePasswordForPublicLink
424430
},
425-
isExpiryDateEnforced() {
426-
return this.config.isDefaultInternalExpireDateEnforced
427-
},
428431
defaultExpiryDate() {
429432
if ((this.isGroupShare || this.isUserShare) && this.config.isDefaultInternalExpireDateEnabled) {
430433
return new Date(this.config.defaultInternalExpirationDate)

dist/core-common.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/core-common.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/files-main.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/files-main.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/files_sharing-files_sharing_tab.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/files_sharing-files_sharing_tab.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.

0 commit comments

Comments
 (0)