aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-07-16 17:59:03 +0200
committerskjnldsv <skjnldsv@protonmail.com>2024-07-18 19:47:11 +0200
commit365b647b60d9380bbbd88fb00984b294db9062c2 (patch)
treed2550ba3582505fe614377c8748af001bdb302bb /apps/files_sharing/src
parenta5fdd1c64a1f2430941c6ba888956eef04c53a7d (diff)
downloadnextcloud-server-365b647b60d9380bbbd88fb00984b294db9062c2.tar.gz
nextcloud-server-365b647b60d9380bbbd88fb00984b294db9062c2.zip
fix(files_sharing): file request conditions with link/email global settings
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/src')
-rw-r--r--apps/files_sharing/src/components/NewFileRequestDialog.vue24
-rw-r--r--apps/files_sharing/src/new/newFileRequest.ts17
-rw-r--r--apps/files_sharing/src/services/ConfigService.ts9
3 files changed, 37 insertions, 13 deletions
diff --git a/apps/files_sharing/src/components/NewFileRequestDialog.vue b/apps/files_sharing/src/components/NewFileRequestDialog.vue
index 35cd4395290..2e15babeae5 100644
--- a/apps/files_sharing/src/components/NewFileRequestDialog.vue
+++ b/apps/files_sharing/src/components/NewFileRequestDialog.vue
@@ -95,7 +95,7 @@
@click="onFinish">
<template #icon>
<NcLoadingIcon v-if="loading" />
- <IconCheck v-else :size="20" />
+ <IconCheck v-else-if="success" :size="20" />
</template>
{{ finishButtonLabel }}
</NcButton>
@@ -182,6 +182,7 @@ export default defineComponent({
return {
currentStep: STEP.FIRST,
loading: false,
+ success: false,
destination: this.context.path || '/',
label: '',
@@ -244,10 +245,19 @@ export default defineComponent({
return
}
- await this.setShareEmails()
- await this.sendEmails()
- showSuccess(this.t('files_sharing', 'File request created and emails sent'))
- this.$emit('close')
+ if (sharingConfig.isMailShareAllowed && this.emails.length > 0) {
+ await this.setShareEmails()
+ await this.sendEmails()
+ showSuccess(this.n('files_sharing', 'File request created and email sent', 'File request created and {count} emails sent', this.emails.length, { count: this.emails.length }))
+ } else {
+ showSuccess(this.t('files_sharing', 'File request created'))
+ }
+
+ // Show success then close
+ this.success = true
+ setTimeout(() => {
+ this.$emit('close')
+ }, 3000)
},
async createShare() {
@@ -258,7 +268,9 @@ export default defineComponent({
const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')
try {
const request = await axios.post<OCSResponse>(shareUrl, {
- shareType: ShareType.Email,
+ // Always create a file request, but without mail share
+ // permissions, only a share link will be created.
+ shareType: sharingConfig.isMailShareAllowed ? ShareType.Email : ShareType.Link,
permissions: Permission.CREATE,
label: this.label,
diff --git a/apps/files_sharing/src/new/newFileRequest.ts b/apps/files_sharing/src/new/newFileRequest.ts
index b7e5b3f2144..c5a0ca07bd1 100644
--- a/apps/files_sharing/src/new/newFileRequest.ts
+++ b/apps/files_sharing/src/new/newFileRequest.ts
@@ -4,22 +4,27 @@
*/
import type { Entry, Folder, Node } from '@nextcloud/files'
+import { Permission } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
-import Vue, { defineAsyncComponent } from 'vue'
import FileUploadSvg from '@mdi/svg/svg/file-upload.svg?raw'
+import Vue, { defineAsyncComponent } from 'vue'
+import Config from '../services/ConfigService'
const NewFileRequestDialogVue = defineAsyncComponent(() => import('../components/NewFileRequestDialog.vue'))
+const sharingConfig = new Config()
+
export const entry = {
id: 'file-request',
displayName: t('files', 'Create new file request'),
iconSvgInline: FileUploadSvg,
order: 30,
- enabled(): boolean {
- // TODO: determine requirements
- // 1. user can share the root folder
- // 2. OR user can create subfolders ?
- return true
+ enabled(context: Folder): boolean {
+ if ((context.permissions & Permission.SHARE) !== 0) {
+ // We need to have either link shares creation permissions
+ return sharingConfig.isPublicShareAllowed
+ }
+ return false
},
async handler(context: Folder, content: Node[]) {
// Create document root
diff --git a/apps/files_sharing/src/services/ConfigService.ts b/apps/files_sharing/src/services/ConfigService.ts
index f8f7994bdab..94db0454428 100644
--- a/apps/files_sharing/src/services/ConfigService.ts
+++ b/apps/files_sharing/src/services/ConfigService.ts
@@ -211,13 +211,20 @@ export default class Config {
}
/**
+ * Is public sharing enabled ?
+ */
+ get isPublicShareAllowed(): boolean {
+ return this._capabilities?.files_sharing?.public?.enabled === true
+ }
+
+ /**
* Is sharing my mail (link share) enabled ?
*/
get isMailShareAllowed(): boolean {
// eslint-disable-next-line camelcase
return this._capabilities?.files_sharing?.sharebymail?.enabled === true
// eslint-disable-next-line camelcase
- && this._capabilities?.files_sharing?.public?.enabled === true
+ && this.isPublicShareAllowed === true
}
/**