Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 29 additions & 30 deletions apps/files_sharing/src/mixins/ShareRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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 })
}
},

Expand All @@ -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 })
}
},

Expand All @@ -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 changes: 2 additions & 2 deletions dist/4505-4505.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions dist/4505-4505.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Nathan Rajlich <[email protected]> (http://n8.io/)
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Jonas Schade <[email protected]>
SPDX-FileCopyrightText: Jerry Bendy <[email protected]>
SPDX-FileCopyrightText: Jeff Sagal <[email protected]>
SPDX-FileCopyrightText: James Halliday
SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dist/4505-4505.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading