diff --git a/assets/javascripts/discourse/components/param-input.js.es6 b/assets/javascripts/discourse/components/param-input.js.es6 index e6947db..97dd855 100644 --- a/assets/javascripts/discourse/components/param-input.js.es6 +++ b/assets/javascripts/discourse/components/param-input.js.es6 @@ -43,6 +43,15 @@ export default Ember.Component.extend({ { name: I18n.t("explorer.types.bool.false"), id: "N" }, { name: I18n.t("explorer.types.bool.null_"), id: "#null" }, ], + initialValues: null, + + init() { + this._super(...arguments); + + if (this.initialValues && this.info.identifier in this.initialValues) { + this.set("value", this.initialValues[this.info.identifier]); + } + }, value: Ember.computed("params", "info.identifier", { get() { diff --git a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 index 8075026..e119caa 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 @@ -12,7 +12,7 @@ import { Promise } from "rsvp"; const NoQuery = Query.create({ name: "No queries", fake: true, group_ids: [] }); export default Ember.Controller.extend({ - queryParams: { selectedQueryId: "id" }, + queryParams: { selectedQueryId: "id", params: "params" }, selectedQueryId: null, editDisabled: false, showResults: false, @@ -32,6 +32,11 @@ export default Ember.Controller.extend({ sortBy: ["last_run_at:desc"], sortedQueries: Ember.computed.sort("model", "sortBy"), + @computed("params") + parsedParams(params) { + return params ? JSON.parse(params) : null; + }, + @computed acceptedImportFileTypes() { return ["application/json"]; @@ -207,10 +212,12 @@ export default Ember.Controller.extend({ order: null, showResults: false, editDisabled: false, + showRecentQueries: true, selectedQueryId: null, + params: null, sortBy: ["last_run_at:desc"], }); - this.transitionToRoute({ queryParams: { id: null } }); + this.transitionToRoute({ queryParams: { id: null, params: null } }); }, showHelpModal() { @@ -303,7 +310,11 @@ export default Ember.Controller.extend({ return; } - this.setProperties({ loading: true, showResults: false }); + this.setProperties({ + loading: true, + showResults: false, + params: JSON.stringify(this.selectedItem.params), + }); ajax( "/admin/plugins/explorer/queries/" + this.get("selectedItem.id") + diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs index 5923e92..d05debe 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs @@ -149,7 +149,11 @@ {{#if selectedItem.hasParams}}