A platform for community discussion. Free, open, simple.
UX: Show graph by default and compact (#39123)
Natalie Taycf2f1a7f0454
diff --git a/plugins/discourse-data-explorer/admin/assets/javascripts/admin/templates/admin-plugins/show/explorer/edit.gjs b/plugins/discourse-data-explorer/admin/assets/javascripts/admin/templates/admin-plugins/show/explorer/edit.gjsindex f56fa362afd..0e42dab5412 100644--- a/plugins/discourse-data-explorer/admin/assets/javascripts/admin/templates/admin-plugins/show/explorer/edit.gjs+++ b/plugins/discourse-data-explorer/admin/assets/javascripts/admin/templates/admin-plugins/show/explorer/edit.gjs@@ -16,6 +16,7 @@ import { i18n } from "discourse-i18n";import CodeView from "discourse/plugins/discourse-data-explorer/discourse/components/code-view";import ExplorerSchema from "discourse/plugins/discourse-data-explorer/discourse/components/explorer-schema";import ParamInputForm from "discourse/plugins/discourse-data-explorer/discourse/components/param-input-form";+import QueryResultDownloadButtons from "discourse/plugins/discourse-data-explorer/discourse/components/query-result-download-buttons";import QueryResultsWrapper from "discourse/plugins/discourse-data-explorer/discourse/components/query-results-wrapper";export default class QueriesEdit extends Component {@@ -152,117 +153,126 @@ export default class QueriesEdit extends Component {"explorer.default_query_notice"}}</div>{{/if}}+ </div>- <div class="pull-left left-buttons">- {{#if @controller.editingQuery}}- <DButton- class="btn-save-query"- @action={{@controller.save}}- @label="explorer.save"- @disabled={{@controller.saveDisabled}}- />- {{else}}- {{#unless @controller.editDisabled}}- <DButton- class="btn-edit-query"- @action={{@controller.editQuery}}- @label="explorer.edit"- @icon="pencil"- />- {{/unless}}- {{/if}}-- <DButton- @action={{@controller.download}}- @label="explorer.export"- @disabled={{@controller.runDisabled}}- @icon="download"+ <form class="query-run" {{on "submit" @controller.run}}>+ {{#if @controller.model.hasParams}}+ <ParamInputForm+ @initialValues={{@controller.parsedParams}}+ @paramInfo={{@controller.model.param_info}}+ @onRegisterApi={{@controller.onRegisterApi}}/>+ {{/if}}- {{#if @controller.editingQuery}}- <DButton- @action={{@controller.showHelpModal}}- @label="explorer.help.label"- @icon="circle-question"- />- {{/if}}- </div>+ <div class="query-run-actions">+ <div class="query-run-actions__left">+ {{#if @controller.runDisabled}}+ {{#if @controller.saveDisabled}}+ <DButton+ @label="explorer.run"+ @disabled="true"+ class="btn-primary query-run__submit"+ />+ {{else}}+ <DButton+ @action={{@controller.saveAndRun}}+ @icon="play"+ @label="explorer.saverun"+ class="btn-primary query-run__save-and-run"+ />+ {{/if}}+ {{else}}+ <DButton+ {{didInsert @controller.runOnLoad}}+ @action={{@controller.run}}+ @icon="play"+ @label="explorer.run"+ @disabled={{@controller.runDisabled}}+ @type="submit"+ class="btn-primary query-run__submit"+ />+ {{/if}}- <div class="pull-right right-buttons">- {{#if @controller.model.destroyed}}- <DButton- @action={{@controller.recover}}- @icon="arrow-rotate-left"- @label="explorer.recover"- />- {{else}}{{#if @controller.editingQuery}}<DButton- @action={{@controller.discard}}- @icon="arrow-rotate-left"- @label="explorer.undo"+ class="btn-save-query"+ @action={{@controller.save}}+ @label="explorer.save"@disabled={{@controller.saveDisabled}}/>+ {{else}}+ {{#unless @controller.editDisabled}}+ <DButton+ class="btn-edit-query"+ @action={{@controller.editQuery}}+ @label="explorer.edit"+ @icon="pencil"+ />+ {{/unless}}{{/if}}- {{#if this.showDestroyQuery}}+ {{#if @controller.editingQuery}}<DButton- @action={{@controller.destroyQuery}}- @icon="trash-can"- @label="explorer.delete"- @disabled={{@controller.aiGenerating}}- class="btn-danger"+ @action={{@controller.showHelpModal}}+ @label="explorer.help.label"+ @icon="circle-question"/>{{/if}}- {{/if}}- </div>- <div class="clear"></div>- </div>- <form class="query-run" {{on "submit" @controller.run}}>- {{#if @controller.model.hasParams}}- <ParamInputForm- @initialValues={{@controller.parsedParams}}- @paramInfo={{@controller.model.param_info}}- @onRegisterApi={{@controller.onRegisterApi}}- />- {{/if}}+ <label class="query-plan">+ <Input+ @type="checkbox"+ @checked={{@controller.explain}}+ name="explain"+ />+ {{i18n "explorer.explain_label"}}+ </label>+ </div>- {{#if @controller.runDisabled}}- {{#if @controller.saveDisabled}}- <DButton- @label="explorer.run"- @disabled="true"- class="btn-primary query-run__submit"- />- {{else}}- <DButton- @action={{@controller.saveAndRun}}- @icon="play"- @label="explorer.saverun"- class="btn-primary query-run__save-and-run"- />- {{/if}}- {{else}}- <DButton- {{didInsert @controller.runOnLoad}}- @action={{@controller.run}}- @icon="play"- @label="explorer.run"- @disabled={{@controller.runDisabled}}- @type="submit"- class="btn-primary query-run__submit"- />- {{/if}}+ <div class="query-run-actions__right">+ {{#if @controller.model.destroyed}}+ <DButton+ @action={{@controller.recover}}+ @icon="arrow-rotate-left"+ @label="explorer.recover"+ />+ {{else}}+ {{#if @controller.editingQuery}}+ <DButton+ @action={{@controller.discard}}+ @icon="arrow-rotate-left"+ @label="explorer.undo"+ @disabled={{@controller.saveDisabled}}+ />+ {{/if}}- <label class="query-plan">- <Input- @type="checkbox"- @checked={{@controller.explain}}- name="explain"- />- {{i18n "explorer.explain_label"}}- </label>+ <DButton+ @action={{@controller.download}}+ @label="explorer.export"+ @disabled={{@controller.runDisabled}}+ @icon="download"+ />++ {{#if @controller.showResults}}+ <QueryResultDownloadButtons+ @query={{@controller.model}}+ @content={{@controller.results}}+ class="query-result-download-buttons--inline"+ />+ {{/if}}++ {{#if this.showDestroyQuery}}+ <DButton+ @action={{@controller.destroyQuery}}+ @icon="trash-can"+ @label="explorer.delete"+ @disabled={{@controller.aiGenerating}}+ class="btn-danger"+ />+ {{/if}}+ {{/if}}+ </div>+ </div></form><hr />@@ -274,6 +284,7 @@ export default class QueriesEdit extends Component {@query={{@controller.model}}@content={{@controller.results}}@cachedAt={{@controller.cachedAt}}+ @showDownloads={{false}}/>{{/if}}</div>diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result-download-buttons.gjs b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result-download-buttons.gjsnew file mode 100644index 00000000000..0a64f9eb79e--- /dev/null+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-result-download-buttons.gjs@@ -0,0 +1,101 @@+import Component from "@glimmer/component";+import { action } from "@ember/object";+import { schedule } from "@ember/runloop";+import DButton from "discourse/components/d-button";+import { ajax } from "discourse/lib/ajax";+import getURL from "discourse/lib/get-url";+import { QUERY_RESULT_MAX_LIMIT } from "discourse/plugins/discourse-data-explorer/discourse/lib/constants";++export default class QueryResultDownloadButtons extends Component {+ get params() {+ return this.args.content.params;+ }++ get explainText() {+ return this.args.content.explain;+ }++ @action+ downloadResultJson() {+ this._downloadResult("json");+ }++ @action+ downloadResultCsv() {+ this._downloadResult("csv");+ }++ _downloadUrl() {+ return this.args.group+ ? `/g/${this.args.group.name}/reports/`+ : "/admin/plugins/discourse-data-explorer/queries/";+ }++ _downloadResult(format) {+ const windowName = randomIdShort();+ const newWindowContents =+ "<style>body{font-size:36px;display:flex;justify-content:center;align-items:center;}</style><body>Click anywhere to close this window once the download finishes.<script>window.onclick=function(){window.close()};</script>";++ window.open("data:text/html;base64," + btoa(newWindowContents), windowName);++ let form = document.createElement("form");+ form.setAttribute("id", "query-download-result");+ form.setAttribute("method", "post");+ form.setAttribute(+ "action",+ getURL(+ this._downloadUrl() ++ this.args.query.id ++ "/run." ++ format ++ "?download=1"+ )+ );+ form.setAttribute("target", windowName);+ form.setAttribute("style", "display:none;");++ function addInput(name, value) {+ let field;+ field = document.createElement("input");+ field.setAttribute("name", name);+ field.setAttribute("value", value);+ form.appendChild(field);+ }++ addInput("params", JSON.stringify(this.params));+ addInput("explain", this.explainText);+ addInput("limit", String(QUERY_RESULT_MAX_LIMIT));++ ajax("/session/csrf.json").then((csrf) => {+ addInput("authenticity_token", csrf.csrf);++ document.body.appendChild(form);+ form.submit();+ schedule("afterRender", () => document.body.removeChild(form));+ });+ }++ <template>+ <div class="query-result-download-buttons" ...attributes>+ <DButton+ @action={{this.downloadResultJson}}+ @icon="download"+ @label="explorer.download_json"+ />++ <DButton+ @action={{this.downloadResultCsv}}+ @icon="download"+ @label="explorer.download_csv"+ />+ </div>+ </template>+}++function randomIdShort() {+ return "xxxxxxxx".replace(/[xy]/g, () => {+ /*eslint-disable*/+ return ((Math.random() * 16) | 0).toString(16);+ /*eslint-enable*/+ });+}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.gjsindex 5e8f9f4aa32..b1d9d7a74bb 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,20 +1,14 @@import Component from "@glimmer/component";-import { tracked } from "@glimmer/tracking";-import { action } from "@ember/object";-import { schedule } from "@ember/runloop";import { service } from "@ember/service";import { capitalize } from "@ember/string";import moment from "moment";-import DButton from "discourse/components/d-button";import icon from "discourse/helpers/d-icon";-import { ajax } from "discourse/lib/ajax";-import getURL from "discourse/lib/get-url";import Badge from "discourse/models/badge";import Category from "discourse/models/category";import I18n, { i18n } from "discourse-i18n";-import { QUERY_RESULT_MAX_LIMIT } from "discourse/plugins/discourse-data-explorer/discourse/lib/constants";import { isNumericColumn, looksLikeDate } from "../lib/chart-helpers";import DataExplorerChart from "./data-explorer-chart";+import QueryResultDownloadButtons from "./query-result-download-buttons";import QueryRowContent from "./query-row-content";import BadgeViewComponent from "./result-types/badge";import CategoryViewComponent from "./result-types/category";@@ -47,8 +41,6 @@ const VIEW_COMPONENTS = {export default class QueryResult extends Component {@service site;- @tracked chartDisplayed = false;-get colRender() {return this.args.content.colrender || {};}@@ -61,14 +53,14 @@ export default class QueryResult extends Component {return this.args.content.columns;}- get params() {- return this.args.content.params;- }-get explainText() {return this.args.content.explain;}+ get showDownloads() {+ return this.args.showDownloads !== false;+ }+get numericColumnIndices() {if (!this.rows?.length || !this.columns?.length) {return [];@@ -272,121 +264,31 @@ export default class QueryResult extends Component {}}- @action- downloadResultJson() {- this._downloadResult("json");- }-- @action- downloadResultCsv() {- this._downloadResult("csv");- }-- @action- showChart() {- this.chartDisplayed = true;- }-- @action- hideChart() {- this.chartDisplayed = false;- }-- _download_url() {- return this.args.group- ? `/g/${this.args.group.name}/reports/`- : "/admin/plugins/discourse-data-explorer/queries/";- }-- _downloadResult(format) {- // Create a frame to submit the form in (?)- // to avoid leaving an about:blank behind- let windowName = randomIdShort();- const newWindowContents =- "<style>body{font-size:36px;display:flex;justify-content:center;align-items:center;}</style><body>Click anywhere to close this window once the download finishes.<script>window.onclick=function(){window.close()};</script>";-- window.open("data:text/html;base64," + btoa(newWindowContents), windowName);-- let form = document.createElement("form");- form.setAttribute("id", "query-download-result");- form.setAttribute("method", "post");- form.setAttribute(- "action",- getURL(- this._download_url() +- this.args.query.id +- "/run." +- format +- "?download=1"- )- );- form.setAttribute("target", windowName);- form.setAttribute("style", "display:none;");-- function addInput(name, value) {- let field;- field = document.createElement("input");- field.setAttribute("name", name);- field.setAttribute("value", value);- form.appendChild(field);- }-- addInput("params", JSON.stringify(this.params));- addInput("explain", this.explainText);- addInput("limit", String(QUERY_RESULT_MAX_LIMIT));-- ajax("/session/csrf.json").then((csrf) => {- addInput("authenticity_token", csrf.csrf);-- document.body.appendChild(form);- form.submit();- schedule("afterRender", () => document.body.removeChild(form));- });- }-<template><article><header class="result-header"><div class="result-info">- <DButton- @action={{this.downloadResultJson}}- @icon="download"- @label="explorer.download_json"- />-- <DButton- @action={{this.downloadResultCsv}}- @icon="download"- @label="explorer.download_csv"- />-- {{#if this.canShowChart}}- {{#if this.chartDisplayed}}- <DButton- @action={{this.hideChart}}- @icon="table"- @label="explorer.show_table"- />- {{else}}- <DButton- @action={{this.showChart}}- @icon="chart-bar"- @label="explorer.show_graph"- />- {{/if}}+ {{#if this.showDownloads}}+ <QueryResultDownloadButtons+ @query={{@query}}+ @content={{@content}}+ @group={{@group}}+ />{{/if}}</div>- <div class="result-about">- {{this.resultCount}}- {{this.duration}}- </div>- {{#if this.cachedResultNotice}}- <div class="cached-result-notice">- {{icon "clock-rotate-left"}}- {{this.cachedResultNotice}}+ <div class="result-meta">+ <div class="result-about">+ {{this.resultCount}}+ {{this.duration}}</div>- {{/if}}+ {{#if this.cachedResultNotice}}+ <div class="cached-result-notice">+ {{icon "clock-rotate-left"}}+ {{this.cachedResultNotice}}+ </div>+ {{/if}}+ </div><br />@@ -402,14 +304,18 @@ export default class QueryResult extends Component {</header><section>- {{#if this.chartDisplayed}}- <DataExplorerChart- @labels={{this.chartLabels}}- @datasets={{this.chartDatasets}}- @chartType={{this.chartType}}- @stacked={{this.isStacked}}- />- {{else}}+ {{#if this.canShowChart}}+ <div class="query-results-chart">+ <DataExplorerChart+ @labels={{this.chartLabels}}+ @datasets={{this.chartDatasets}}+ @chartType={{this.chartType}}+ @stacked={{this.isStacked}}+ />+ </div>+ {{/if}}++ <div class="query-results-table-wrapper"><table class="query-results-table"><thead><tr class="headers">@@ -441,20 +347,12 @@ export default class QueryResult extends Component {{{/each}}</tbody></table>- {{/if}}+ </div></section></article></template>}-function randomIdShort() {- return "xxxxxxxx".replace(/[xy]/g, () => {- /*eslint-disable*/- return ((Math.random() * 16) | 0).toString(16);- /*eslint-enable*/- });-}-function transformedRelTable(table, modelClass) {const result = {};table?.forEach((item) => {diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-results-wrapper.gjs b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-results-wrapper.gjsindex 561d9ed20a4..237b37c9c90 100644--- a/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-results-wrapper.gjs+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/components/query-results-wrapper.gjs@@ -8,6 +8,7 @@ const QueryResultsWrapper = <template>@query={{@query}}@content={{@results}}@cachedAt={{@cachedAt}}+ @showDownloads={{@showDownloads}}/>{{else}}{{#each @results.errors as |err|}}diff --git a/plugins/discourse-data-explorer/assets/javascripts/discourse/templates/group/reports/show.gjs b/plugins/discourse-data-explorer/assets/javascripts/discourse/templates/group/reports/show.gjsindex 678196919a7..c0a1d4b34bc 100644--- a/plugins/discourse-data-explorer/assets/javascripts/discourse/templates/group/reports/show.gjs+++ b/plugins/discourse-data-explorer/assets/javascripts/discourse/templates/group/reports/show.gjs@@ -4,6 +4,7 @@ import ConditionalLoadingSpinner from "discourse/components/conditional-loading-import DButton from "discourse/components/d-button";import ParamInputForm from "../../../components/param-input-form";import QueryResult from "../../../components/query-result";+import QueryResultDownloadButtons from "../../../components/query-result-download-buttons";export default <template><section class="user-content">@@ -19,23 +20,40 @@ export default <template>/>{{/if}}- <DButton- {{didInsert @controller.runOnLoad}}- @action={{@controller.run}}- @icon="play"- @label="explorer.run"- @type="submit"- class="btn-primary query-run__submit"- />-- <DButton- @action={{@controller.toggleBookmark}}- @translatedLabel={{@controller.bookmarkLabel}}- @icon={{@controller.bookmarkIcon}}- class={{@controller.bookmarkClassName}}- />+ <div class="query-run-actions">+ <div class="query-run-actions__left">+ <DButton+ {{didInsert @controller.runOnLoad}}+ @action={{@controller.run}}+ @icon="play"+ @label="explorer.run"+ @type="submit"+ class="btn-primary query-run__submit"+ />++ <DButton+ @action={{@controller.toggleBookmark}}+ @translatedLabel={{@controller.bookmarkLabel}}+ @icon={{@controller.bookmarkIcon}}+ class={{@controller.bookmarkClassName}}+ />+ </div>++ {{#if @controller.showResults}}+ <div class="query-run-actions__right">+ <QueryResultDownloadButtons+ @query={{@controller.model}}+ @content={{@controller.results}}+ @group={{@controller.group}}+ class="query-result-download-buttons--inline"+ />+ </div>+ {{/if}}+ </div></form>+ <hr />+<ConditionalLoadingSpinner @condition={{@controller.loading}} />{{#if @controller.results}}@@ -45,6 +63,7 @@ export default <template>@query={{@controller.model}}@content={{@controller.results}}@group={{@controller.group}}+ @showDownloads={{false}}/>{{else}}{{#each @controller.results.errors as |err|}}diff --git a/plugins/discourse-data-explorer/assets/stylesheets/explorer.scss b/plugins/discourse-data-explorer/assets/stylesheets/explorer.scssindex a0c8cea0a05..f7b97cd3d41 100644--- a/plugins/discourse-data-explorer/assets/stylesheets/explorer.scss+++ b/plugins/discourse-data-explorer/assets/stylesheets/explorer.scss@@ -274,9 +274,28 @@ table.group-reports {.query-run {margin-top: 25px;+ .query-run-actions {+ display: flex;+ justify-content: space-between;+ align-items: center;+ gap: 1em;+ flex-wrap: wrap;+ margin-top: 1em;+ }++ .query-run-actions__left,+ .query-run-actions__right {+ display: flex;+ align-items: center;+ gap: 0.5em;+ flex-wrap: wrap;+ }+.query-plan {- display: inline-block;- margin-left: 15px;+ display: inline-flex;+ align-items: center;+ gap: 0.4em;+ margin-left: 0.25em;}}@@ -384,10 +403,30 @@ table.group-reports {}.query-results {+ .query-result-download-buttons {+ display: inline-flex;+ gap: 0.5em;++ .btn {+ margin: 0;+ }+ }++ .result-meta {+ display: flex;+ justify-content: space-between;+ align-items: baseline;+ gap: 0.75em 1.25em;+ flex-wrap: wrap;+ }+section {width: 100%;- overflow: auto;- max-height: 1000px;+ }++ .query-results-chart {+ width: min(100%, 840px);+ margin: 0 auto 1rem;}table {@@ -408,6 +447,11 @@ table.group-reports {z-index: z("base");}}++ .query-results-table-wrapper {+ overflow: auto;+ max-height: 1000px;+ }}.discourse-data-explorer-query-list {diff --git a/plugins/discourse-data-explorer/test/javascripts/acceptance/param-input-test.js b/plugins/discourse-data-explorer/test/javascripts/acceptance/param-input-test.jsindex d60c451caf0..56955bfa4e3 100644--- a/plugins/discourse-data-explorer/test/javascripts/acceptance/param-input-test.js+++ b/plugins/discourse-data-explorer/test/javascripts/acceptance/param-input-test.js@@ -403,13 +403,13 @@ acceptance("Data Explorer Plugin | Param Input", function (needs) {test("creates input boxes if has parameters when save", async function (assert) {await visit("/admin/plugins/discourse-data-explorer/queries/3");assert.dom(".query-params input").doesNotExist();- await click(".query-edit .btn-edit-query");+ await click(".query-run-actions .btn-edit-query");await fillIn(".query-editor .ace_text-input","-- [params]\n-- int :months_ago = 1\n\nSELECT 1");await click(".query-editor .ace_text-input"); // enables `Save Changes` button- await click(".query-edit .btn-save-query");+ await click(".query-run-actions .btn-save-query");assert.dom(".query-params input").exists();});diff --git a/plugins/discourse-data-explorer/test/javascripts/acceptance/run-query-test.js b/plugins/discourse-data-explorer/test/javascripts/acceptance/run-query-test.jsindex cf3751c78a8..58bbd758423 100644--- a/plugins/discourse-data-explorer/test/javascripts/acceptance/run-query-test.js+++ b/plugins/discourse-data-explorer/test/javascripts/acceptance/run-query-test.js@@ -305,13 +305,13 @@ acceptance("Data Explorer Plugin | Run Query", function (needs) {.dom("div.query-results table tbody tr").exists({ count: 2 }, "the table with query results was rendered");- assert- .dom("div.result-info button:nth-child(3) span")- .hasText(i18n("explorer.show_graph"), "the chart button was rendered");-- await click("div.result-info button:nth-child(3)");-assert.dom("canvas").exists("the chart was rendered");+ assert+ .dom("div.query-results section > :first-child")+ .matchesSelector(+ ".query-results-chart",+ "the chart is shown above the table"+ );});test("runs query and is able to download the results", async function (assert) {@@ -360,7 +360,9 @@ acceptance("Data Explorer Plugin | Run Query", function (needs) {}});- await click("div.result-info button:nth-child(1)");+ await click(+ ".query-run-actions__right .query-result-download-buttons button:nth-child(1)"+ );await finishedForm;diff --git a/plugins/discourse-data-explorer/test/javascripts/integration/components/query-result-test.gjs b/plugins/discourse-data-explorer/test/javascripts/integration/components/query-result-test.gjsindex b2d0832a110..f01daa7aba7 100644--- a/plugins/discourse-data-explorer/test/javascripts/integration/components/query-result-test.gjs+++ b/plugins/discourse-data-explorer/test/javascripts/integration/components/query-result-test.gjs@@ -1,4 +1,4 @@-import { click, render } from "@ember/test-helpers";+import { render } from "@ember/test-helpers";import { module, test } from "qunit";import { setupRenderingTest } from "discourse/tests/helpers/component-test";import { i18n } from "discourse-i18n";@@ -23,18 +23,19 @@ module(await render(<template><QueryResult @content={{content}} /></template>);assert- .dom("div.result-info button:nth-child(1) span")+ .dom(+ ".result-info .query-result-download-buttons button:nth-child(1) span"+ ).hasText(i18n("explorer.download_json"), "renders the JSON button");assert- .dom("div.result-info button:nth-child(2) span")+ .dom(+ ".result-info .query-result-download-buttons button:nth-child(2) span"+ ).hasText(i18n("explorer.download_csv"), "renders the CSV button");- assert- .dom("div.result-info button:nth-child(3) span")- .hasText(i18n("explorer.show_graph"), "renders the chart button");-assert.dom("div.result-about").exists("renders a query summary");+ assert.dom("canvas").exists("renders the chart above the table");assert.dom("table thead tr th:nth-child(1)").hasText("user_name");assert.dom("table thead tr th:nth-child(2)").hasText("like_count");@@ -142,7 +143,7 @@ module(function (hooks) {setupRenderingTest(hooks);- test("navigation between a table and a chart works", async function (assert) {+ test("renders the chart above the table for chartable results", async function (assert) {const content = {colrender: [],result_count: 2,@@ -155,32 +156,18 @@ module(await render(<template><QueryResult @content={{content}} /></template>);- assert- .dom("div.result-info button:nth-child(3) span")- .hasText(i18n("explorer.show_graph"), "the chart button was rendered");- assert.dom("table").exists("the table was rendered");-- await click("div.result-info button:nth-child(3)");-- assert- .dom("div.result-info button:nth-child(3) span")- .hasText(- i18n("explorer.show_table"),- "the chart button was changed to the table button"- );+ assert.dom(".result-info button:nth-child(3)").doesNotExist();assert.dom("canvas").exists("the chart was rendered");-- await click("div.result-info button:nth-child(3)");+ assert.dom("table").exists("the table was rendered");assert- .dom("div.result-info button:nth-child(3) span")- .hasText(- i18n("explorer.show_graph"),- "the table button was changed to the chart button"+ .dom("section > :first-child")+ .matchesSelector(+ ".query-results-chart",+ "the chart is shown above the table");- assert.dom("table").exists("the table was rendered");});- test("renders a chart button when data has two columns and numbers in the second column", async function (assert) {+ test("renders a chart when data has two columns and numbers in the second column", async function (assert) {const content = {colrender: [],result_count: 2,@@ -193,12 +180,10 @@ module(await render(<template><QueryResult @content={{content}} /></template>);- assert- .dom("div.result-info button:nth-child(3) span")- .hasText(i18n("explorer.show_graph"));+ assert.dom("canvas").exists();});- test("doesn't render a chart button when data contains identifiers in the second column", async function (assert) {+ test("doesn't render a chart when data contains identifiers in the second column", async function (assert) {const content = {colrender: { 1: "user" },relations: {@@ -217,10 +202,10 @@ module(await render(<template><QueryResult @content={{content}} /></template>);- assert.dom("div.result-info button:nth-child(3)").doesNotExist();+ assert.dom("canvas").doesNotExist();});- test("doesn't render a chart button when data contains one column", async function (assert) {+ test("doesn't render a chart when data contains one column", async function (assert) {const content = {colrender: [],result_count: 2,@@ -230,10 +215,10 @@ module(await render(<template><QueryResult @content={{content}} /></template>);- assert.dom("div.result-info button:nth-child(3)").doesNotExist();+ assert.dom("canvas").doesNotExist();});- test("renders a chart button when data contains multiple numeric columns", async function (assert) {+ test("renders a chart when data contains multiple numeric columns", async function (assert) {const content = {colrender: [],result_count: 2,@@ -246,12 +231,10 @@ module(await render(<template><QueryResult @content={{content}} /></template>);- assert- .dom("div.result-info button:nth-child(3) span")- .hasText(i18n("explorer.show_graph"));+ assert.dom("canvas").exists();});- test("doesn't render a chart button when all non-label columns are relation types", async function (assert) {+ test("doesn't render a chart when all non-label columns are relation types", async function (assert) {const content = {colrender: { 1: "user", 2: "badge" },relations: {@@ -265,7 +248,7 @@ module(await render(<template><QueryResult @content={{content}} /></template>);- assert.dom("div.result-info button:nth-child(3)").doesNotExist();+ assert.dom("canvas").doesNotExist();});test("renders a chart for date-based data", async function (assert) {@@ -281,11 +264,6 @@ module(await render(<template><QueryResult @content={{content}} /></template>);- assert- .dom("div.result-info button:nth-child(3) span")- .hasText(i18n("explorer.show_graph"));-- await click("div.result-info button:nth-child(3)");assert.dom("canvas").exists("renders a chart canvas");});@@ -302,7 +280,6 @@ module(await render(<template><QueryResult @content={{content}} /></template>);- await click("div.result-info button:nth-child(3)");assert.dom("canvas").exists("renders a chart canvas for multi-series");});