From 598b756ef7a9365f6d231b332aef2a8a93738f7b Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Fri, 13 Oct 2023 13:01:31 +0200 Subject: [PATCH] feat: Show [ No Title ] when chart title is missing (profile table) --- app/login/components/profile-tables.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/login/components/profile-tables.tsx b/app/login/components/profile-tables.tsx index 41f36450d..1caa295ec 100644 --- a/app/login/components/profile-tables.tsx +++ b/app/login/components/profile-tables.tsx @@ -26,6 +26,7 @@ import React from "react"; import useDisclosure from "@/components/use-disclosure"; import { ParsedConfig } from "@/db/config"; import { sourceToLabel } from "@/domain/datasource"; +import { truthy } from "@/domain/types"; import { useDataCubeMetadataQuery } from "@/graphql/query-hooks"; import { Icon, IconName } from "@/icons"; import { useRootStyles } from "@/login/utils"; @@ -221,6 +222,17 @@ const ProfileVisualizationsRow = (props: ProfileVisualizationsRowProps) => { return actions; }, [config.key, onRemoveSuccess, userId]); + const chartTitle = React.useMemo(() => { + const title = config.data.chartConfigs + .map((d) => d.meta.title[locale]) + .filter(truthy) + .join(", "); + + return title + ? title + : t({ id: "annotation.add.title", message: "[ No Title ]" }); + }, [config.data.chartConfigs, locale]); + return ( { - {config.data.chartConfigs - .map((d) => d.meta.title[locale]) - .join(", ")} + {chartTitle}