mirror of https://github.com/buster-so/buster.git
Move features components to feature folder
This commit is contained in:
parent
4a37d59fc2
commit
b540d3ff3c
|
@ -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 { AppVerticalSplitterWithGap } from '@/components/ui/layout/AppVerticalSplitterWithGap';
|
import { AppVerticalCodeSplitter } from '@/components/features/AppVerticalCodeSplitter';
|
||||||
import { useDatasetPageContextSelector } from '../_DatasetsLayout/DatasetPageContext';
|
import { useDatasetPageContextSelector } from '../_DatasetsLayout/DatasetPageContext';
|
||||||
|
|
||||||
export const EditorContent: React.FC<{
|
export const EditorContent: React.FC<{
|
||||||
|
@ -73,7 +73,7 @@ export const EditorContent: React.FC<{
|
||||||
<EditorContainerSubHeader selectedApp={selectedApp} setSelectedApp={setSelectedApp} />
|
<EditorContainerSubHeader selectedApp={selectedApp} setSelectedApp={setSelectedApp} />
|
||||||
<div className={cx('h-full w-full overflow-hidden p-5', styles.container)}>
|
<div className={cx('h-full w-full overflow-hidden p-5', styles.container)}>
|
||||||
{selectedApp === EditorApps.PREVIEW && (
|
{selectedApp === EditorApps.PREVIEW && (
|
||||||
<AppVerticalSplitterWithGap
|
<AppVerticalCodeSplitter
|
||||||
autoSaveId="dataset-editor"
|
autoSaveId="dataset-editor"
|
||||||
ref={splitterRef}
|
ref={splitterRef}
|
||||||
sql={sql}
|
sql={sql}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { Meta, StoryObj } from '@storybook/react';
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
import { AppVerticalSplitterWithGap } from './AppVerticalSplitterWithGap';
|
import { AppVerticalCodeSplitter } from './AppVerticalCodeSplitter';
|
||||||
|
|
||||||
const meta: Meta<typeof AppVerticalSplitterWithGap> = {
|
const meta: Meta<typeof AppVerticalCodeSplitter> = {
|
||||||
title: 'UI/Layouts/AppVerticalSplitterWithGap',
|
title: 'UI/Layouts/AppVerticalCodeSplitter',
|
||||||
component: AppVerticalSplitterWithGap,
|
component: AppVerticalCodeSplitter,
|
||||||
parameters: {
|
parameters: {
|
||||||
layout: 'fullscreen'
|
layout: 'fullscreen'
|
||||||
},
|
},
|
||||||
|
@ -11,7 +11,7 @@ const meta: Meta<typeof AppVerticalSplitterWithGap> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof AppVerticalSplitterWithGap>;
|
type Story = StoryObj<typeof AppVerticalCodeSplitter>;
|
||||||
|
|
||||||
const mockData: Record<string, string | number | null>[] = [
|
const mockData: Record<string, string | number | null>[] = [
|
||||||
{ id: 1, name: 'Sample Data 1' },
|
{ id: 1, name: 'Sample Data 1' },
|
|
@ -1,10 +1,10 @@
|
||||||
import React, { forwardRef } from 'react';
|
import React, { forwardRef } from 'react';
|
||||||
import { AppSplitter, type AppSplitterRef } from '../AppSplitter';
|
import { AppSplitter, type AppSplitterRef } from '@/components/ui/layout/AppSplitter';
|
||||||
import { SQLContainer } from './SQLContainer';
|
import { SQLContainer } from './SQLContainer';
|
||||||
import { DataContainer } from './DataContainer';
|
import { DataContainer } from './DataContainer';
|
||||||
import type { IDataResult } from '@/api/asset_interfaces';
|
import type { IDataResult } from '@/api/asset_interfaces';
|
||||||
|
|
||||||
export interface AppVerticalSplitterWithGapProps {
|
export interface AppVerticalCodeSplitterProps {
|
||||||
sql: string;
|
sql: string;
|
||||||
setSQL: (sql: string) => void;
|
setSQL: (sql: string) => void;
|
||||||
runSQLError: string | null;
|
runSQLError: string | null;
|
||||||
|
@ -19,10 +19,7 @@ export interface AppVerticalSplitterWithGapProps {
|
||||||
gapAmount?: number;
|
gapAmount?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AppVerticalSplitterWithGap = forwardRef<
|
export const AppVerticalCodeSplitter = forwardRef<AppSplitterRef, AppVerticalCodeSplitterProps>(
|
||||||
AppSplitterRef,
|
|
||||||
AppVerticalSplitterWithGapProps
|
|
||||||
>(
|
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
sql,
|
sql,
|
||||||
|
@ -77,4 +74,4 @@ export const AppVerticalSplitterWithGap = forwardRef<
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
AppVerticalSplitterWithGap.displayName = 'AppVerticalSplitterWithGap';
|
AppVerticalCodeSplitter.displayName = 'AppVerticalCodeSplitter';
|
|
@ -2,8 +2,8 @@ import type { IDataResult } from '@/api/asset_interfaces';
|
||||||
import { createStyles } from 'antd-style';
|
import { createStyles } from 'antd-style';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
import AppDataGrid from '../../table/AppDataGrid';
|
import { AppDataGrid } from '@/components/ui/table/AppDataGrid';
|
||||||
import { IndeterminateLinearLoader } from '../../loaders';
|
import { IndeterminateLinearLoader } from '@/components/ui/loaders/IndeterminateLinearLoader';
|
||||||
|
|
||||||
export const DataContainer: React.FC<{
|
export const DataContainer: React.FC<{
|
||||||
data: IDataResult;
|
data: IDataResult;
|
||||||
|
@ -17,7 +17,7 @@ export const DataContainer: React.FC<{
|
||||||
<div className={cx(styles.container, 'relative h-full w-full overflow-hidden', className)}>
|
<div className={cx(styles.container, 'relative h-full w-full overflow-hidden', className)}>
|
||||||
<IndeterminateLinearLoader
|
<IndeterminateLinearLoader
|
||||||
className={cx(
|
className={cx(
|
||||||
'absolute left-0 top-0 z-10 w-full',
|
'absolute top-0 left-0 z-10 w-full',
|
||||||
fetchingData && hasData ? 'block' : 'hidden!'
|
fetchingData && hasData ? 'block' : 'hidden!'
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
|
@ -1,20 +1,20 @@
|
||||||
import { AppMaterialIcons } from '../../icons';
|
import { Command, Xmark, CircleWarning, ReturnKey } from '@/components/ui/icons';
|
||||||
import { AppCodeEditor } from '../../inputs/AppCodeEditor';
|
import { AppCodeEditor } from '@/components/ui/inputs/AppCodeEditor';
|
||||||
import { useBusterNotifications } from '@/context/BusterNotifications';
|
import { useBusterNotifications } from '@/context/BusterNotifications';
|
||||||
import { useMemoizedFn } from 'ahooks';
|
import { useMemoizedFn } from 'ahooks';
|
||||||
import { Button, Divider } from 'antd';
|
|
||||||
import { createStyles } from 'antd-style';
|
import { createStyles } from 'antd-style';
|
||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import { Button } from '@/components/ui/buttons/Button';
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
import type { AppVerticalSplitterWithGapProps } from './AppVerticalSplitterWithGap';
|
import type { AppVerticalCodeSplitterProps } from './AppVerticalCodeSplitter';
|
||||||
|
|
||||||
export const SQLContainer: React.FC<{
|
export const SQLContainer: React.FC<{
|
||||||
className?: string;
|
className?: string;
|
||||||
sql: string | undefined;
|
sql: string | undefined;
|
||||||
setDatasetSQL: (sql: string) => void;
|
setDatasetSQL: (sql: string) => void;
|
||||||
onRunQuery: () => Promise<void>;
|
onRunQuery: () => Promise<void>;
|
||||||
onSaveSQL?: AppVerticalSplitterWithGapProps['onSaveSQL'];
|
onSaveSQL?: AppVerticalCodeSplitterProps['onSaveSQL'];
|
||||||
disabledSave?: AppVerticalSplitterWithGapProps['disabledSave'];
|
disabledSave?: AppVerticalCodeSplitterProps['disabledSave'];
|
||||||
error?: string | null;
|
error?: string | null;
|
||||||
}> = React.memo(
|
}> = React.memo(
|
||||||
({ disabledSave, className = '', sql, setDatasetSQL, onRunQuery, onSaveSQL, error }) => {
|
({ disabledSave, className = '', sql, setDatasetSQL, onRunQuery, onSaveSQL, error }) => {
|
||||||
|
@ -47,32 +47,33 @@ export const SQLContainer: React.FC<{
|
||||||
onChange={setDatasetSQL}
|
onChange={setDatasetSQL}
|
||||||
onMetaEnter={onRunQueryPreflight}
|
onMetaEnter={onRunQueryPreflight}
|
||||||
/>
|
/>
|
||||||
<Divider className="my-0!" />
|
<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">
|
||||||
<Button type="default" onClick={onCopySQL}>
|
<Button onClick={onCopySQL}>Copy SQL</Button>
|
||||||
Copy SQL
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
{onSaveSQL && (
|
{onSaveSQL && (
|
||||||
<Button
|
<Button
|
||||||
disabled={disabledSave || !sql || isRunning}
|
disabled={disabledSave || !sql || isRunning}
|
||||||
color="default"
|
variant="black"
|
||||||
variant="solid"
|
|
||||||
onClick={onSaveSQL}>
|
onClick={onSaveSQL}>
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
type="default"
|
variant="default"
|
||||||
loading={isRunning}
|
loading={isRunning}
|
||||||
disabled={!sql}
|
disabled={!sql}
|
||||||
className="flex items-center space-x-0"
|
className="flex items-center space-x-0"
|
||||||
onClick={onRunQueryPreflight}>
|
onClick={onRunQueryPreflight}
|
||||||
<span>Run</span>
|
suffix={
|
||||||
<AppMaterialIcons icon="keyboard_command_key" />
|
<div className="flex items-center">
|
||||||
<AppMaterialIcons icon="keyboard_return" />
|
<Command />
|
||||||
|
<ReturnKey />
|
||||||
|
</div>
|
||||||
|
}>
|
||||||
|
Run
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ const ErrorContainer: React.FC<{
|
||||||
className={cx(styles.errorContainer, 'absolute right-0 bottom-full left-0 mx-4 mb-2')}>
|
className={cx(styles.errorContainer, 'absolute right-0 bottom-full left-0 mx-4 mb-2')}>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<AppMaterialIcons icon="error" />
|
<CircleWarning />
|
||||||
<span>{error}</span>
|
<span>{error}</span>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
@ -113,7 +114,7 @@ const ErrorContainer: React.FC<{
|
||||||
styles.closeButton,
|
styles.closeButton,
|
||||||
'rounded-sm p-0.5 transition-colors hover:bg-black/5'
|
'rounded-sm p-0.5 transition-colors hover:bg-black/5'
|
||||||
)}>
|
)}>
|
||||||
<AppMaterialIcons icon="close" className="text-sm" />
|
<Xmark />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './AppVerticalCodeSplitter';
|
|
@ -1 +0,0 @@
|
||||||
export * from './AppVerticalSplitterWithGap';
|
|
|
@ -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 { AppVerticalSplitterWithGap } from '@/components/ui/layout/AppVerticalSplitterWithGap';
|
import { AppVerticalCodeSplitter } from '@/components/features/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';
|
||||||
|
@ -82,7 +82,7 @@ export const MetricViewResults: React.FC<MetricViewProps> = React.memo(({ metric
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={containerRef} className="h-full w-full p-3">
|
<div ref={containerRef} className="h-full w-full p-3">
|
||||||
<AppVerticalSplitterWithGap
|
<AppVerticalCodeSplitter
|
||||||
ref={appSplitterRef}
|
ref={appSplitterRef}
|
||||||
autoSaveId={autoSaveId}
|
autoSaveId={autoSaveId}
|
||||||
sql={sql}
|
sql={sql}
|
||||||
|
|
Loading…
Reference in New Issue