Skip to content

Commit 180564d

Browse files
committed
fix(attachments): disable upload without owner
Signed-off-by: Max <[email protected]>
1 parent aaa6600 commit 180564d

2 files changed

Lines changed: 37 additions & 3 deletions

File tree

src/components/Menu/ActionAttachmentUpload.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<NcActions class="entry-action entry-action__image-upload"
77
:data-text-action-entry="actionEntry.key"
88
:name="actionEntry.label"
9-
:title="actionEntry.label"
9+
:disabled="isUploadDisabled"
10+
:title="menuTitle"
1011
:aria-label="actionEntry.label"
1112
:container="menuIDSelector">
1213
<template #icon>
@@ -56,7 +57,11 @@
5657
import { NcActions, NcActionSeparator, NcActionButton, NcIconSvgWrapper } from '@nextcloud/vue'
5758
import { loadState } from '@nextcloud/initial-state'
5859
import { Loading, Folder, Upload, Plus } from '../icons.js'
59-
import { useIsPublicMixin, useEditorUpload } from '../Editor.provider.js'
60+
import {
61+
useIsPublicMixin,
62+
useEditorUpload,
63+
useSyncServiceMixin
64+
} from '../Editor.provider.js'
6065
import { BaseActionEntry } from './BaseActionEntry.js'
6166
import { useMenuIDMixin } from './MenuBar.provider.js'
6267
import {
@@ -82,6 +87,7 @@ export default {
8287
mixins: [
8388
useIsPublicMixin,
8489
useEditorUpload,
90+
useSyncServiceMixin,
8591
useActionAttachmentPromptMixin,
8692
useUploadingStateMixin,
8793
useActionChooseLocalAttachmentMixin,
@@ -100,6 +106,17 @@ export default {
100106
templates() {
101107
return loadState('files', 'templates', [])
102108
},
109+
isUploadDisabled() {
110+
return !this.$syncService.hasOwner
111+
},
112+
menuTitle() {
113+
return this.isUploadDisabled
114+
? t(
115+
'text',
116+
"Attachments cannot be created or uploaded because this file is shared from another cloud."
117+
)
118+
: this.actionEntry.label
119+
},
103120
},
104121
methods: {
105122
createAttachment(template) {

src/components/SuggestionsBar.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
type="secondary"
2323
size="normal"
2424
class="suggestions--button"
25+
:disabled="isUploadDisabled"
26+
:title="uploadTitle"
2527
@click="$callChooseLocalAttachment">
2628
<template #icon>
2729
<Upload :size="20" />
@@ -59,7 +61,11 @@ import { NcButton } from '@nextcloud/vue'
5961
import { Document, Shape, Upload, Table as TableIcon } from '../components/icons.js'
6062
import { useActionChooseLocalAttachmentMixin } from './Editor/MediaHandler.provider.js'
6163
import { getLinkWithPicker } from '@nextcloud/vue/dist/Components/NcRichText.js'
62-
import { useEditorMixin, useFileMixin, useSyncServerMixin } from './Editor.provider.js'
64+
import {
65+
useEditorMixin,
66+
useFileMixin,
67+
useSyncServiceMixin
68+
} from './Editor.provider.js'
6369
import { generateUrl } from '@nextcloud/router'
6470
import { buildFilePicker } from '../helpers/filePicker.js'
6571
import { isMobileDevice } from '../helpers/isMobileDevice.js'
@@ -73,6 +79,7 @@ export default {
7379
Shape,
7480
Upload,
7581
},
82+
7683
mixins: [
7784
useActionChooseLocalAttachmentMixin,
7885
useEditorMixin,
@@ -97,6 +104,16 @@ export default {
97104
relativePath() {
98105
return this.$file?.relativePath ?? '/'
99106
},
107+
isUploadDisabled() {
108+
return !this.$syncService.hasOwner
109+
},
110+
uploadTitle() {
111+
return this.isUploadDisabled
112+
&& t(
113+
'text',
114+
"Uploading attachments is disabled because the file is shared from another cloud."
115+
)
116+
},
100117
},
101118
102119
mounted() {

0 commit comments

Comments
 (0)