Skip to content

Commit

Permalink
fix(SharingEntryLink): Show default password before create if any
Browse files Browse the repository at this point in the history
Prevent silent addition of expiration date to shares.

Resolves : #48860

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Nov 6, 2024
1 parent 9276f45 commit 5399e73
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>

<!-- pending actions -->
<NcActions v-if="!pending && (pendingPassword || pendingEnforcedPassword || pendingExpirationDate)"
<NcActions v-if="!pending && pendingDataIsMissing"
class="sharing-entry__actions"
:aria-label="actionsTooltip"
menu-align="right"
Expand Down Expand Up @@ -82,10 +82,18 @@
</template>
</NcActionInput>

<NcActionCheckbox v-if="hasDefaultExpirationDate"
:checked.sync="defaultExpirationDateEnabled"
:disabled="pendingEnforcedExpirationDate || saving"
class="share-link-password-checkbox"
@change="onDefaultExpirationDateEnabledChange">
{{ config.enforcePasswordForPublicLink ? t('files_sharing', 'Enable expiration (enforced)') : t('files_sharing', 'Enable expiration date') }}
</NcActionCheckbox>

<!-- expiration date -->
<NcActionInput v-if="pendingExpirationDate"
<NcActionInput v-if="(hasDefaultExpirationDate || pendingEnforcedExpirationDate) && defaultExpirationDateEnabled"
class="share-link-expire-date"
:label="t('files_sharing', 'Expiration date (enforced)')"
:label="pendingEnforcedExpirationDate ? t('files_sharing', 'Expiration date (enforced)') : t('files_sharing', 'Expiration date')"
:disabled="saving"
:is-native-picker="true"
:hide-label="true"
Expand Down Expand Up @@ -289,6 +297,7 @@ export default {
shareCreationComplete: false,
copySuccess: true,
copied: false,
defaultExpirationDateEnabled: true,

// Are we waiting for password/expiration date
pending: false,
Expand Down Expand Up @@ -462,15 +471,21 @@ export default {
*
* @return {boolean}
*/
pendingDataIsMissing() {
return this.pendingPassword || this.pendingEnforcedPassword || this.pendingEnforcedExpirationDate || this.hasDefaultExpirationDate
},
pendingPassword() {
return this.config.enableLinkPasswordByDefault && this.share && !this.share.id
},
pendingEnforcedPassword() {
return this.config.enforcePasswordForPublicLink && this.share && !this.share.id
},
pendingExpirationDate() {
pendingEnforcedExpirationDate() {
return this.config.isDefaultExpireDateEnforced && this.share && !this.share.id
},
hasDefaultExpirationDate() {
return this.config.defaultExpirationDate instanceof Date || !isNaN(new Date(this.config.defaultExpirationDated).getTime())
},

sharePolicyHasRequiredProperties() {
return this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced
Expand Down Expand Up @@ -829,6 +844,9 @@ export default {
this.onPasswordSubmit()
this.onNoteSubmit()
},
onDefaultExpirationDateEnabledChange(enabled) {
this.share.expireDate = enabled ? this.formatDateToString(this.config.defaultExpirationDate) : ''
},

/**
* Cancel the share creation
Expand Down

0 comments on commit 5399e73

Please sign in to comment.