mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
fix(client): sql result taking unnecessary space when inactive
This commit is contained in:
parent
10a6a3056a
commit
49c80f0e0b
@ -10,13 +10,14 @@ export default function SqlResults() {
|
|||||||
const [ results, setResults ] = useState<SqlExecuteResults>();
|
const [ results, setResults ] = useState<SqlExecuteResults>();
|
||||||
|
|
||||||
useTriliumEvent("sqlQueryResults", ({ ntxId: eventNtxId, results }) => {
|
useTriliumEvent("sqlQueryResults", ({ ntxId: eventNtxId, results }) => {
|
||||||
if (eventNtxId !== ntxId) return;
|
if (eventNtxId !== ntxId) return;
|
||||||
setResults(results);
|
setResults(results);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isEnabled = note?.mime === "text/x-sqlite;schema=trilium";
|
||||||
return (
|
return (
|
||||||
<div className="sql-result-widget">
|
<div className={`sql-result-widget ${!isEnabled ? "hidden-ext" : ""}`}>
|
||||||
{note?.mime === "text/x-sqlite;schema=trilium" && (
|
{isEnabled && (
|
||||||
results?.length === 1 && Array.isArray(results[0]) && results[0].length === 0 ? (
|
results?.length === 1 && Array.isArray(results[0]) && results[0].length === 0 ? (
|
||||||
<Alert type="info">
|
<Alert type="info">
|
||||||
{t("sql_result.no_rows")}
|
{t("sql_result.no_rows")}
|
||||||
@ -26,9 +27,9 @@ export default function SqlResults() {
|
|||||||
{results?.map(rows => {
|
{results?.map(rows => {
|
||||||
// inserts, updates
|
// inserts, updates
|
||||||
if (typeof rows === "object" && !Array.isArray(rows)) {
|
if (typeof rows === "object" && !Array.isArray(rows)) {
|
||||||
return <pre>{JSON.stringify(rows, null, "\t")}</pre>
|
return <pre>{JSON.stringify(rows, null, "\t")}</pre>
|
||||||
}
|
}
|
||||||
|
|
||||||
// selects
|
// selects
|
||||||
return <SqlResultTable rows={rows} />
|
return <SqlResultTable rows={rows} />
|
||||||
})}
|
})}
|
||||||
@ -59,4 +60,4 @@ function SqlResultTable({ rows }: { rows: object[] }) {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user