diff --git a/app/assets/javascripts/discourse/app/components/hidden-details.js b/app/assets/javascripts/discourse/app/components/hidden-details.js new file mode 100644 index 00000000000..a06ed1ee91c --- /dev/null +++ b/app/assets/javascripts/discourse/app/components/hidden-details.js @@ -0,0 +1,9 @@ +import Component from "@ember/component"; +import { action } from "@ember/object"; + +export default Component.extend({ + @action + expand() { + this.set("expanded", true); + }, +}); diff --git a/app/assets/javascripts/discourse/app/controllers/upload-selector.js b/app/assets/javascripts/discourse/app/controllers/upload-selector.js index 92672343a7a..6ccf7f4fbbb 100644 --- a/app/assets/javascripts/discourse/app/controllers/upload-selector.js +++ b/app/assets/javascripts/discourse/app/controllers/upload-selector.js @@ -1,7 +1,6 @@ import { allowsAttachments, authorizedExtensions, - authorizesAllExtensions, uploadIcon, } from "discourse/lib/uploads"; import Controller from "@ember/controller"; @@ -16,11 +15,9 @@ export default Controller.extend(ModalFunctionality, { remote: equal("selection", "remote"), selection: "local", - uploadTranslate(key) { - if (allowsAttachments(this.currentUser.staff, this.siteSettings)) { - key += "_with_attachments"; - } - return `upload_selector.${key}`; + @discourseComputed() + allowAdditionalFormats() { + return allowsAttachments(this.currentUser.staff, this.siteSettings); }, @discourseComputed() @@ -28,22 +25,26 @@ export default Controller.extend(ModalFunctionality, { return uploadIcon(this.currentUser.staff, this.siteSettings); }, - @discourseComputed() - title() { - return this.uploadTranslate("title"); + @discourseComputed("allowAdditionalFormats") + title(allowAdditionalFormats) { + const suffix = allowAdditionalFormats ? "_with_attachments" : ""; + return `upload_selector.title${suffix}`; }, - @discourseComputed("selection") - tip(selection) { - const authorized_extensions = authorizesAllExtensions( + @discourseComputed("selection", "allowAdditionalFormats") + tip(selection, allowAdditionalFormats) { + const suffix = allowAdditionalFormats ? "_with_attachments" : ""; + return I18n.t(`upload_selector.${selection}_tip${suffix}`); + }, + + @discourseComputed() + supportedFormats() { + const extensions = authorizedExtensions( this.currentUser.staff, this.siteSettings - ) - ? "" - : `(${authorizedExtensions(this.currentUser.staff, this.siteSettings)})`; - return I18n.t(this.uploadTranslate(`${selection}_tip`), { - authorized_extensions, - }); + ); + + return `(${extensions})`; }, actions: { diff --git a/app/assets/javascripts/discourse/app/templates/components/hidden-details.hbs b/app/assets/javascripts/discourse/app/templates/components/hidden-details.hbs new file mode 100644 index 00000000000..b7dc645453a --- /dev/null +++ b/app/assets/javascripts/discourse/app/templates/components/hidden-details.hbs @@ -0,0 +1,9 @@ +{{#unless expanded}} + {{d-button + action=(action "expand") + class="btn-link" + label=label}} +{{/unless}} +{{#if expanded}} + {{details}} +{{/if}} diff --git a/app/assets/javascripts/discourse/app/templates/modal/upload-selector.hbs b/app/assets/javascripts/discourse/app/templates/modal/upload-selector.hbs index 51dbfba2f2e..4e90b908837 100644 --- a/app/assets/javascripts/discourse/app/templates/modal/upload-selector.hbs +++ b/app/assets/javascripts/discourse/app/templates/modal/upload-selector.hbs @@ -6,6 +6,9 @@