From f10f7a806f102d53d4f66e88542afd98707c1f2d Mon Sep 17 00:00:00 2001 From: SagarRajput-7 <162284829+SagarRajput-7@users.noreply.github.com> Date: Fri, 16 May 2025 16:35:11 +0530 Subject: [PATCH] feat: suggest and allow variables in panel title (#7898) * feat: suggest and allow variables in panel title * feat: refined the logic for suggestion and addition with $ * feat: added logic for panel title resolved string and added test cases * feat: added support to full view --- .../GridCard/WidgetGraphComponent.tsx | 14 +- .../GridCardLayout/WidgetHeader/index.tsx | 22 ++- .../RightContainer/RightContainer.styles.scss | 1 - .../NewWidget/RightContainer/index.tsx | 109 +++++++++++- .../__test__/useGetResolvedText.test.tsx | 133 +++++++++++++++ .../hooks/dashboard/useGetResolvedText.tsx | 156 ++++++++++++++++++ 6 files changed, 419 insertions(+), 16 deletions(-) create mode 100644 frontend/src/hooks/dashboard/__test__/useGetResolvedText.test.tsx create mode 100644 frontend/src/hooks/dashboard/useGetResolvedText.tsx diff --git a/frontend/src/container/GridCardLayout/GridCard/WidgetGraphComponent.tsx b/frontend/src/container/GridCardLayout/GridCard/WidgetGraphComponent.tsx index 99f8d1f237..d39fe0c080 100644 --- a/frontend/src/container/GridCardLayout/GridCard/WidgetGraphComponent.tsx +++ b/frontend/src/container/GridCardLayout/GridCard/WidgetGraphComponent.tsx @@ -1,6 +1,6 @@ import '../GridCardLayout.styles.scss'; -import { Skeleton, Typography } from 'antd'; +import { Skeleton, Tooltip, Typography } from 'antd'; import cx from 'classnames'; import { useNavigateToExplorer } from 'components/CeleryTask/useNavigateToExplorer'; import { ToggleGraphProps } from 'components/Graph/types'; @@ -9,6 +9,7 @@ import { QueryParams } from 'constants/query'; import { PANEL_TYPES } from 'constants/queryBuilder'; import { placeWidgetAtBottom } from 'container/NewWidget/utils'; import PanelWrapper from 'container/PanelWrapper/PanelWrapper'; +import useGetResolvedText from 'hooks/dashboard/useGetResolvedText'; import { useUpdateDashboard } from 'hooks/dashboard/useUpdateDashboard'; import { useNotifications } from 'hooks/useNotifications'; import { useSafeNavigate } from 'hooks/useSafeNavigate'; @@ -293,6 +294,11 @@ function WidgetGraphComponent({ }); }; + const { truncatedText, fullText } = useGetResolvedText({ + text: widget.title as string, + maxLength: 100, + }); + return (