diff --git a/app/assets/javascripts/discourse/controllers/upload-selector.js.es6 b/app/assets/javascripts/discourse/controllers/upload-selector.js.es6 index bc083efcc4f..0fee68472b5 100644 --- a/app/assets/javascripts/discourse/controllers/upload-selector.js.es6 +++ b/app/assets/javascripts/discourse/controllers/upload-selector.js.es6 @@ -1,30 +1,37 @@ import ModalFunctionality from 'discourse/mixins/modal-functionality'; -import { default as computed } from 'ember-addons/ember-computed-decorators'; +import { default as computed, observes } from 'ember-addons/ember-computed-decorators'; import { allowsAttachments, authorizesAllExtensions, authorizedExtensions } from 'discourse/lib/utilities'; -export function uploadTranslate(key, options) { - options = options || {}; +function uploadTranslate(key) { if (allowsAttachments()) { key += "_with_attachments"; } - return I18n.t(`upload_selector.${key}`, options); + return `upload_selector.${key}`; } export default Ember.Controller.extend(ModalFunctionality, { showMore: false, - local: true, imageUrl: null, imageLink: null, - remote: Ember.computed.not("local"), + local: Ember.computed.equal('selection', 'local'), + remote: Ember.computed.equal('selection', 'remote'), + selection: 'local', - @computed - uploadIcon() { - return allowsAttachments() ? "upload" : "picture-o"; + @computed() + uploadIcon: () => allowsAttachments() ? "upload" : "picture-o", + + @computed() + title: () => uploadTranslate("title"), + + @computed('selection') + tip(selection) { + const authorized_extensions = authorizesAllExtensions() ? "" : `(${authorizedExtensions()})`; + return I18n.t(uploadTranslate(`${selection}_tip`), { authorized_extensions }); }, - @computed('local') - tip(local) { - const source = local ? "local" : "remote"; - const authorized_extensions = authorizesAllExtensions() ? "" : `(${authorizedExtensions()})`; - return uploadTranslate(`${source}_tip`, { authorized_extensions }); + @observes('selection') + _selectionChanged() { + if (this.get('local')) { + this.set('showMore', false); + } }, actions: { @@ -45,12 +52,6 @@ export default Ember.Controller.extend(ModalFunctionality, { this.send('closeModal'); }, - useLocal() { - this.setProperties({ local: true, showMore: false}); - }, - useRemote() { - this.set("local", false); - }, toggleShowMore() { this.toggleProperty("showMore"); } diff --git a/app/assets/javascripts/discourse/templates/modal/upload-selector.hbs b/app/assets/javascripts/discourse/templates/modal/upload-selector.hbs index 943ad5004a1..e0cd9a31349 100644 --- a/app/assets/javascripts/discourse/templates/modal/upload-selector.hbs +++ b/app/assets/javascripts/discourse/templates/modal/upload-selector.hbs @@ -1,6 +1,6 @@ -