From c06aaae80e5c83c33e34898a9c25f00f4232037f Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Fri, 8 Nov 2024 11:38:21 -0800 Subject: [PATCH] feat(files): Update caption for screen readers when uploading is not possible Signed-off-by: Christopher Ng --- .../files/src/components/FilesListVirtual.vue | 20 ++++++++++++++++-- apps/files/src/views/FilesList.vue | 21 +------------------ 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/apps/files/src/components/FilesListVirtual.vue b/apps/files/src/components/FilesListVirtual.vue index 95bd0f6c5719c..d7b6c2ebc2cc1 100644 --- a/apps/files/src/components/FilesListVirtual.vue +++ b/apps/files/src/components/FilesListVirtual.vue @@ -62,7 +62,7 @@ import type { Node as NcNode } from '@nextcloud/files' import type { ComponentPublicInstance, PropType } from 'vue' import type { UserConfig } from '../types' -import { getFileListHeaders, Folder, View, getFileActions, FileType } from '@nextcloud/files' +import { getFileListHeaders, Folder, Permission, View, getFileActions, FileType } from '@nextcloud/files' import { showError } from '@nextcloud/dialogs' import { translate as t } from '@nextcloud/l10n' import { subscribe, unsubscribe } from '@nextcloud/event-bus' @@ -172,12 +172,28 @@ export default defineComponent({ return [...this.headers].sort((a, b) => a.order - b.order) }, + cantUpload() { + return this.currentFolder && (this.currentFolder.permissions & Permission.CREATE) === 0 + }, + + isQuotaExceeded() { + return this.currentFolder?.attributes?.['quota-available-bytes'] === 0 + }, + caption() { const defaultCaption = t('files', 'List of files and folders.') const viewCaption = this.currentView.caption || defaultCaption + const cantUploadCaption = this.cantUpload ? t('files', 'You don’t have permission to upload or create files here.') : null + const quotaExceededCaption = this.isQuotaExceeded ? t('files', 'You have used your space quota and cannot upload files anymore.') : null const sortableCaption = t('files', 'Column headers with buttons are sortable.') const virtualListNote = t('files', 'This list is not fully rendered for performance reasons. The files will be rendered as you navigate through the list.') - return `${viewCaption}\n${sortableCaption}\n${virtualListNote}` + return [ + viewCaption, + cantUploadCaption, + quotaExceededCaption, + sortableCaption, + virtualListNote, + ].filter(Boolean).join('\n') }, selectedNodes() { diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue index fdfbed6a4e31a..112a1d875fd7e 100644 --- a/apps/files/src/views/FilesList.vue +++ b/apps/files/src/views/FilesList.vue @@ -22,21 +22,8 @@ - - - - {{ t('files', 'New') }} - - -