9797 {{ t('files_sharing', 'Expiration date (enforced)') }}
9898 </NcActionText >
9999 <NcActionInput v-if =" pendingExpirationDate"
100- v-model =" share.expireDate"
101100 class =" share-link-expire-date"
102101 :disabled =" saving"
103102 :is-native-picker =" true"
104103 :hide-label =" true"
104+ :value =" new Date(share.expireDate)"
105105 type =" date"
106106 :min =" dateTomorrow"
107- :max =" dateMaxEnforced" >
107+ :max =" dateMaxEnforced"
108+ @input =" onExpirationChange" >
108109 <!-- let's not submit when picked, the user
109110 might want to still edit or copy the password -->
110111 {{ t('files_sharing', 'Enter a date') }}
218219 class =" share-link-expire-date"
219220 :class =" { error: errors.expireDate}"
220221 :disabled =" saving"
221- :value =" share.expireDate"
222+ :value =" new Date( share.expireDate) "
222223 type =" date"
223224 :min =" dateTomorrow"
224225 :max =" dateMaxEnforced"
298299
299300<script >
300301import { generateUrl } from ' @nextcloud/router'
302+ import { showError } from ' @nextcloud/dialogs'
301303import { Type as ShareTypes } from ' @nextcloud/sharing'
302304import Vue from ' vue'
303305
@@ -312,11 +314,11 @@ import NcActions from '@nextcloud/vue/dist/Components/NcActions'
312314import NcAvatar from ' @nextcloud/vue/dist/Components/NcAvatar'
313315import Tooltip from ' @nextcloud/vue/dist/Directives/Tooltip'
314316
315- import ExternalShareAction from ' ./ExternalShareAction'
316- import SharePermissionsEditor from ' ./SharePermissionsEditor'
317- import GeneratePassword from ' ../utils/GeneratePassword'
318- import Share from ' ../models/Share'
319- import SharesMixin from ' ../mixins/SharesMixin'
317+ import ExternalShareAction from ' ./ExternalShareAction.vue '
318+ import SharePermissionsEditor from ' ./SharePermissionsEditor.vue '
319+ import GeneratePassword from ' ../utils/GeneratePassword.js '
320+ import Share from ' ../models/Share.js '
321+ import SharesMixin from ' ../mixins/SharesMixin.js '
320322
321323export default {
322324 name: ' SharingEntryLink' ,
@@ -422,20 +424,18 @@ export default {
422424 || !! this .share .expireDate
423425 },
424426 set (enabled ) {
425- let defaultExpirationDate = this .config .defaultExpirationDate
426- if (! defaultExpirationDate) {
427- defaultExpirationDate = new Date ()
428- }
429- this .share .state .expiration = enabled
430- ? defaultExpirationDate
427+ const defaultExpirationDate = this .config .defaultExpirationDate
428+ || new Date (new Date ().setDate (new Date ().getDate () + 1 ))
429+ this .share .expireDate = enabled
430+ ? this .formatDateToString (defaultExpirationDate)
431431 : ' '
432432 console .debug (' Expiration date status' , enabled, this .share .expireDate )
433433 },
434434 },
435435
436436 dateMaxEnforced () {
437437 if (this .config .isDefaultExpireDateEnforced ) {
438- return new Date (new Date ().setDate (new Date ().getDate () + 1 + this .config .defaultExpireDate ))
438+ return new Date (new Date ().setDate (new Date ().getDate () + this .config .defaultExpireDate ))
439439 }
440440 return null
441441 },
@@ -620,7 +620,7 @@ export default {
620620 if (this .config .isDefaultExpireDateEnforced ) {
621621 // default is empty string if not set
622622 // expiration is the share object key, not expireDate
623- shareDefaults .expiration = this .config .defaultExpirationDate
623+ shareDefaults .expiration = this .formatDateToString ( this . config .defaultExpirationDate )
624624 }
625625 if (this .config .enableLinkPasswordByDefault ) {
626626 shareDefaults .password = await GeneratePassword ()
@@ -687,7 +687,7 @@ export default {
687687 this .errors = {}
688688
689689 const path = (this .fileInfo .path + ' /' + this .fileInfo .name ).replace (' //' , ' /' )
690- const newShare = await this . createShare ( {
690+ const options = {
691691 path,
692692 shareType: ShareTypes .SHARE_TYPE_LINK ,
693693 password: share .password ,
@@ -698,10 +698,12 @@ export default {
698698 // Todo: We also need to fix the createShare method in
699699 // lib/Controller/ShareAPIController.php to allow file drop
700700 // (currently not supported on create, only update)
701- })
701+ }
702702
703- this .open = false
703+ console .debug (' Creating link share with options' , options)
704+ const newShare = await this .createShare (options)
704705
706+ this .open = false
705707 console .debug (' Link share created' , newShare)
706708
707709 // if share already exists, copy link directly on next tick
@@ -728,8 +730,14 @@ export default {
728730 component .copyLink ()
729731 }
730732
731- } catch ({ response }) {
732- const message = response .data .ocs .meta .message
733+ } catch (data) {
734+ const message = data? .response ? .data ? .ocs ? .meta ? .message
735+ if (! message) {
736+ showError (t (' sharing' , ' Error while creating the share' ))
737+ console .error (data)
738+ return
739+ }
740+
733741 if (message .match (/ password/ i )) {
734742 this .onSyncError (' password' , message)
735743 } else if (message .match (/ date/ i )) {
0 commit comments