From cc0ab0fc39b316e85c15e4eb31a0d53a356217ce Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Sun, 30 Jun 2024 13:00:49 +0900 Subject: [PATCH] Follow review comments --- .../ts/components/Artifact/TableArtifactViewer.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/optuna_dashboard/ts/components/Artifact/TableArtifactViewer.tsx b/optuna_dashboard/ts/components/Artifact/TableArtifactViewer.tsx index c398c02b..bb346fe4 100644 --- a/optuna_dashboard/ts/components/Artifact/TableArtifactViewer.tsx +++ b/optuna_dashboard/ts/components/Artifact/TableArtifactViewer.tsx @@ -38,7 +38,7 @@ export const TableArtifactViewer: React.FC = ( const loadedData = await loadData(props) setData(loadedData) } catch (error: unknown) { - enqueueSnackbar("Failed to load the file. " + error, { + enqueueSnackbar(`Failed to load the file. ${error}`, { variant: "error", }) } @@ -47,7 +47,13 @@ export const TableArtifactViewer: React.FC = ( }, [props]) const columns = React.useMemo(() => { - const keys = data.length > 0 ? Object.keys(data[0]) : [] + const unionSet: Set = new Set() + data.forEach((d) => { + Object.keys(d).forEach((key) => { + unionSet.add(key) + }) + }) + const keys = Array.from(unionSet) return keys.map((key) => ({ header: key, accessorFn: (info: Data) =>