Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] Allow share expiry dates lower than enforced limits #40928

Merged
merged 5 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ export default {
return this.config.isDefaultExpireDateEnforced
}
if (this.isRemoteShare) {
return this.config.isDefaultRemoteExpireDateEnforced || this.config.isDefaultExpireDateEnforced
return this.config.isDefaultRemoteExpireDateEnforced
}
return this.config.isDefaultInternalExpireDateEnforced || this.config.isDefaultExpireDateEnforced
return this.config.isDefaultInternalExpireDateEnforced
},
hasCustomPermissions() {
const bundledPermissions = [
Expand Down
50 changes: 24 additions & 26 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,10 @@
</NcCheckboxRadioSwitch>
<NcDateTimePickerNative v-if="hasExpirationDate"
id="share-date-picker"
:value="new Date(share.expireDate)"
:value="new Date(share.expireDate ?? dateTomorrow)"
:min="dateTomorrow"
:max="dateMaxEnforced"
:max="maxExpirationDateEnforced"
:hide-label="true"
:disabled="isExpiryDateEnforced"
:placeholder="t('files_sharing', 'Expiration date')"
type="date"
@input="onExpirationChange" />
Expand All @@ -135,9 +134,6 @@
<NcCheckboxRadioSwitch v-if="!isPublicShare" :disabled="!canSetDownload" :checked.sync="canDownload">
{{ t('files_sharing', 'Allow download') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-if="!isPublicShare" :disabled="!canSetDownload" :checked.sync="canDownload">
{{ t('file_sharing', 'Allow download') }}
</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch :checked.sync="writeNoteToRecipientIsChecked">
{{ t('files_sharing', 'Note to recipient') }}
</NcCheckboxRadioSwitch>
Expand Down Expand Up @@ -374,19 +370,7 @@ export default {
*/
hasExpirationDate: {
get() {
const isDefaultExpireDateEnabled = this.config.isDefaultExpireDateEnabled
const hasExistingExpirationDate = !!this.share.expireDate || isDefaultExpireDateEnabled
const isDefaultInternalExpireDateEnabled = this.config.isDefaultInternalExpireDateEnabled
const isDefaultRemoteExpireDateEnabled = this.config.isDefaultRemoteExpireDateEnabled
if (this.isPublicShare) {
return hasExistingExpirationDate
}

if (this.isRemoteShare) {
return hasExistingExpirationDate || isDefaultRemoteExpireDateEnabled
}

return hasExistingExpirationDate || isDefaultInternalExpireDateEnabled
return this.isValidShareAttribute(this.share.expireDate)
},
set(enabled) {
this.share.expireDate = enabled
Expand Down Expand Up @@ -418,11 +402,16 @@ export default {
isFolder() {
return this.fileInfo.type === 'dir'
},
dateMaxEnforced() {
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))
maxExpirationDateEnforced() {
if (this.isExpiryDateEnforced) {
if (this.isPublicShare) {
return this.config.defaultExpirationDate
}
if (this.isRemoteShare) {
return this.config.defaultRemoteExpirationDateString
}
// If it get's here then it must be an internal share
return this.config.defaultInternalExpirationDate
}
return null
},
Expand Down Expand Up @@ -699,10 +688,19 @@ export default {
this.share.newPassword = await GeneratePassword()
this.advancedSectionAccordionExpanded = true
}
if (this.hasExpirationDate) {
this.share.expireDate = this.defaultExpiryDate
/* Set default expiration dates if configured */
if (this.isPublicShare && this.config.isDefaultExpireDateEnabled) {
this.share.expireDate = this.config.defaultExpirationDate.toDateString()
} else if (this.isRemoteShare && this.config.isDefaultRemoteExpireDateEnabled) {
this.share.expireDate = this.config.defaultRemoteExpirationDateString.toDateString()
} else if (this.config.isDefaultInternalExpireDateEnabled) {
this.share.expireDate = this.config.defaultInternalExpirationDate.toDateString()
}

if (this.isValidShareAttribute(this.share.expireDate)) {
this.advancedSectionAccordionExpanded = true
}

return
}

Expand Down
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/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.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.

Loading