2525 *
2626 */
2727
28+ import { getCurrentUser } from '@nextcloud/auth'
29+ import { showError , showSuccess } from '@nextcloud/dialogs'
2830import { emit } from '@nextcloud/event-bus'
2931import { fetchNode } from '../services/WebdavClient.ts'
30- import { showError , showSuccess } from '@nextcloud/dialogs'
31- import { getCurrentUser } from '@nextcloud/auth'
32- // eslint-disable-next-line import/no-unresolved, n/no-missing-import
32+
3333import PQueue from 'p-queue'
3434import debounce from 'debounce'
3535
@@ -114,10 +114,10 @@ export default {
114114 // Datepicker language
115115 lang ( ) {
116116 const weekdaysShort = window . dayNamesShort
117- ? window . dayNamesShort // provided by nextcloud
117+ ? window . dayNamesShort // provided by Nextcloud
118118 : [ 'Sun.' , 'Mon.' , 'Tue.' , 'Wed.' , 'Thu.' , 'Fri.' , 'Sat.' ]
119119 const monthsShort = window . monthNamesShort
120- ? window . monthNamesShort // provided by nextcloud
120+ ? window . monthNamesShort // provided by Nextcloud
121121 : [ 'Jan.' , 'Feb.' , 'Mar.' , 'Apr.' , 'May.' , 'Jun.' , 'Jul.' , 'Aug.' , 'Sep.' , 'Oct.' , 'Nov.' , 'Dec.' ]
122122 const firstDayOfWeek = window . firstDay ? window . firstDay : 0
123123
@@ -178,7 +178,7 @@ export default {
178178
179179 methods : {
180180 /**
181- * Fetch webdav node
181+ * Fetch WebDAV node
182182 *
183183 * @return {Node }
184184 */
@@ -191,6 +191,7 @@ export default {
191191 logger . error ( 'Error:' , error )
192192 }
193193 } ,
194+
194195 /**
195196 * Check if a share is valid before
196197 * firing the request
@@ -214,19 +215,7 @@ export default {
214215 } ,
215216
216217 /**
217- * @param {string } date a date with YYYY-MM-DD format
218- * @return {Date } date
219- */
220- parseDateString ( date ) {
221- if ( ! date ) {
222- return
223- }
224- const regex = / ( [ 0 - 9 ] { 4 } - [ 0 - 9 ] { 2 } - [ 0 - 9 ] { 2 } ) / i
225- return new Date ( date . match ( regex ) ?. pop ( ) )
226- } ,
227-
228- /**
229- * @param {Date } date
218+ * @param {Date } date the date to format
230219 * @return {string } date a date with YYYY-MM-DD format
231220 */
232221 formatDateToString ( date ) {
@@ -338,11 +327,17 @@ export default {
338327
339328 // clear any previous errors
340329 this . $delete ( this . errors , propertyNames [ 0 ] )
341- showSuccess ( t ( 'files_sharing' , 'Share {propertyName} saved' , { propertyName : propertyNames [ 0 ] } ) )
342- } catch ( { message } ) {
330+ showSuccess ( this . updateSuccessMessage ( propertyNames ) )
331+ } catch ( error ) {
332+ logger . error ( 'Could not update share' , { error, share : this . share , propertyNames } )
333+
334+ const { message } = error
343335 if ( message && message !== '' ) {
344336 this . onSyncError ( propertyNames [ 0 ] , message )
345- showError ( t ( 'files_sharing' , message ) )
337+ showError ( message )
338+ } else {
339+ // We do not have information what happened, but we should still inform the user
340+ showError ( t ( 'files_sharing' , 'Could not update share' ) )
346341 }
347342 } finally {
348343 this . saving = false
@@ -355,6 +350,32 @@ export default {
355350 console . debug ( 'Updated local share' , this . share )
356351 } ,
357352
353+ /**
354+ * @param {string[] } names Properties changed
355+ */
356+ updateSuccessMessage ( names ) {
357+ if ( names . length !== 1 ) {
358+ return t ( 'files_sharing' , 'Share saved' )
359+ }
360+
361+ switch ( names [ 0 ] ) {
362+ case 'expireDate' :
363+ return t ( 'files_sharing' , 'Share expire date saved' )
364+ case 'hideDownload' :
365+ return t ( 'files_sharing' , 'Share hide-download state saved' )
366+ case 'label' :
367+ return t ( 'files_sharing' , 'Share label saved' )
368+ case 'note' :
369+ return t ( 'files_sharing' , 'Share note for recipient saved' )
370+ case 'password' :
371+ return t ( 'files_sharing' , 'Share password saved' )
372+ case 'permissions' :
373+ return t ( 'files_sharing' , 'Share permissions saved' )
374+ default :
375+ return t ( 'files_sharing' , 'Share saved' )
376+ }
377+ } ,
378+
358379 /**
359380 * Manage sync errors
360381 *
0 commit comments