Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(files): Update caption for screen readers when uploading is not possible #49167

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -170,12 +170,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() {
Expand Down
23 changes: 1 addition & 22 deletions apps/files/src/views/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,8 @@
</template>
</NcButton>

<!-- Disabled upload button -->
<NcButton v-if="!canUpload || isQuotaExceeded"
:aria-label="cantUploadLabel"
:title="cantUploadLabel"
class="files-list__header-upload-button--disabled"
:disabled="true"
type="secondary">
<template #icon>
<PlusIcon :size="20" />
</template>
{{ t('files', 'New') }}
</NcButton>

<!-- Uploader -->
<UploadPicker v-else-if="currentFolder"
<UploadPicker v-if="canUpload && !isQuotaExceeded && currentFolder"
allow-folders
class="files-list__header-upload-button"
:content="getContent"
Expand Down Expand Up @@ -170,7 +157,6 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import PlusIcon from 'vue-material-design-icons/Plus.vue'
import AccountPlusIcon from 'vue-material-design-icons/AccountPlus.vue'
import ViewGridIcon from 'vue-material-design-icons/ViewGrid.vue'

Expand Down Expand Up @@ -210,7 +196,6 @@ export default defineComponent({
NcEmptyContent,
NcIconSvgWrapper,
NcLoadingIcon,
PlusIcon,
AccountPlusIcon,
UploadPicker,
ViewGridIcon,
Expand Down Expand Up @@ -430,12 +415,6 @@ export default defineComponent({
isQuotaExceeded() {
return this.currentFolder?.attributes?.['quota-available-bytes'] === 0
},
cantUploadLabel() {
if (this.isQuotaExceeded) {
return t('files', 'Your have used your space quota and cannot upload files anymore')
}
return t('files', 'You don’t have permission to upload or create files here')
},

/**
* Check if current folder has share permissions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,5 @@ describe('files_sharing: Public share - View only', { testIsolation: true }, ()
// wait for file list to be ready
getRowForFile('foo.txt')
.should('be.visible')

cy.contains('button', 'New')
.should('be.visible')
.and('be.disabled')
})
})
4 changes: 0 additions & 4 deletions cypress/e2e/files_sharing/public-share/view_view-only.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ describe('files_sharing: Public share - View only', { testIsolation: true }, ()
// wait for file list to be ready
getRowForFile('foo.txt')
.should('be.visible')

cy.contains('button', 'New')
.should('be.visible')
.and('be.disabled')
})

it('Only download action is actions available', () => {
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

Loading