aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-10-23 15:24:53 +0200
committerGitHub <noreply@github.com>2024-10-23 15:24:53 +0200
commit0977b7dab8546f5eb11e1e91304093912b2589e2 (patch)
tree1d03f4ff5ced47298ae6f11cb965346d061bad64 /apps/files_sharing
parent7df57c2d39a082b0c818c3d15cd4e63709b1158f (diff)
parent38eef3d5a863eb4b892c6ac1da7f0495757e974b (diff)
downloadnextcloud-server-0977b7dab8546f5eb11e1e91304093912b2589e2.tar.gz
nextcloud-server-0977b7dab8546f5eb11e1e91304093912b2589e2.zip
Merge pull request #48796 from nextcloud/backport/48696/stable28
[stable28] fix(files_sharing): Add proper user facing messages on success
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/src/mixins/SharesMixin.js65
1 files changed, 43 insertions, 22 deletions
diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js
index 4893025c99f..6154b7f68cf 100644
--- a/apps/files_sharing/src/mixins/SharesMixin.js
+++ b/apps/files_sharing/src/mixins/SharesMixin.js
@@ -25,11 +25,11 @@
*
*/
+import { getCurrentUser } from '@nextcloud/auth'
+import { showError, showSuccess } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { fetchNode } from '../services/WebdavClient.ts'
-import { showError, showSuccess } from '@nextcloud/dialogs'
-import { getCurrentUser } from '@nextcloud/auth'
-// eslint-disable-next-line import/no-unresolved, n/no-missing-import
+
import PQueue from 'p-queue'
import debounce from 'debounce'
@@ -114,10 +114,10 @@ export default {
// Datepicker language
lang() {
const weekdaysShort = window.dayNamesShort
- ? window.dayNamesShort // provided by nextcloud
+ ? window.dayNamesShort // provided by Nextcloud
: ['Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri.', 'Sat.']
const monthsShort = window.monthNamesShort
- ? window.monthNamesShort // provided by nextcloud
+ ? window.monthNamesShort // provided by Nextcloud
: ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.']
const firstDayOfWeek = window.firstDay ? window.firstDay : 0
@@ -178,7 +178,7 @@ export default {
methods: {
/**
- * Fetch webdav node
+ * Fetch WebDAV node
*
* @return {Node}
*/
@@ -191,6 +191,7 @@ export default {
logger.error('Error:', error)
}
},
+
/**
* Check if a share is valid before
* firing the request
@@ -214,19 +215,7 @@ export default {
},
/**
- * @param {string} date a date with YYYY-MM-DD format
- * @return {Date} date
- */
- parseDateString(date) {
- if (!date) {
- return
- }
- const regex = /([0-9]{4}-[0-9]{2}-[0-9]{2})/i
- return new Date(date.match(regex)?.pop())
- },
-
- /**
- * @param {Date} date
+ * @param {Date} date the date to format
* @return {string} date a date with YYYY-MM-DD format
*/
formatDateToString(date) {
@@ -338,11 +327,17 @@ export default {
// clear any previous errors
this.$delete(this.errors, propertyNames[0])
- showSuccess(t('files_sharing', 'Share {propertyName} saved', { propertyName: propertyNames[0] }))
- } catch ({ message }) {
+ showSuccess(this.updateSuccessMessage(propertyNames))
+ } catch (error) {
+ logger.error('Could not update share', { error, share: this.share, propertyNames })
+
+ const { message } = error
if (message && message !== '') {
this.onSyncError(propertyNames[0], message)
- showError(t('files_sharing', message))
+ showError(message)
+ } else {
+ // We do not have information what happened, but we should still inform the user
+ showError(t('files_sharing', 'Could not update share'))
}
} finally {
this.saving = false
@@ -356,6 +351,32 @@ export default {
},
/**
+ * @param {string[]} names Properties changed
+ */
+ updateSuccessMessage(names) {
+ if (names.length !== 1) {
+ return t('files_sharing', 'Share saved')
+ }
+
+ switch (names[0]) {
+ case 'expireDate':
+ return t('files_sharing', 'Share expire date saved')
+ case 'hideDownload':
+ return t('files_sharing', 'Share hide-download state saved')
+ case 'label':
+ return t('files_sharing', 'Share label saved')
+ case 'note':
+ return t('files_sharing', 'Share note for recipient saved')
+ case 'password':
+ return t('files_sharing', 'Share password saved')
+ case 'permissions':
+ return t('files_sharing', 'Share permissions saved')
+ default:
+ return t('files_sharing', 'Share saved')
+ }
+ },
+
+ /**
* Manage sync errors
*
* @param {string} property the errored property, e.g. 'password'