Skip to content

Commit d97d1bd

Browse files
authored
Merge pull request #49167 from nextcloud/feat/caption-cant-upload
feat(files): Update caption for screen readers when uploading is not possible
2 parents 03bbe06 + 2251c65 commit d97d1bd

File tree

6 files changed

+22
-35
lines changed

6 files changed

+22
-35
lines changed

apps/files/src/components/FilesListVirtual.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import type { Node as NcNode } from '@nextcloud/files'
6262
import type { ComponentPublicInstance, PropType } from 'vue'
6363
import type { UserConfig } from '../types'
6464
65-
import { getFileListHeaders, Folder, View, getFileActions, FileType } from '@nextcloud/files'
65+
import { getFileListHeaders, Folder, Permission, View, getFileActions, FileType } from '@nextcloud/files'
6666
import { showError } from '@nextcloud/dialogs'
6767
import { translate as t } from '@nextcloud/l10n'
6868
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
@@ -170,12 +170,28 @@ export default defineComponent({
170170
return [...this.headers].sort((a, b) => a.order - b.order)
171171
},
172172
173+
cantUpload() {
174+
return this.currentFolder && (this.currentFolder.permissions & Permission.CREATE) === 0
175+
},
176+
177+
isQuotaExceeded() {
178+
return this.currentFolder?.attributes?.['quota-available-bytes'] === 0
179+
},
180+
173181
caption() {
174182
const defaultCaption = t('files', 'List of files and folders.')
175183
const viewCaption = this.currentView.caption || defaultCaption
184+
const cantUploadCaption = this.cantUpload ? t('files', 'You don’t have permission to upload or create files here.') : null
185+
const quotaExceededCaption = this.isQuotaExceeded ? t('files', 'You have used your space quota and cannot upload files anymore.') : null
176186
const sortableCaption = t('files', 'Column headers with buttons are sortable.')
177187
const virtualListNote = t('files', 'This list is not fully rendered for performance reasons. The files will be rendered as you navigate through the list.')
178-
return `${viewCaption}\n${sortableCaption}\n${virtualListNote}`
188+
return [
189+
viewCaption,
190+
cantUploadCaption,
191+
quotaExceededCaption,
192+
sortableCaption,
193+
virtualListNote,
194+
].filter(Boolean).join('\n')
179195
},
180196
181197
selectedNodes() {

apps/files/src/views/FilesList.vue

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,8 @@
2222
</template>
2323
</NcButton>
2424

25-
<!-- Disabled upload button -->
26-
<NcButton v-if="!canUpload || isQuotaExceeded"
27-
:aria-label="cantUploadLabel"
28-
:title="cantUploadLabel"
29-
class="files-list__header-upload-button--disabled"
30-
:disabled="true"
31-
type="secondary">
32-
<template #icon>
33-
<PlusIcon :size="20" />
34-
</template>
35-
{{ t('files', 'New') }}
36-
</NcButton>
37-
3825
<!-- Uploader -->
39-
<UploadPicker v-else-if="currentFolder"
26+
<UploadPicker v-if="canUpload && !isQuotaExceeded && currentFolder"
4027
allow-folders
4128
class="files-list__header-upload-button"
4229
:content="getContent"
@@ -170,7 +157,6 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
170157
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
171158
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
172159
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
173-
import PlusIcon from 'vue-material-design-icons/Plus.vue'
174160
import AccountPlusIcon from 'vue-material-design-icons/AccountPlus.vue'
175161
import ViewGridIcon from 'vue-material-design-icons/ViewGrid.vue'
176162
@@ -210,7 +196,6 @@ export default defineComponent({
210196
NcEmptyContent,
211197
NcIconSvgWrapper,
212198
NcLoadingIcon,
213-
PlusIcon,
214199
AccountPlusIcon,
215200
UploadPicker,
216201
ViewGridIcon,
@@ -430,12 +415,6 @@ export default defineComponent({
430415
isQuotaExceeded() {
431416
return this.currentFolder?.attributes?.['quota-available-bytes'] === 0
432417
},
433-
cantUploadLabel() {
434-
if (this.isQuotaExceeded) {
435-
return t('files', 'Your have used your space quota and cannot upload files anymore')
436-
}
437-
return t('files', 'You don’t have permission to upload or create files here')
438-
},
439418
440419
/**
441420
* Check if current folder has share permissions

cypress/e2e/files_sharing/public-share/view_view-only-no-download.cy.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,5 @@ describe('files_sharing: Public share - View only', { testIsolation: true }, ()
9696
// wait for file list to be ready
9797
getRowForFile('foo.txt')
9898
.should('be.visible')
99-
100-
cy.contains('button', 'New')
101-
.should('be.visible')
102-
.and('be.disabled')
10399
})
104100
})

cypress/e2e/files_sharing/public-share/view_view-only.cy.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ describe('files_sharing: Public share - View only', { testIsolation: true }, ()
7878
// wait for file list to be ready
7979
getRowForFile('foo.txt')
8080
.should('be.visible')
81-
82-
cy.contains('button', 'New')
83-
.should('be.visible')
84-
.and('be.disabled')
8581
})
8682

8783
it('Only download action is actions available', () => {

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)