Skip to content

Commit f2ad50f

Browse files
authored
Merge pull request #52076 from nextcloud/backport/52075/stable29
2 parents 6222643 + eee9958 commit f2ad50f

File tree

11 files changed

+28
-12
lines changed

11 files changed

+28
-12
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
use OCP\Lock\ILockingProvider;
8282
use OCP\Lock\LockedException;
8383
use OCP\Server;
84+
use OCP\Share\Exceptions\GenericShareException;
8485
use OCP\Share\Exceptions\ShareNotFound;
8586
use OCP\Share\IManager;
8687
use OCP\Share\IShare;
@@ -804,6 +805,9 @@ public function createShare(
804805
} catch (HintException $e) {
805806
$code = $e->getCode() === 0 ? 403 : $e->getCode();
806807
throw new OCSException($e->getHint(), $code);
808+
} catch (GenericShareException|\InvalidArgumentException $e) {
809+
$this->logger->error($e->getMessage(), ['exception' => $e]);
810+
throw new OCSForbiddenException($e->getMessage(), $e);
807811
} catch (\Exception $e) {
808812
$this->logger->error($e->getMessage(), ['exception' => $e]);
809813
throw new OCSForbiddenException('Failed to create share.', $e);

apps/files_sharing/src/mixins/ShareRequests.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
// TODO: remove when ie not supported
2727
import 'url-search-params-polyfill'
2828

29+
import { emit } from '@nextcloud/event-bus'
30+
import { showError } from '@nextcloud/dialogs'
2931
import { generateOcsUrl } from '@nextcloud/router'
3032
import axios from '@nextcloud/axios'
33+
3134
import Share from '../models/Share.js'
32-
import { emit } from '@nextcloud/event-bus'
3335

3436
const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')
3537

@@ -65,7 +67,7 @@ export default {
6567
} catch (error) {
6668
console.error('Error while creating share', error)
6769
const errorMessage = error?.response?.data?.ocs?.meta?.message
68-
OC.Notification.showTemporary(
70+
showError(
6971
errorMessage ? t('files_sharing', 'Error creating the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error creating the share'),
7072
{ type: 'error' },
7173
)

apps/files_sharing/src/views/SharingDetailsTab.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
</NcButton>
231231
<NcButton type="primary"
232232
data-cy-files-sharing-share-editor-action="save"
233+
:disabled="creating"
233234
@click="saveShare">
234235
{{ shareButtonText }}
235236
<template v-if="creating" #icon>
@@ -899,8 +900,16 @@ export default {
899900
incomingShare.password = this.share.password
900901
}
901902
902-
this.creating = true
903-
const share = await this.addShare(incomingShare)
903+
let share
904+
try {
905+
this.creating = true
906+
share = await this.addShare(incomingShare)
907+
} catch (error) {
908+
this.creating = false
909+
// Error is already handled by ShareRequests mixin
910+
return
911+
}
912+
904913
// ugly hack to make code work - we need the id to be set but at the same time we need to keep values we want to update
905914
this.share._share.id = share.id
906915
await this.queueUpdate(...permissionsAndAttributes)
@@ -914,6 +923,7 @@ export default {
914923
}
915924
}
916925
}
926+
917927
this.share = share
918928
this.creating = false
919929
this.$emit('add:share', this.share)

dist/5956-5956.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/5956-5956.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/6576-6576.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

dist/6576-6576.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-files_sharing_tab.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-files_sharing_tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)