Skip to content

Commit

Permalink
Consider share type for enforced share expiry dates
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Fenn-CS committed Sep 20, 2023
1 parent 09794b6 commit 25982a7
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 53 deletions.
24 changes: 1 addition & 23 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Expand Up @@ -97,7 +97,7 @@
</NcActionText>
<NcActionInput v-if="pendingExpirationDate"
class="share-link-expire-date"
:disabled="saving"
:disabled="saving || isExpiryDateEnforced"
:is-native-picker="true"
:hide-label="true"
:value="new Date(share.expireDate)"
Expand Down Expand Up @@ -302,34 +302,12 @@ export default {
}
return null
},
/**
* Does the current share have an expiration date
*
* @return {boolean}
*/
hasExpirationDate: {
get() {
return this.config.isDefaultExpireDateEnforced
|| !!this.share.expireDate
},
set(enabled) {
const defaultExpirationDate = this.config.defaultExpirationDate
|| new Date(new Date().setDate(new Date().getDate() + 1))
this.share.expireDate = enabled
? this.formatDateToString(defaultExpirationDate)
: ''
console.debug('Expiration date status', enabled, this.share.expireDate)
},
},
dateMaxEnforced() {
if (this.config.isDefaultExpireDateEnforced) {
return new Date(new Date().setDate(new Date().getDate() + this.config.defaultExpireDate))
}
return null
},
/**
* Is the current share password protected ?
*
Expand Down
9 changes: 9 additions & 0 deletions apps/files_sharing/src/mixins/SharesMixin.js
Expand Up @@ -135,6 +135,15 @@ export default {
isShareOwner() {
return this.share && this.share.owner === getCurrentUser().uid
},
isExpiryDateEnforced() {
if (this.isPublicShare) {
return this.config.isDefaultExpireDateEnforced
}
if (this.isRemoteShare) {
return this.config.isDefaultRemoteExpireDateEnforced || this.config.isDefaultExpireDateEnforced
}
return this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
},
hasCustomPermissions() {
const bundledPermissions = [
BUNDLED_PERMISSIONS.ALL,
Expand Down
13 changes: 8 additions & 5 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Expand Up @@ -368,7 +368,13 @@ export default {
*/
hasExpirationDate: {
get() {
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced
if (this.isPublicShare) {
return !!this.share.expireDate || this.config.isDefaultExpireDateEnforced
}
if (this.isRemoteShare) {
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
}
return !!this.share.expireDate || this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
},
set(enabled) {
this.share.expireDate = enabled
Expand Down Expand Up @@ -401,7 +407,7 @@ export default {
return this.fileInfo.type === 'dir'
},
dateMaxEnforced() {
if (!this.isRemote && this.config.isDefaultInternalExpireDateEnforced) {
if (!this.isRemoteShare && this.config.isDefaultInternalExpireDateEnforced) {
return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultInternalExpireDate))
} else if (this.config.isDefaultRemoteExpireDateEnforced) {
return new Date(new Date().setDate(new Date().getDate() + 1 + this.config.defaultRemoteExpireDate))
Expand Down Expand Up @@ -430,9 +436,6 @@ export default {
isPasswordEnforced() {
return this.isPublicShare && this.config.enforcePasswordForPublicLink
},
isExpiryDateEnforced() {
return this.config.isDefaultInternalExpireDateEnforced
},
defaultExpiryDate() {
if ((this.isGroupShare || this.isUserShare) && this.config.isDefaultInternalExpireDateEnabled) {
return new Date(this.config.defaultInternalExpirationDate)
Expand Down
6 changes: 3 additions & 3 deletions dist/6898-6898.js → dist/188-188.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/188-188.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/6898-6898.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions dist/7816-7816.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/7816-7816.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-unsupported-browser-redirect.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unsupported-browser-redirect.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-unsupported-browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unsupported-browser.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-sidebar.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/systemtags-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/systemtags-init.js.map

Large diffs are not rendered by default.

0 comments on commit 25982a7

Please sign in to comment.