Skip to content

Commit e8d5a3d

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 <[email protected]>
1 parent 6714e51 commit e8d5a3d

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

apps/files_sharing/src/components/SharingEntryLink.vue

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

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
@@ -368,7 +368,13 @@ export default {
368368
*/
369369
hasExpirationDate: {
370370
get() {
371-
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced
371+
if (this.isPublicShare) {
372+
return !!this.share.expireDate || this.config.isDefaultExpireDateEnforced
373+
}
374+
if (this.isRemoteShare) {
375+
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
376+
}
377+
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
372378
},
373379
set(enabled) {
374380
this.share.expireDate = enabled
@@ -401,7 +407,7 @@ export default {
401407
return this.fileInfo.type === 'dir'
402408
},
403409
dateMaxEnforced() {
404-
if (!this.isRemote && this.config.isDefaultInternalExpireDateEnforced) {
410+
if (!this.isRemoteShare && this.config.isDefaultInternalExpireDateEnforced) {
405411
return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultInternalExpireDate))
406412
} else if (this.config.isDefaultRemoteExpireDateEnforced) {
407413
return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultRemoteExpireDate))
@@ -430,9 +436,6 @@ export default {
430436
isPasswordEnforced() {
431437
return this.isPublicShare && this.config.enforcePasswordForPublicLink
432438
},
433-
isExpiryDateEnforced() {
434-
return this.config.isDefaultInternalExpireDateEnforced
435-
},
436439
defaultExpiryDate() {
437440
if ((this.isGroupShare || this.isUserShare) && this.config.isDefaultInternalExpireDateEnabled) {
438441
return new Date(this.config.defaultInternalExpirationDate)

0 commit comments

Comments
 (0)