mirror of https://github.com/buster-so/buster.git
code editor updates
This commit is contained in:
parent
b540d3ff3c
commit
6e8f217233
|
@ -10,7 +10,7 @@ import { runSQL } from '@/api/buster_rest';
|
||||||
import type { RustApiError } from '@/api/buster_rest/errors';
|
import type { RustApiError } from '@/api/buster_rest/errors';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
import type { AppSplitterRef } from '@/components/ui/layout/AppSplitter';
|
import type { AppSplitterRef } from '@/components/ui/layout/AppSplitter';
|
||||||
import { AppVerticalCodeSplitter } from '@/components/features/AppVerticalCodeSplitter';
|
import { AppVerticalCodeSplitter } from '@/components/features/layout/AppVerticalCodeSplitter';
|
||||||
import { useDatasetPageContextSelector } from '../_DatasetsLayout/DatasetPageContext';
|
import { useDatasetPageContextSelector } from '../_DatasetsLayout/DatasetPageContext';
|
||||||
|
|
||||||
export const EditorContent: React.FC<{
|
export const EditorContent: React.FC<{
|
||||||
|
|
|
@ -2,12 +2,22 @@ import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import { AppVerticalCodeSplitter } from './AppVerticalCodeSplitter';
|
import { AppVerticalCodeSplitter } from './AppVerticalCodeSplitter';
|
||||||
|
|
||||||
const meta: Meta<typeof AppVerticalCodeSplitter> = {
|
const meta: Meta<typeof AppVerticalCodeSplitter> = {
|
||||||
title: 'UI/Layouts/AppVerticalCodeSplitter',
|
title: 'Features/Layout/AppVerticalCodeSplitter',
|
||||||
component: AppVerticalCodeSplitter,
|
component: AppVerticalCodeSplitter,
|
||||||
parameters: {
|
parameters: {
|
||||||
layout: 'fullscreen'
|
layout: 'fullscreen'
|
||||||
},
|
},
|
||||||
tags: ['autodocs']
|
tags: ['autodocs'],
|
||||||
|
args: {
|
||||||
|
className: 'min-h-[600px] min-w-[600px]'
|
||||||
|
},
|
||||||
|
decorators: [
|
||||||
|
(Story) => (
|
||||||
|
<div className="" style={{ height: '500px' }}>
|
||||||
|
<Story />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
|
@ -21,13 +31,13 @@ const mockData: Record<string, string | number | null>[] = [
|
||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
args: {
|
args: {
|
||||||
sql: 'SELECT * FROM sample_table',
|
sql: 'SELECT * FROM sample_table',
|
||||||
setSQL: (sql: string) => console.log('SQL changed:', sql),
|
setSQL: (sql: string) => alert('SQL changed: ' + sql),
|
||||||
runSQLError: null,
|
runSQLError: null,
|
||||||
onRunQuery: async () => console.log('Running query...'),
|
onRunQuery: async () => alert('Running query...'),
|
||||||
data: mockData,
|
data: mockData,
|
||||||
fetchingData: false,
|
fetchingData: false,
|
||||||
defaultLayout: ['50%', '50%'],
|
defaultLayout: ['50%', '50%'],
|
||||||
autoSaveId: 'default-splitter'
|
autoSaveId: 'default-split-for-code-splitter'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,14 +72,14 @@ export const CustomGap: Story = {
|
||||||
export const WithSaveButton: Story = {
|
export const WithSaveButton: Story = {
|
||||||
args: {
|
args: {
|
||||||
...Default.args,
|
...Default.args,
|
||||||
onSaveSQL: async () => console.log('Saving SQL...')
|
onSaveSQL: async () => alert('Saving SQL...')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DisabledSave: Story = {
|
export const DisabledSave: Story = {
|
||||||
args: {
|
args: {
|
||||||
...Default.args,
|
...Default.args,
|
||||||
onSaveSQL: async () => console.log('Saving SQL...'),
|
onSaveSQL: async () => alert('Saving SQL...'),
|
||||||
disabledSave: true
|
disabledSave: true
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -17,6 +17,7 @@ export interface AppVerticalCodeSplitterProps {
|
||||||
onSaveSQL?: () => Promise<void>;
|
onSaveSQL?: () => Promise<void>;
|
||||||
disabledSave?: boolean;
|
disabledSave?: boolean;
|
||||||
gapAmount?: number;
|
gapAmount?: number;
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AppVerticalCodeSplitter = forwardRef<AppSplitterRef, AppVerticalCodeSplitterProps>(
|
export const AppVerticalCodeSplitter = forwardRef<AppSplitterRef, AppVerticalCodeSplitterProps>(
|
||||||
|
@ -33,7 +34,8 @@ export const AppVerticalCodeSplitter = forwardRef<AppSplitterRef, AppVerticalCod
|
||||||
autoSaveId,
|
autoSaveId,
|
||||||
disabledSave = false,
|
disabledSave = false,
|
||||||
topHidden = false,
|
topHidden = false,
|
||||||
gapAmount = 3
|
gapAmount = 3,
|
||||||
|
className
|
||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
) => {
|
) => {
|
||||||
|
@ -69,6 +71,7 @@ export const AppVerticalCodeSplitter = forwardRef<AppSplitterRef, AppVerticalCod
|
||||||
rightPanelMinSize={'80px'}
|
rightPanelMinSize={'80px'}
|
||||||
leftPanelMinSize={'120px'}
|
leftPanelMinSize={'120px'}
|
||||||
leftHidden={topHidden}
|
leftHidden={topHidden}
|
||||||
|
className={className}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -46,6 +46,7 @@ export const SQLContainer: React.FC<{
|
||||||
value={sql}
|
value={sql}
|
||||||
onChange={setDatasetSQL}
|
onChange={setDatasetSQL}
|
||||||
onMetaEnter={onRunQueryPreflight}
|
onMetaEnter={onRunQueryPreflight}
|
||||||
|
variant={null}
|
||||||
/>
|
/>
|
||||||
<div className="bg-border-color my-0! h-[0.5px] w-full" />
|
<div className="bg-border-color my-0! h-[0.5px] w-full" />
|
||||||
<div className="relative flex items-center justify-between px-4 py-2.5">
|
<div className="relative flex items-center justify-between px-4 py-2.5">
|
||||||
|
@ -68,7 +69,7 @@ export const SQLContainer: React.FC<{
|
||||||
className="flex items-center space-x-0"
|
className="flex items-center space-x-0"
|
||||||
onClick={onRunQueryPreflight}
|
onClick={onRunQueryPreflight}
|
||||||
suffix={
|
suffix={
|
||||||
<div className="flex items-center">
|
<div className="flex items-center gap-x-1 text-sm">
|
||||||
<Command />
|
<Command />
|
||||||
<ReturnKey />
|
<ReturnKey />
|
||||||
</div>
|
</div>
|
|
@ -33,7 +33,7 @@ export interface AppCodeEditorProps {
|
||||||
readOnlyMessage?: string;
|
readOnlyMessage?: string;
|
||||||
defaultValue?: string;
|
defaultValue?: string;
|
||||||
monacoEditorOptions?: editor.IStandaloneEditorConstructionOptions;
|
monacoEditorOptions?: editor.IStandaloneEditorConstructionOptions;
|
||||||
variant?: 'bordered';
|
variant?: 'bordered' | null;
|
||||||
onMetaEnter?: () => void;
|
onMetaEnter?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,8 @@ const theme: editor.IStandaloneThemeData = {
|
||||||
'editorWhitespace.foreground': '#959da5',
|
'editorWhitespace.foreground': '#959da5',
|
||||||
'editorIndentGuide.background': '#959da5',
|
'editorIndentGuide.background': '#959da5',
|
||||||
'editorIndentGuide.activeBackground': '#24292e',
|
'editorIndentGuide.activeBackground': '#24292e',
|
||||||
'editor.selectionHighlightBorder': '#fafbfc'
|
'editor.selectionHighlightBorder': '#fafbfc',
|
||||||
|
focusBorder: '#00000000'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ const meta = {
|
||||||
tags: ['autodocs'],
|
tags: ['autodocs'],
|
||||||
decorators: [
|
decorators: [
|
||||||
(Story) => (
|
(Story) => (
|
||||||
<div className="" style={{ height: '400px' }}>
|
<div className="p-2" style={{ height: '400px' }}>
|
||||||
<Story />
|
<Story />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -235,12 +235,11 @@ export const AppSplitter = React.memo(
|
||||||
useImperativeHandle(ref, imperativeHandleMethods);
|
useImperativeHandle(ref, imperativeHandleMethods);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full w-full" ref={containerRef}>
|
<div className={cn('h-full w-full', className)} ref={containerRef}>
|
||||||
<SplitPane
|
<SplitPane
|
||||||
autoSizeId={autoSaveId}
|
autoSizeId={autoSaveId}
|
||||||
initialReady={initialReady}
|
initialReady={initialReady}
|
||||||
split={split}
|
split={split}
|
||||||
className={`${className}`}
|
|
||||||
sizes={_sizes}
|
sizes={_sizes}
|
||||||
style={style}
|
style={style}
|
||||||
allowResize={_allowResize}
|
allowResize={_allowResize}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useEffect, useMemo } from 'react';
|
import React, { useEffect, useMemo } from 'react';
|
||||||
import type { MetricViewProps } from '../config';
|
import type { MetricViewProps } from '../config';
|
||||||
import { useMetricIndividual } from '@/context/Metrics';
|
import { useMetricIndividual } from '@/context/Metrics';
|
||||||
import { AppVerticalCodeSplitter } from '@/components/features/AppVerticalCodeSplitter';
|
import { AppVerticalCodeSplitter } from '@/components/features/layout/AppVerticalCodeSplitter';
|
||||||
import { useMemoizedFn, useUnmount } from 'ahooks';
|
import { useMemoizedFn, useUnmount } from 'ahooks';
|
||||||
import { IDataResult } from '@/api/asset_interfaces';
|
import { IDataResult } from '@/api/asset_interfaces';
|
||||||
import { useMetricLayout } from '../useMetricLayout';
|
import { useMetricLayout } from '../useMetricLayout';
|
||||||
|
|
Loading…
Reference in New Issue