@@ -109,9 +109,9 @@ import PlusIcon from 'vue-material-design-icons/Plus.vue'
109109import UploadIcon from ' vue-material-design-icons/Upload.vue'
110110
111111import { getCapabilities } from ' @nextcloud/capabilities'
112+ import { loadState } from ' @nextcloud/initial-state'
112113import { showError } from ' @nextcloud/dialogs'
113114import { FilePickerVue as FilePicker } from ' @nextcloud/dialogs/filepicker.js'
114- import { loadState } from ' @nextcloud/initial-state'
115115
116116import NcActionButton from ' @nextcloud/vue/components/NcActionButton'
117117import NcActions from ' @nextcloud/vue/components/NcActions'
@@ -223,6 +223,18 @@ export default {
223223 },
224224 },
225225 methods: {
226+ getMaxFileUploads () {
227+ const capabilitiesMax = getCapabilities ()? .libresign ? .config ? .upload ? .[' max-file-uploads' ]
228+ return Number .isFinite (capabilitiesMax) && capabilitiesMax > 0 ? Math .floor (capabilitiesMax) : 20
229+ },
230+ validateMaxFileUploads (filesCount ) {
231+ const maxFileUploads = this .getMaxFileUploads ()
232+ if (filesCount > maxFileUploads) {
233+ showError (t (' libresign' , ' You can upload at most {max} files at once.' , { max: maxFileUploads }))
234+ return false
235+ }
236+ return true
237+ },
226238 handleEnvelopeNameSubmit () {
227239 const trimmedName = this .envelopeNameInput .trim ()
228240 if (trimmedName .length >= ENVELOPE_NAME_MIN_LENGTH && this .pendingFiles .length > 0 ) {
@@ -250,6 +262,10 @@ export default {
250262 this .loading = false
251263 },
252264 async upload (files , envelopeName = null ) {
265+ if (! this .validateMaxFileUploads (files .length )) {
266+ return
267+ }
268+
253269 this .loading = true
254270 this .isUploading = true
255271 this .uploadProgress = 0
@@ -318,10 +334,14 @@ export default {
318334 const input = document .createElement (' input' )
319335 input .accept = ' application/pdf'
320336 input .type = ' file'
321- input .multiple = this .envelopeEnabled
337+ input .multiple = this .envelopeEnabled && this . getMaxFileUploads () > 1
322338
323339 input .onchange = async (ev ) => {
324340 const files = Array .from (ev .target .files )
341+ if (! this .validateMaxFileUploads (files .length )) {
342+ input .remove ()
343+ return
344+ }
325345
326346 if (files .length > 1 && this .envelopeEnabled ) {
327347 this .pendingFiles = files
0 commit comments