diff --git a/web/app/components/workflow/skill/viewer/sqlite-file-preview/index.tsx b/web/app/components/workflow/skill/viewer/sqlite-file-preview/index.tsx index f32db83c8e..cf110654cb 100644 --- a/web/app/components/workflow/skill/viewer/sqlite-file-preview/index.tsx +++ b/web/app/components/workflow/skill/viewer/sqlite-file-preview/index.tsx @@ -4,7 +4,7 @@ import { useEffect, useMemo, useReducer, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import Loading from '@/app/components/base/loading' import { useSQLiteDatabase } from '../../hooks/use-sqlite-database' -import DataTable from './data-table' +import TablePanel from './table-panel' import TableSelector from './table-selector' type SQLiteFilePreviewProps = { @@ -149,40 +149,12 @@ const SQLiteFilePreview: FC = ({ isLoading={tableState.isLoading} /> -
- {tableState.isLoading - ? ( -
- -
- ) - : tableState.error - ? ( -
- - {t('skillSidebar.sqlitePreview.loadError')} - -
- ) - : tableState.data - ? ( - - ) - : ( -
- - {t('skillSidebar.sqlitePreview.emptyRows')} - -
- )} -
+ ) } diff --git a/web/app/components/workflow/skill/viewer/sqlite-file-preview/table-panel.tsx b/web/app/components/workflow/skill/viewer/sqlite-file-preview/table-panel.tsx new file mode 100644 index 0000000000..1a2c57267d --- /dev/null +++ b/web/app/components/workflow/skill/viewer/sqlite-file-preview/table-panel.tsx @@ -0,0 +1,61 @@ +import type { FC, RefObject } from 'react' +import type { SQLiteQueryResult } from '../../hooks/sqlite/types' +import * as React from 'react' +import { useTranslation } from 'react-i18next' +import Loading from '@/app/components/base/loading' +import DataTable from './data-table' + +type TablePanelProps = { + data: SQLiteQueryResult | null + isLoading: boolean + error: Error | null + scrollRef: RefObject +} + +const TablePanel: FC = ({ + data, + isLoading, + error, + scrollRef, +}) => { + const { t } = useTranslation('workflow') + + return ( +
+ {isLoading + ? ( +
+ +
+ ) + : error + ? ( +
+ + {t('skillSidebar.sqlitePreview.loadError')} + +
+ ) + : data + ? ( + + ) + : ( +
+ + {t('skillSidebar.sqlitePreview.emptyRows')} + +
+ )} +
+ ) +} + +export default React.memo(TablePanel)