Skip to content

A platform for community discussion. Free, open, simple.

FIX: Allow showing expanded results table (#39601)

Natalie Taycc8035ba12bf
diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result.gjs b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result.gjs
index 16e6a378d73..e7ab9a4bfa9 100644
--- a/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result.gjs
+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result.gjs
@@ -1,6 +1,7 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
+import didInsert from "@ember/render-modifiers/modifiers/did-insert";
import { service } from "@ember/service";
import { capitalize } from "@ember/string";
import moment from "moment";
@@ -49,6 +50,8 @@ export default class QueryResult extends Component {
@tracked showChart;
@tracked showTable;
+ @tracked tableExpanded = false;
+ @tracked hasOverflow = false;
constructor() {
super(...arguments);
@@ -80,6 +83,24 @@ export default class QueryResult extends Component {
}
}
+ get showExpandButton() {
+ return this.hasOverflow && !this.tableExpanded;
+ }
+
+ @action
+ checkOverflow(element) {
+ if (!this.chartVisible) {
+ this.tableExpanded = true;
+ return;
+ }
+ this.hasOverflow = element.scrollHeight > element.clientHeight;
+ }
+
+ @action
+ expandTable() {
+ this.tableExpanded = true;
+ }
+
get chartVisible() {
return this.canShowChart && this.showChart;
}
@@ -391,7 +412,11 @@ export default class QueryResult extends Component {
{{/if}}
{{#if this.showTable}}
- <div class="query-results-table-wrapper">
+ <div
+ class="query-results-table-wrapper
+ {{if this.tableExpanded '--expanded'}}"
+ {{didInsert this.checkOverflow}}
+ >
<table class="query-results-table">
<thead>
<tr class="headers">
@@ -424,6 +449,14 @@ export default class QueryResult extends Component {
</tbody>
</table>
</div>
+ {{#if this.showExpandButton}}
+ <DButton
+ @action={{this.expandTable}}
+ @icon="chevron-down"
+ @translatedTitle={{i18n "show_more"}}
+ class="btn-flat query-results-expand-btn"
+ />
+ {{/if}}
{{/if}}
</section>
diff --git a/plugins/discourse-data-explorer/assets/stylesheets/explorer.scss b/plugins/discourse-data-explorer/assets/stylesheets/explorer.scss
index 22e049f9fb4..2ff2b79c1e8 100644
--- a/plugins/discourse-data-explorer/assets/stylesheets/explorer.scss
+++ b/plugins/discourse-data-explorer/assets/stylesheets/explorer.scss
@@ -538,7 +538,15 @@ table.group-reports {
.query-results-table-wrapper {
overflow: auto;
- max-height: 300px;
+ max-height: 350px;
+
+ &.--expanded {
+ max-height: none;
+ }
+ }
+
+ .query-results-expand-btn {
+ width: 100%;
}
.query-results-modes {
diff --git a/plugins/discourse-data-explorer/spec/system/query_runner_spec.rb b/plugins/discourse-data-explorer/spec/system/query_runner_spec.rb
index a071a9fd396..afc06352f1d 100644
--- a/plugins/discourse-data-explorer/spec/system/query_runner_spec.rb
+++ b/plugins/discourse-data-explorer/spec/system/query_runner_spec.rb
@@ -24,6 +24,7 @@ RSpec.describe "Data explorer query runner" do
visit("/admin/plugins/discourse-data-explorer/queries/#{query_a.id}")
find(".query-run .btn-primary").click
expect(page).to have_css(".query-results .result-header")
+ expect(page).to have_css(".query-results-table-wrapper.--expanded")
find(".back-button").click
first("a[href='/admin/plugins/discourse-data-explorer/queries/#{query_b.id}']").click
diff --git a/plugins/discourse-data-explorer/spec/system/reports_spec.rb b/plugins/discourse-data-explorer/spec/system/reports_spec.rb
index 1e0fbac6b12..c67a2677f62 100644
--- a/plugins/discourse-data-explorer/spec/system/reports_spec.rb
+++ b/plugins/discourse-data-explorer/spec/system/reports_spec.rb
@@ -34,6 +34,7 @@ RSpec.describe "Reports" do
expect(page).not_to have_css(".query-results .result-header")
find(".query-run .btn-primary").click
expect(page).to have_css(".query-results .result-header")
+ expect(page).to have_css(".query-results-table-wrapper.--expanded")
find(".group-reports-nav-item-outlet a").click
all(".group-reports a ").last.click