diff --git a/assets/javascripts/discourse/components/share-report.js.es6 b/assets/javascripts/discourse/components/share-report.js.es6 new file mode 100644 index 0000000..6dfbc25 --- /dev/null +++ b/assets/javascripts/discourse/components/share-report.js.es6 @@ -0,0 +1,86 @@ +import { + default as computed, + on +} from "ember-addons/ember-computed-decorators"; + +export default Ember.Component.extend({ + classNames: ["share-report"], + + group: null, + query: null, + visible: false, + + @computed("group", "query") + link() { + return ( + Discourse.BaseUrl + + "/g/" + + this.group + + "/reports/" + + this.query.id + ); + }, + + _mouseDownHandler(event) { + if (!this.element || this.isDestroying || this.isDestroyed) { + return; + } + if ($(this.element).has(event.target).length !== 0) { + return; + } + + this.send("close"); + + return true; + }, + + _keydownHandler(event) { + if (!this.element || this.isDestroying || this.isDestroyed) { + return; + } + + if (event.keyCode === 27) { + this.send("close"); + } + }, + + @on("init") + _setupHandlers() { + this._boundMouseDownHandler = Ember.run.bind(this, this._mouseDownHandler); + this._boundKeydownHandler = Ember.run.bind(this, this._keydownHandler); + }, + + didInsertElement() { + this._super(...arguments); + + $("html") + .on("mousedown.outside-share-link", this._boundMouseDownHandler) + .on("keydown.share-view", this._boundKeydownHandler); + }, + + willDestroyElement() { + this._super(...arguments); + + $("html") + .off("mousedown.outside-share-link", this._boundMouseDownHandler) + .off("keydown.share-view", this._boundKeydownHandler); + }, + + actions: { + open(e) { + this.set("visible", true); + window.setTimeout( + () => + $(this.element) + .find("input") + .select() + .focus(), + 160 + ); + }, + + close(e) { + this.set("visible", false); + } + } +}); diff --git a/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 index 39d1213..02b4a87 100644 --- a/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 +++ b/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 @@ -24,8 +24,6 @@ export default Discourse.Route.extend({ "group_names", (query.group_ids || []) .map(id => groupNames[id]) - .filter(n => n) - .join(", ") ); }); return { model, schema, groups }; diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs index d5c7aa3..c14ff34 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs @@ -206,16 +206,16 @@ {{/if}}