UX: Add tooltip why file upload is disabled (#19471)

Follow up to commit 0cc6e678bb.
This commit is contained in:
Bianca Nenciu 2022-12-15 22:57:11 +02:00 committed by GitHub
parent 8126c1613a
commit 1f6e9bd5a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -8,11 +8,19 @@ import lightbox from "discourse/lib/lightbox";
import { next } from "@ember/runloop";
import { htmlSafe } from "@ember/template";
import { authorizesOneOrMoreExtensions } from "discourse/lib/uploads";
import I18n from "I18n";
export default Component.extend(UppyUploadMixin, {
classNames: ["image-uploader"],
disabled: or("notAllowed", "uploading", "processing"),
@discourseComputed("disabled", "notAllowed")
disabledReason(disabled, notAllowed) {
if (disabled && notAllowed) {
return I18n.t("post.errors.no_uploads_authorized");
}
},
@discourseComputed(
"currentUser.staff",
"siteSettings.{authorized_extensions,authorized_extensions_for_staff}"

View File

@ -3,7 +3,7 @@
<div class="placeholder-overlay" style={{this.placeholderStyle}}></div>
{{/if}}
<div class="image-upload-controls">
<label class="btn btn-default pad-left no-text {{if this.disabled "disabled"}}">
<label class="btn btn-default pad-left no-text {{if this.disabled "disabled"}}" title={{this.disabledReason}}>
{{d-icon "far-image"}}
<PickFilesButton @fileInputDisabled={{this.disabled}} @fileInputClass="hidden-upload-field" @acceptedFormatsOverride="image/*" />
</label>