-
Notifications
You must be signed in to change notification settings - Fork 159
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
Add tooltip/ariaLabel for New Button if user has permissions #5155
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
if (!this.canUpload) { | ||
return this.$gettext('You have no permission to upload!') | ||
} | ||
if (!this.hasFreeSpace) { | ||
return this.$gettext('You have not enough space left to upload!') | ||
} | ||
return null | ||
return "Add files or folders" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now adds a tooltip for a non-error case as well. IMO not good. Looks like it's required to separate into two different computed props, one for the tooltip and one for the aria-label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the solution I went for and let me know if you like it!
6460a4c
to
7795fad
Compare
if (isToolTip === true) { | ||
return null | ||
} | ||
return 'Add files or folders' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line lacks this.$gettext
} | ||
return null | ||
newButtonTooltip() { | ||
return this.newButtonDescription(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newButtonTooltip()
could do what we had before:
if (!this.canUpload) {
return this.$gettext('You have no permission to upload!')
}
if (!this.hasFreeSpace) {
return this.$gettext('You have not enough space left to upload!')
}
return null
newButtonTooltip() { | ||
return this.newButtonDescription(true) | ||
}, | ||
newButtonAriaLabel() { |
There was a problem hiding this comment.
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')
@@ -306,6 +300,19 @@ export default { | |||
this.createModal(modal) | |||
}, | |||
|
|||
newButtonDescription(isToolTip) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is totally fine technically, it is hard to read in the location where it's called. this.newButtonDescription(true)
or this.newButtonDescription(false)
doesn't give a hint what effect the boolean has on the output. I'd prefer a solution without the boolean, as pointed out in the two comments above.
7795fad
to
854f1fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🤖
Description
Add tooltip/ariaLabel for New Button if user has permissions to upload/create resources