Skip to content

Commit f268433

Browse files
authored
Merge pull request #1086 from merico-dev/1083-id_field-error-appears-during-initial-rendering-of-viz-table
1083 id field error appears during initial rendering of viz table
2 parents 2fd8bb6 + b173e09 commit f268433

File tree

8 files changed

+56
-31
lines changed

8 files changed

+56
-31
lines changed

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/api",
3-
"version": "10.9.7",
3+
"version": "10.9.8",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/dashboard",
3-
"version": "10.9.7",
3+
"version": "10.9.8",
44
"license": "Apache-2.0",
55
"publishConfig": {
66
"access": "public",

dashboard/src/plugins/viz-components/boxplot-chart/viz-boxplot-chart.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ClickBoxplotSeries } from './triggers';
2020
import { DEFAULT_CONFIG, IBoxplotChartConf, IBoxplotDataItem } from './type';
2121
import { parseDataKey } from '~/utils/data';
2222
import { useRowDataMap } from '~/plugins/hooks/use-row-data-map';
23+
import { Box } from '@mantine/core';
2324

2425
echarts.use([
2526
DataZoomComponent,
@@ -79,13 +80,15 @@ export function VizBoxplotChart({ context, instance }: VizViewProps) {
7980
return null;
8081
}
8182
return (
82-
<ReactEChartsCore
83-
echarts={echarts}
84-
option={option}
85-
style={{ width, height }}
86-
onEvents={onEvents}
87-
notMerge
88-
theme="merico-light"
89-
/>
83+
<Box sx={{ width, height, overflow: 'hidden' }}>
84+
<ReactEChartsCore
85+
echarts={echarts}
86+
option={option}
87+
style={{ width, height }}
88+
onEvents={onEvents}
89+
notMerge
90+
theme="merico-light"
91+
/>
92+
</Box>
9093
);
9194
}

dashboard/src/plugins/viz-components/cartesian/viz-cartesian-chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export function VizCartesianChart({ context, instance }: VizViewProps) {
144144

145145
const finalHeight = Math.max(0, height - topStatsHeight - bottomStatsHeight);
146146
return (
147-
<Box>
147+
<Box sx={{ width, height, overflow: 'hidden' }}>
148148
<Text
149149
ref={topStatsRef}
150150
align="left"

dashboard/src/plugins/viz-components/table/viz-table.tsx

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { Box, Table, TableProps, Text } from '@mantine/core';
22
import {
33
Cell,
4+
Row,
5+
SortingState,
46
createColumnHelper,
57
flexRender,
68
getCoreRowModel,
79
getSortedRowModel,
8-
Row,
9-
SortingState,
1010
useReactTable,
1111
} from '@tanstack/react-table';
12-
import _ from 'lodash';
1312
import React, { useCallback, useContext, useMemo, useState } from 'react';
1413
import { useVirtual } from 'react-virtual';
1514
import { useCurrentInteractionManager } from '~/interactions/hooks/use-current-interaction-manager';
@@ -18,12 +17,12 @@ import { HeadCell } from '~/plugins/viz-components/table/components/head-cell';
1817
import { ClickCellContent } from '~/plugins/viz-components/table/triggers/click-cell-content';
1918
import { baseTableSX, useTableStyles } from '~/plugins/viz-components/table/viz-table.styles';
2019
import { AnyObject } from '~/types';
21-
import { VizInstance, VizViewProps } from '~/types/plugin';
20+
import { VizInstance, VizViewContext, VizViewProps } from '~/types/plugin';
21+
import { parseDataKey } from '~/utils/data';
2222
import { IVizManager, PluginContext, useStorageData } from '../..';
2323
import { TableCellContext } from './table-cell-context';
24-
import { DEFAULT_CONFIG, IColumnConf, ITableConf, TriggerConfigType, ValueType } from './type';
24+
import { IColumnConf, ITableConf, TriggerConfigType, ValueType } from './type';
2525
import { CellValue } from './value';
26-
import { parseDataKey } from '~/utils/data';
2726

2827
const useGetCellContext = (context: {
2928
vizManager: IVizManager;
@@ -40,10 +39,16 @@ const useGetCellContext = (context: {
4039
);
4140
};
4241

43-
export function VizTable({ context, instance }: VizViewProps) {
44-
const data = context.data;
45-
const { height, width } = context.viewport;
46-
const { value: conf = DEFAULT_CONFIG } = useStorageData<ITableConf>(context.instanceData, 'config');
42+
type IVizTableComponent = {
43+
data: TPanelData;
44+
width: number;
45+
height: number;
46+
conf: ITableConf;
47+
instance: VizInstance;
48+
context: VizViewContext;
49+
};
50+
51+
function VizTableComponent({ data, width, height, conf, context, instance }: IVizTableComponent) {
4752
const { id_field, use_raw_columns, columns, ...rest } = conf;
4853

4954
const { classes, cx } = useTableStyles();
@@ -126,13 +131,6 @@ export function VizTable({ context, instance }: VizViewProps) {
126131
const showInfoBar = totalRows > 0;
127132
const tableHeight = showInfoBar ? height - 22 : height;
128133
const theadTop = showInfoBar ? 22 : 0;
129-
if (!id_field) {
130-
return (
131-
<Text color="red" align="center">
132-
ID Field is not set, can't render a table without it
133-
</Text>
134-
);
135-
}
136134
if (!Array.isArray(queryData) || queryData.length === 0) {
137135
return (
138136
<Text color="gray" align="center">
@@ -194,3 +192,27 @@ export function VizTable({ context, instance }: VizViewProps) {
194192
</div>
195193
);
196194
}
195+
export function VizTable({ context, instance }: VizViewProps) {
196+
const data = context.data;
197+
const { height, width } = context.viewport;
198+
const { value: conf } = useStorageData<ITableConf>(context.instanceData, 'config');
199+
200+
if (!conf) {
201+
return null;
202+
}
203+
204+
if (!conf.id_field) {
205+
console.group('🔴 what the fuck');
206+
console.log(conf);
207+
console.groupEnd();
208+
return (
209+
<Text color="red" align="center">
210+
ID Field is not set, can't render a table without it
211+
</Text>
212+
);
213+
}
214+
215+
return (
216+
<VizTableComponent data={data} width={width} height={height} conf={conf} context={context} instance={instance} />
217+
);
218+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/root",
3-
"version": "10.9.7",
3+
"version": "10.9.8",
44
"private": true,
55
"workspaces": [
66
"api",

settings-form/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtable/settings-form",
3-
"version": "10.9.7",
3+
"version": "10.9.8",
44
"license": "Apache-2.0",
55
"publishConfig": {
66
"access": "public",

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@devtable/website",
33
"private": true,
44
"license": "Apache-2.0",
5-
"version": "10.9.7",
5+
"version": "10.9.8",
66
"scripts": {
77
"dev": "vite",
88
"preview": "vite preview"

0 commit comments

Comments
 (0)