Merge pull request #58669 from nextcloud/backport/b298ecb3b680df351731722505e95e3dc92daaa6
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Integration sqlite / changes (push) Waiting to run
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, --tags ~@large files_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, capabilities_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, collaboration_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, comments_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, dav_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, federation_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, file_conversions) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, files_reminders) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, filesdrop_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, ldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, openldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, openldap_numerical_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, remoteapi_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, routing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, setup_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, sharees_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, sharing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, theming_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable32, 8.1, stable32, videoverification_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite-summary (push) Blocked by required conditions

[stable32] fix(files_sharing): ensure the server share API errors are shown
This commit is contained in:
Ferdinand Thiessen 2026-03-03 02:08:02 +01:00 committed by GitHub
commit 8eca67bb3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 40 additions and 48 deletions

View file

@ -3,15 +3,12 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
// TODO: remove when ie not supported
import 'url-search-params-polyfill'
import { emit } from '@nextcloud/event-bus'
import axios, { isAxiosError } from '@nextcloud/axios'
import { showError } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'
import Share from '../models/Share.ts'
import logger from '../services/logger.ts'
const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')
@ -45,13 +42,9 @@ export default {
emit('files_sharing:share:created', { share })
return share
} catch (error) {
console.error('Error while creating share', error)
const errorMessage = error?.response?.data?.ocs?.meta?.message
showError(
errorMessage ? t('files_sharing', 'Error creating the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error creating the share'),
{ type: 'error' },
)
throw error
const errorMessage = getErrorMessage(error) ?? t('files_sharing', 'Error creating the share')
showError(errorMessage)
throw new Error(errorMessage, { cause: error })
}
},
@ -70,13 +63,9 @@ export default {
emit('files_sharing:share:deleted', { id })
return true
} catch (error) {
console.error('Error while deleting share', error)
const errorMessage = error?.response?.data?.ocs?.meta?.message
OC.Notification.showTemporary(
errorMessage ? t('files_sharing', 'Error deleting the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error deleting the share'),
{ type: 'error' },
)
throw error
const errorMessage = getErrorMessage(error) ?? t('files_sharing', 'Error deleting the share')
showError(errorMessage)
throw new Error(errorMessage, { cause: error })
}
},
@ -96,17 +85,27 @@ export default {
return request.data.ocs.data
}
} catch (error) {
console.error('Error while updating share', error)
if (error.response.status !== 400) {
const errorMessage = error?.response?.data?.ocs?.meta?.message
OC.Notification.showTemporary(
errorMessage ? t('files_sharing', 'Error updating the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error updating the share'),
{ type: 'error' },
)
}
const message = error.response.data.ocs.meta.message
throw new Error(message)
logger.error('Error while updating share', { error })
const errorMessage = getErrorMessage(error) ?? t('files_sharing', 'Error updating the share')
// the error will be shown in apps/files_sharing/src/mixins/SharesMixin.js
throw new Error(errorMessage, { cause: error })
}
},
},
}
/**
* Handle an error response from the server and show a notification with the error message if possible
*
* @param {unknown} error - The received error
* @return {string|undefined} the error message if it could be extracted from the response, otherwise undefined
*/
function getErrorMessage(error) {
if (isAxiosError(error) && error.response.data?.ocs) {
/** @type {import('@nextcloud/typings/ocs').OCSResponse} */
const response = error.response.data
if (response.ocs.meta?.message) {
return response.ocs.meta.message
}
}
}

4
dist/4505-4505.js vendored

File diff suppressed because one or more lines are too long

View file

@ -29,7 +29,6 @@ SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Jonas Schade <derzade@gmail.com>
SPDX-FileCopyrightText: Jerry Bendy <jerry@icewingcc.com>
SPDX-FileCopyrightText: Jeff Sagal <sagalbot@gmail.com>
SPDX-FileCopyrightText: James Halliday
SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
@ -300,9 +299,6 @@ This file is generated from multiple sources. Included packages:
- unist-util-visit
- version: 5.1.0
- license: MIT
- url-search-params-polyfill
- version: 8.2.5
- license: MIT
- util-deprecate
- version: 1.0.2
- license: MIT

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

12
package-lock.json generated
View file

@ -71,7 +71,6 @@
"strengthify": "github:nextcloud/strengthify#0.5.9",
"throttle-debounce": "^5.0.2",
"underscore": "1.13.8",
"url-search-params-polyfill": "^8.2.5",
"v-click-outside": "^3.2.0",
"v-tooltip": "^2.1.3",
"vue": "^2.7.16",
@ -4031,6 +4030,7 @@
"version": "7.7.9",
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.7.9.tgz",
"integrity": "sha512-kIE8wvwlcZ6TJTbNeU2HQNtaxLx3a84aotTITUuL/4bzfPxzajGBOoqjMhwZJ8L9qFYDU/lAYMEEm11dnZOD6g==",
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
@ -4228,6 +4228,7 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/pinia/-/pinia-3.0.4.tgz",
"integrity": "sha512-l7pqLUFTI/+ESXn6k3nu30ZIzW5E2WZF/LaHJEpoq6ElcLD+wduZoB2kBN19du6K/4FDpPMazY2wJr+IndBtQw==",
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
@ -7628,6 +7629,7 @@
"version": "7.7.9",
"resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.7.9.tgz",
"integrity": "sha512-PyQ6odHSgiDVd4hnTP+aDk2X4gl2HmLDfiyEnn3/oV+ckFDuswRs4IbBT7vacMuGdwY/XemxBoh302ctbsptuA==",
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
@ -7644,6 +7646,7 @@
"version": "7.7.9",
"resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.7.9.tgz",
"integrity": "sha512-iWAb0v2WYf0QWmxCGy0seZNDPdO3Sp5+u78ORnyeonS6MT4PC7VPrryX2BpMJrwlDeaZ6BD4vP4XKjK0SZqaeA==",
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
@ -20566,6 +20569,7 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz",
"integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==",
"license": "MIT",
"optional": true,
"peer": true
},
@ -26581,12 +26585,6 @@
"requires-port": "^1.0.0"
}
},
"node_modules/url-search-params-polyfill": {
"version": "8.2.5",
"resolved": "https://registry.npmjs.org/url-search-params-polyfill/-/url-search-params-polyfill-8.2.5.tgz",
"integrity": "sha512-FOEojW4XReTmtZOB7xqSHmJZhrNTmClhBriwLTmle4iA7bwuCo6ldSfbtsFSb8bTf3E0a3XpfonAdaur9vqq8A==",
"license": "MIT"
},
"node_modules/util": {
"version": "0.12.5",
"resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz",

View file

@ -100,7 +100,6 @@
"strengthify": "github:nextcloud/strengthify#0.5.9",
"throttle-debounce": "^5.0.2",
"underscore": "1.13.8",
"url-search-params-polyfill": "^8.2.5",
"v-click-outside": "^3.2.0",
"v-tooltip": "^2.1.3",
"vue": "^2.7.16",