diff --git a/app/assets/javascripts/admin/controllers/modals/admin-import-theme.js.es6 b/app/assets/javascripts/admin/controllers/modals/admin-import-theme.js.es6 index 4b9a5aa6ddd..e69ada3b55b 100644 --- a/app/assets/javascripts/admin/controllers/modals/admin-import-theme.js.es6 +++ b/app/assets/javascripts/admin/controllers/modals/admin-import-theme.js.es6 @@ -1,7 +1,10 @@ import ModalFunctionality from "discourse/mixins/modal-functionality"; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; -import { observes } from "ember-addons/ember-computed-decorators"; +import { + default as computed, + observes +} from "ember-addons/ember-computed-decorators"; export default Ember.Controller.extend(ModalFunctionality, { local: Ember.computed.equal("selection", "local"), @@ -11,8 +14,14 @@ export default Ember.Controller.extend(ModalFunctionality, { loading: false, keyGenUrl: "/admin/themes/generate_key_pair", importUrl: "/admin/themes/import", - checkPrivate: Ember.computed.match("uploadUrl", /^git/), + localFile: null, + uploadUrl: null, + + @computed("loading", "remote", "uploadUrl", "local", "localFile") + importDisabled(isLoading, isRemote, uploadUrl, isLocal, localFile) { + return isLoading || (isRemote && !uploadUrl) || (isLocal && !localFile); + }, @observes("privateChecked") privateWasChecked() { @@ -32,6 +41,10 @@ export default Ember.Controller.extend(ModalFunctionality, { }, actions: { + uploadLocaleFile() { + this.set("localFile", $("#file-input")[0].files[0]); + }, + importTheme() { let options = { type: "POST" @@ -41,7 +54,7 @@ export default Ember.Controller.extend(ModalFunctionality, { options.processData = false; options.contentType = false; options.data = new FormData(); - options.data.append("theme", $("#file-input")[0].files[0]); + options.data.append("theme", this.get("localFile")); } else { options.data = { remote: this.get("uploadUrl"), diff --git a/app/assets/javascripts/admin/templates/modal/admin-import-theme.hbs b/app/assets/javascripts/admin/templates/modal/admin-import-theme.hbs index ed8e7ed681a..9a42c1846b7 100644 --- a/app/assets/javascripts/admin/templates/modal/admin-import-theme.hbs +++ b/app/assets/javascripts/admin/templates/modal/admin-import-theme.hbs @@ -4,7 +4,7 @@ {{#if local}}
-
+
{{i18n 'admin.customize.theme.import_file_tip'}}
{{/if}} @@ -44,6 +44,6 @@ {{/d-modal-body}}