Skip to content

Commit

Permalink
Fix code highlighting + disable analyse button for sql queries
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke committed Dec 10, 2024
1 parent 56fa763 commit ec0692b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions shared/studio/tabs/perfStats/perfStats.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
.fullData {
display: grid;
grid-template-columns: repeat(6, auto);
margin: 0 48px 0 12px;
margin: 0 48px 16px 12px;
gap: 16px 24px;
max-width: 880px;

Expand Down Expand Up @@ -350,7 +350,7 @@

.analyseQueryButton {
align-self: flex-end;
margin-top: -32px;
margin-top: -48px;
margin-bottom: 16px;
margin-right: 8px;
}
Expand Down
27 changes: 19 additions & 8 deletions shared/studio/tabs/perfStats/statsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {useEffect, useRef, useState} from "react";
import {observer} from "mobx-react-lite";

import {sql, PostgreSQL} from "@codemirror/lang-sql";

import cn from "@edgedb/common/utils/classNames";

import {
Expand All @@ -19,6 +21,8 @@ import {OrderBy, PerfStatsState, QueryStats} from "./state";

import styles from "./perfStats.module.scss";

const sqlLang = sql({dialect: PostgreSQL}).language;

export const StatsTable = observer(function StatsTable({
state,
}: {
Expand Down Expand Up @@ -236,21 +240,28 @@ export const QueryStatsRow = observer(function QueryStatsRow({
</div>
</div>

<Button
className={styles.analyseQueryButton}
kind="outline"
onClick={() => state.setAnalyzeQuery(queryStats.query)}
>
Analyze Query
</Button>
{queryStats.query_type === "EdgeQL" ? (
<Button
className={styles.analyseQueryButton}
kind="outline"
onClick={() => state.setAnalyzeQuery(queryStats.query)}
>
Analyze Query
</Button>
) : null}

<div className={styles.fullQuery}>
<CopyButton
className={styles.copyButton}
content={queryStats.query}
mini
/>
<CodeBlock code={queryStats.query} />
<CodeBlock
code={queryStats.query}
language={
queryStats.query_type === "SQL" ? sqlLang : undefined
}
/>
</div>
</div>
) : null}
Expand Down

0 comments on commit ec0692b

Please sign in to comment.