Skip to content

Commit 4528a93

Browse files
committed
fix(attachments): disable upload without owner
Signed-off-by: Max <max@nextcloud.com>
1 parent 318e5d7 commit 4528a93

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
@@ -16,13 +16,15 @@
1616
</template>
1717
<NcActionButton v-if="$editorUpload"
1818
close-after-click
19-
:disabled="isUploadingAttachments"
19+
:disabled="isUploadingAttachments || isUploadDisabled"
20+
:title="uploadTitle"
2021
:data-text-action-entry="`${actionEntry.key}-upload`"
2122
@click="$callChooseLocalAttachment">
2223
<template #icon>
2324
<Upload />
2425
</template>
2526
{{ t('text', 'Upload from computer') }}
27+
{{ uploadTitle }}
2628
</NcActionButton>
2729
<NcActionButton v-if="!$isPublic"
2830
close-after-click
@@ -56,7 +58,11 @@
5658
import { NcActions, NcActionSeparator, NcActionButton, NcIconSvgWrapper } from '@nextcloud/vue'
5759
import { loadState } from '@nextcloud/initial-state'
5860
import { Loading, Folder, Upload, Plus } from '../icons.js'
59-
import { useIsPublicMixin, useEditorUpload } from '../Editor.provider.js'
61+
import {
62+
useIsPublicMixin,
63+
useEditorUpload,
64+
useSyncServiceMixin
65+
} from '../Editor.provider.js'
6066
import { BaseActionEntry } from './BaseActionEntry.js'
6167
import { useMenuIDMixin } from './MenuBar.provider.js'
6268
import {
@@ -82,6 +88,7 @@ export default {
8288
mixins: [
8389
useIsPublicMixin,
8490
useEditorUpload,
91+
useSyncServiceMixin,
8592
useActionAttachmentPromptMixin,
8693
useUploadingStateMixin,
8794
useActionChooseLocalAttachmentMixin,
@@ -100,6 +107,16 @@ export default {
100107
templates() {
101108
return loadState('files', 'templates', [])
102109
},
110+
isUploadDisabled() {
111+
return !this.$syncService.hasOwner
112+
},
113+
uploadTitle() {
114+
return this.isUploadDisabled
115+
&& t(
116+
'text',
117+
"Uploading attachments is disabled because the file is shared from another cloud."
118+
)
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)