From 4cd5be26ad7f34842b63cc08bb2b0747c693d0d9 Mon Sep 17 00:00:00 2001 From: ckfear Date: Sun, 2 Apr 2023 16:55:55 +0800 Subject: [PATCH 1/2] fix: Fix the uploadInfo text from static text to dynamic --- .../components/editor/editor-modal-media.vue | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/client/components/editor/editor-modal-media.vue b/client/components/editor/editor-modal-media.vue index 100a36df..9bcaaecc 100644 --- a/client/components/editor/editor-modal-media.vue +++ b/client/components/editor/editor-modal-media.vue @@ -150,7 +150,7 @@ ) v-divider v-card-actions.pa-3 - .caption.grey--text.text-darken-2 Max 10 files, 5 MB each + .caption.grey--text.text-darken-2 Max {{config.uploadMaxFiles}} files, {{config.uploadMaxFileSize | prettyBytes}} each v-spacer v-btn.px-4(color='teal', dark, @click='upload') {{$t('common:actions.upload')}} @@ -239,6 +239,7 @@ import listFolderAssetQuery from 'gql/editor/editor-media-query-folder-list.gql' import createAssetFolderMutation from 'gql/editor/editor-media-mutation-folder-create.gql' import renameAssetMutation from 'gql/editor/editor-media-mutation-asset-rename.gql' import deleteAssetMutation from 'gql/editor/editor-media-mutation-asset-delete.gql' +import gql from 'graphql-tag' const FilePond = vueFilePond() const localeSegmentRegex = /^[A-Z]{2}(-[A-Z]{2})?$/i @@ -278,7 +279,11 @@ export default { renameAssetName: '', renameAssetLoading: false, deleteDialog: false, - deleteAssetLoading: false + deleteAssetLoading: false, + config: { + uploadMaxFileSize: 0, + uploadMaxFiles: 0 + } } }, computed: { @@ -546,6 +551,23 @@ export default { this.loading = isLoading this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'editor-media-list-refresh') } + }, + config: { + query: gql` + { + site { + config { + uploadMaxFileSize + uploadMaxFiles + } + } + } + `, + fetchPolicy: 'network-only', + update: (data) => data.site.config, + watchLoading (isLoading) { + this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'editor-media-config-refresh') + } } } } From 3161c670b47f691366a747c259e67f4d1cc68f87 Mon Sep 17 00:00:00 2001 From: ckfear Date: Mon, 15 May 2023 15:27:19 +0800 Subject: [PATCH 2/2] fix: add uploadConfig GraphQL resolver for non admin user query. --- client/components/editor/editor-modal-media.vue | 10 +++++----- server/graph/resolvers/site.js | 6 ++++++ server/graph/schemas/site.graphql | 6 ++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/client/components/editor/editor-modal-media.vue b/client/components/editor/editor-modal-media.vue index 9bcaaecc..05861455 100644 --- a/client/components/editor/editor-modal-media.vue +++ b/client/components/editor/editor-modal-media.vue @@ -150,7 +150,7 @@ ) v-divider v-card-actions.pa-3 - .caption.grey--text.text-darken-2 Max {{config.uploadMaxFiles}} files, {{config.uploadMaxFileSize | prettyBytes}} each + .caption.grey--text.text-darken-2 Max {{uploadConfig.uploadMaxFiles}} files, {{uploadConfig.uploadMaxFileSize | prettyBytes}} each v-spacer v-btn.px-4(color='teal', dark, @click='upload') {{$t('common:actions.upload')}} @@ -280,7 +280,7 @@ export default { renameAssetLoading: false, deleteDialog: false, deleteAssetLoading: false, - config: { + uploadConfig: { uploadMaxFileSize: 0, uploadMaxFiles: 0 } @@ -552,11 +552,11 @@ export default { this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'editor-media-list-refresh') } }, - config: { + uploadConfig: { query: gql` { site { - config { + uploadConfig { uploadMaxFileSize uploadMaxFiles } @@ -564,7 +564,7 @@ export default { } `, fetchPolicy: 'network-only', - update: (data) => data.site.config, + update: (data) => data.site.uploadConfig, watchLoading (isLoading) { this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'editor-media-config-refresh') } diff --git a/server/graph/resolvers/site.js b/server/graph/resolvers/site.js index 27cd340c..89f1e31b 100644 --- a/server/graph/resolvers/site.js +++ b/server/graph/resolvers/site.js @@ -36,6 +36,12 @@ module.exports = { uploadScanSVG: WIKI.config.uploads.scanSVG, uploadForceDownload: WIKI.config.uploads.forceDownload } + }, + async uploadConfig(obj, args, context, info) { + return { + uploadMaxFileSize: WIKI.config.uploads.maxFileSize, + uploadMaxFiles: WIKI.config.uploads.maxFiles, + } } }, SiteMutation: { diff --git a/server/graph/schemas/site.graphql b/server/graph/schemas/site.graphql index 29370f20..94e3e07c 100644 --- a/server/graph/schemas/site.graphql +++ b/server/graph/schemas/site.graphql @@ -16,6 +16,7 @@ extend type Mutation { type SiteQuery { config: SiteConfig @auth(requires: ["manage:system"]) + uploadConfig: UploadConfig @auth(requires: ["manage:system", "manage:assets", "read:assets", "write:assets"]) } # ----------------------------------------------- @@ -116,3 +117,8 @@ type SiteConfig { uploadScanSVG: Boolean uploadForceDownload: Boolean } + +type UploadConfig { + uploadMaxFileSize: Int @auth(requires: ["manage:system", "manage:assets", "read:assets", "write:assets"]) + uploadMaxFiles: Int @auth(requires: ["manage:system", "manage:assets", "read:assets", "write:assets"]) +}