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

Add tooltip/ariaLabel for New Button if user has permissions #5155

Merged
merged 1 commit into from
May 27, 2021
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
1 change: 1 addition & 0 deletions changelog/unreleased/enhancement-oc-tooltip
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ https://github.com/owncloud/web/issues/2623
https://github.com/owncloud/web/issues/4597
https://github.com/owncloud/web/issues/4332
https://github.com/owncloud/web/issues/4300
https://github.com/owncloud/web/issues/5155
155 changes: 80 additions & 75 deletions packages/web-app-files/src/components/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,80 +22,78 @@
v-if="showActions || selectedFiles.length > 0 || isTrashbinRoute"
class="uk-flex uk-flex-middle oc-p-s"
>
<template v-if="showActions">
<template v-if="areDefaultActionsVisible">
<oc-button
id="new-file-menu-btn"
key="new-file-menu-btn-enabled"
v-oc-tooltip="_cannotCreateDialogText"
:aria-label="_cannotCreateDialogText"
variation="primary"
appearance="filled"
:disabled="isNewBtnDisabled"
>
<oc-icon name="add" />
<translate>New</translate>
</oc-button>
<oc-drop
drop-id="new-file-menu-drop"
toggle="#new-file-menu-btn"
mode="click"
close-on-click
:options="{ delayHide: 0 }"
>
<ul class="uk-list">
<li>
<file-upload
:path="currentPath"
:headers="headers"
@success="onFileSuccess"
@error="onFileError"
@progress="onFileProgress"
/>
</li>
<li v-if="checkIfBrowserSupportsFolderUpload">
<folder-upload
v-if="!isIE11()"
:root-path="currentPath"
:path="currentPath"
:headers="headers"
@success="onFileSuccess"
@error="onFileError"
@progress="onFileProgress"
/>
</li>
<li>
<div>
<oc-button
id="new-folder-btn"
appearance="raw"
class="uk-width-1-1"
justify-content="left"
@click="showCreateResourceModal"
>
<oc-icon name="create_new_folder" />
<translate>New folder…</translate>
</oc-button>
</div>
</li>
<li v-for="(newFileHandler, key) in newFileHandlers" :key="key">
<div>
<oc-button
appearance="raw"
justify-content="left"
:class="['new-file-btn-' + newFileHandler.ext, 'uk-width-1-1']"
@click="
showCreateResourceModal(false, newFileHandler.ext, newFileHandler.action)
"
>
<oc-icon :name="newFileHandler.icon || 'save'" />
<span>{{ newFileHandler.menuTitle($gettext) }}</span>
</oc-button>
</div>
</li>
</ul>
</oc-drop>
</template>
<template v-if="showActions && areDefaultActionsVisible">
<oc-button
id="new-file-menu-btn"
key="new-file-menu-btn-enabled"
v-oc-tooltip="newButtonTooltip"
:aria-label="newButtonAriaLabel"
variation="primary"
appearance="filled"
:disabled="isNewBtnDisabled"
>
<oc-icon name="add" />
<translate>New</translate>
</oc-button>
<oc-drop
drop-id="new-file-menu-drop"
toggle="#new-file-menu-btn"
mode="click"
close-on-click
:options="{ delayHide: 0 }"
>
<ul class="uk-list">
<li>
<file-upload
:path="currentPath"
:headers="headers"
@success="onFileSuccess"
@error="onFileError"
@progress="onFileProgress"
/>
</li>
<li v-if="checkIfBrowserSupportsFolderUpload">
<folder-upload
v-if="!isIE11()"
:root-path="currentPath"
:path="currentPath"
:headers="headers"
@success="onFileSuccess"
@error="onFileError"
@progress="onFileProgress"
/>
</li>
<li>
<div>
<oc-button
id="new-folder-btn"
appearance="raw"
class="uk-width-1-1"
justify-content="left"
@click="showCreateResourceModal"
>
<oc-icon name="create_new_folder" />
<translate>New folder…</translate>
</oc-button>
</div>
</li>
<li v-for="(newFileHandler, key) in newFileHandlers" :key="key">
<div>
<oc-button
appearance="raw"
justify-content="left"
:class="['new-file-btn-' + newFileHandler.ext, 'uk-width-1-1']"
@click="
showCreateResourceModal(false, newFileHandler.ext, newFileHandler.action)
"
>
<oc-icon :name="newFileHandler.icon || 'save'" />
<span>{{ newFileHandler.menuTitle($gettext) }}</span>
</oc-button>
</div>
</li>
</ul>
</oc-drop>
</template>
<info-selected-resources v-if="selectedFiles.length > 0" class="oc-mr-s uk-visible@l" />
<batch-actions />
Expand Down Expand Up @@ -147,7 +145,7 @@ export default {
]),
...mapState(['route']),

_cannotCreateDialogText() {
newButtonTooltip() {
if (!this.canUpload) {
return this.$gettext('You have no permission to upload!')
}
Expand All @@ -156,6 +154,13 @@ export default {
}
return null
},
newButtonAriaLabel() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and newButtonAriaLabel() could then do the following:

const tooltip = this.newButtonTooltip
if (tooltip) {
    return tooltip
}
return this.$gettext('Add files or folders')

const tooltip = this.newButtonTooltip
if (tooltip) {
return tooltip
}
return this.$gettext('Add files or folders')
},
currentPath() {
const path = this.$route.params.item || ''
if (path.endsWith('/')) {
Expand Down