diff --git a/.gitignore b/.gitignore index ca06557..1266b58 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ auto_generated Gemfile.lock .DS_Store *.swp +*.swo .rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml diff --git a/assets/javascripts/discourse/components/explorer-container.js.es6 b/assets/javascripts/discourse/components/explorer-container.js.es6 index 232643f..987fde2 100644 --- a/assets/javascripts/discourse/components/explorer-container.js.es6 +++ b/assets/javascripts/discourse/components/explorer-container.js.es6 @@ -15,45 +15,64 @@ export default Ember.Component.extend({ if (this._state !== "inDOM") { return; } - const $editPane = this.$().find(".query-editor"); + const $editPane = this.$(".query-editor"); if (!$editPane.length) { return; } + const oldGrippie = this.get("grippie"); if (oldGrippie) { oldGrippie.off("mousedown mousemove mouseup"); - $editPane.off("mousemove mouseup"); } const $grippie = $editPane.find(".grippie"); - const $targets = $editPane.find(".ace-wrapper,.grippie-target"); - const $body = $("body"); - const self = this; + const $target = $editPane.find(".panels-flex"); + const $document = Ember.$(document); + + const minWidth = $target.width(); + const minHeight = $target.height(); this.set("grippie", $grippie); - const mousemove = function(e) { - const diff = self.get("startY") - e.screenY; - const newHeight = self.get("startSize") - diff; - $targets.height(newHeight); - self.appEvents.trigger("ace:resize"); + const mousemove = e => { + const diffY = this.get("startY") - e.screenY; + const diffX = this.get("startX") - e.screenX; + + const newHeight = Math.max(minHeight, this.get("startHeight") - diffY); + const newWidth = Math.max(minWidth, this.get("startWidth") - diffX); + + $target.height(newHeight); + $target.width(newWidth); + $grippie.width(newWidth); + this.appEvents.trigger("ace:resize"); }; - let mouseup; - mouseup = function(e) { - mousemove(e); - $body.off("mousemove", mousemove); - $body.off("mouseup", mouseup); - self.set("startY", null); - self.set("startSize", null); - }; + const throttledMousemove = (event => { + event.preventDefault(); + Ember.run.throttle(this, mousemove, event, 20); + }).bind(this); - $grippie.on("mousedown", function(e) { - self.set("startY", e.screenY); - self.set("startSize", $targets.height()); + const mouseup = (e => { + $document.off("mousemove", throttledMousemove); + $document.off("mouseup", mouseup); + this.setProperties({ + startY: null, + startX: null, + startHeight: null, + startWidth: null + }); + }).bind(this); - $body.on("mousemove", mousemove); - $body.on("mouseup", mouseup); + $grippie.on("mousedown", e => { + this.setProperties({ + startY: e.screenY, + startX: e.screenX, + startHeight: $target.height(), + startWidth: $target.width() + }); + + $document.on("mousemove", throttledMousemove); + $document.on("mouseup", mouseup); e.preventDefault(); }); }, diff --git a/assets/javascripts/discourse/components/explorer-schema.js.es6 b/assets/javascripts/discourse/components/explorer-schema.js.es6 index 7e6518d..8e1f3f7 100644 --- a/assets/javascripts/discourse/components/explorer-schema.js.es6 +++ b/assets/javascripts/discourse/components/explorer-schema.js.es6 @@ -2,9 +2,6 @@ import debounce from "discourse/lib/debounce"; export default Ember.Component.extend({ actions: { - expandSchema() { - this.set("hideSchema", false); - }, collapseSchema() { this.set("hideSchema", true); } diff --git a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 index f7ff5d1..77782d3 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 @@ -96,6 +96,10 @@ export default Ember.Controller.extend({ actions: { dummy() {}, + expandSchema() { + this.set("hideSchema", false); + }, + importQuery() { showModal("import-query"); this.set("showCreate", false); diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs index 5c55a91..185e54b 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs @@ -55,15 +55,22 @@ {{! the SQL editor will show the first time you }} {{#if everEditing}}