mirror of https://github.com/buster-so/buster.git
Add a splitter
This commit is contained in:
parent
6cfc2ec655
commit
cb0ebe7eda
|
@ -16,6 +16,7 @@ import type { RunSQLResponse } from '@/api/asset_interfaces';
|
||||||
import { useMemoizedFn } from '@/hooks';
|
import { useMemoizedFn } from '@/hooks';
|
||||||
import { Button } from '@/components/ui/buttons';
|
import { Button } from '@/components/ui/buttons';
|
||||||
import { Input } from '@/components/ui/inputs';
|
import { Input } from '@/components/ui/inputs';
|
||||||
|
import { AppSplitter } from '@/components/ui/layouts/AppSplitter';
|
||||||
|
|
||||||
type YamlifiedConfig = {
|
type YamlifiedConfig = {
|
||||||
sql: string;
|
sql: string;
|
||||||
|
@ -108,8 +109,8 @@ export default function ChartPlayground() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
// Define the left panel content (code editor and controls)
|
||||||
<div className="grid h-screen grid-cols-[2fr_3fr] gap-4 p-4">
|
const leftPanelContent = (
|
||||||
<div className="bg-background flex h-full w-full flex-col space-y-4 overflow-hidden rounded-lg border p-4">
|
<div className="bg-background flex h-full w-full flex-col space-y-4 overflow-hidden rounded-lg border p-4">
|
||||||
<div className="h-full w-full overflow-hidden">
|
<div className="h-full w-full overflow-hidden">
|
||||||
<AppCodeEditor value={config} onChange={setConfig} />
|
<AppCodeEditor value={config} onChange={setConfig} />
|
||||||
|
@ -127,8 +128,10 @@ export default function ChartPlayground() {
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
{/* Second column - 40% width */}
|
// Define the right panel content (chart preview)
|
||||||
|
const rightPanelContent = (
|
||||||
<div className="bg-background flex h-full flex-col overflow-hidden rounded-lg border shadow-sm">
|
<div className="bg-background flex h-full flex-col overflow-hidden rounded-lg border shadow-sm">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="bg-muted/30 border-b px-6 py-4">
|
<div className="bg-muted/30 border-b px-6 py-4">
|
||||||
|
@ -145,7 +148,7 @@ export default function ChartPlayground() {
|
||||||
<h4 className="text-sm font-semibold text-red-800">Chart Configuration Error</h4>
|
<h4 className="text-sm font-semibold text-red-800">Chart Configuration Error</h4>
|
||||||
</div>
|
</div>
|
||||||
<pre className="overflow-x-auto rounded bg-red-100 p-3 text-xs whitespace-pre-wrap text-red-700">
|
<pre className="overflow-x-auto rounded bg-red-100 p-3 text-xs whitespace-pre-wrap text-red-700">
|
||||||
{JSON.stringify(chartConfigError as Object, null, 2)}
|
{JSON.stringify(chartConfigError || {}, null, 2)}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -157,7 +160,7 @@ export default function ChartPlayground() {
|
||||||
<h4 className="text-sm font-semibold text-red-800">SQL Execution Error</h4>
|
<h4 className="text-sm font-semibold text-red-800">SQL Execution Error</h4>
|
||||||
</div>
|
</div>
|
||||||
<pre className="overflow-x-auto rounded bg-red-100 p-3 text-xs whitespace-pre-wrap text-red-700">
|
<pre className="overflow-x-auto rounded bg-red-100 p-3 text-xs whitespace-pre-wrap text-red-700">
|
||||||
{JSON.stringify(runSQLError as Object, null, 2)}
|
{JSON.stringify(runSQLError || {}, null, 2)}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -235,6 +238,23 @@ export default function ChartPlayground() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="h-screen w-screen p-4">
|
||||||
|
<AppSplitter
|
||||||
|
autoSaveId="chart-playground"
|
||||||
|
splitterClassName="mx-2"
|
||||||
|
defaultLayout={DEFAULT_LAYOUT}
|
||||||
|
className="h-full w-full"
|
||||||
|
leftPanelMinSize="200px"
|
||||||
|
rightPanelMinSize="200px"
|
||||||
|
leftChildren={leftPanelContent}
|
||||||
|
rightChildren={rightPanelContent}
|
||||||
|
preserveSide="left"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT_LAYOUT = ['40%', 'auto'];
|
||||||
|
|
Loading…
Reference in New Issue