From 5a6443cfc3d14d400ddee092b539b78ba954d63e Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Wed, 24 Sep 2025 13:04:08 +0530 Subject: [PATCH] feat(ui): Enhance Profiler components with additional props and improve layout using Grid --- .../profilerDashboard.interface.ts | 1 + .../ProfilerLatestValue.tsx | 115 +++---- .../CustomMetricGraphs.component.tsx | 285 ++++++++++-------- .../TableProfilerChart/TableProfilerChart.tsx | 41 ++- 4 files changed, 242 insertions(+), 200 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerDashboard/profilerDashboard.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerDashboard/profilerDashboard.interface.ts index a3c346c9160..eb84fc815e3 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerDashboard/profilerDashboard.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerDashboard/profilerDashboard.interface.ts @@ -81,6 +81,7 @@ export interface ProfilerLatestValueProps { information: MetricChartType['information']; tickFormatter?: string; stringValue?: boolean; + extra?: ReactNode; } export type TestCaseAction = { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerLatestValue/ProfilerLatestValue.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerLatestValue/ProfilerLatestValue.tsx index cd5abdd764c..0af453d1c6b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerLatestValue/ProfilerLatestValue.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/ProfilerLatestValue/ProfilerLatestValue.tsx @@ -11,7 +11,7 @@ * limitations under the License. */ -import { Box, Divider, Stack, Typography, useTheme } from '@mui/material'; +import { Box, Divider, Grid, Typography, useTheme } from '@mui/material'; import { isUndefined } from 'lodash'; import { getStatisticsDisplayValue } from '../../../../utils/CommonUtils'; import '../ProfilerDashboard/profiler-dashboard.less'; @@ -21,6 +21,7 @@ const ProfilerLatestValue = ({ information, tickFormatter, stringValue = false, + extra, }: ProfilerLatestValueProps) => { const theme = useTheme(); @@ -37,65 +38,71 @@ const ProfilerLatestValue = ({ }; return ( - - {information.map((info) => ( - - - {info.title} - - - {getLatestValue(info.latestValue)} - - {info.extra && ( - <> - - - {info.extra} - - - )} - - ))} - + + {information.map((info) => ( + + + {info.title} + + + {getLatestValue(info.latestValue)} + + {info.extra && ( + <> + + + {info.extra} + + + )} + + ))} + + {extra && ( + + {extra} + + )} + ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/CustomMetricGraphs/CustomMetricGraphs.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/CustomMetricGraphs/CustomMetricGraphs.component.tsx index 3851b06fa66..0cb7d668ff6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/CustomMetricGraphs/CustomMetricGraphs.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/TableProfiler/CustomMetricGraphs/CustomMetricGraphs.component.tsx @@ -10,33 +10,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import MoreVertIcon from '@mui/icons-material/MoreVert'; import { - Button, - Card, - Col, - Dropdown, - Form, - Modal, - Row, - Typography, -} from 'antd'; + Box, + Grid, + IconButton, + Menu, + MenuItem, + Stack, + useTheme, +} from '@mui/material'; +import { Form, Modal } from 'antd'; import { AxiosError } from 'axios'; import { isEmpty, isUndefined, last, omit, toPairs } from 'lodash'; import { useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { + Area, CartesianGrid, - Legend, + ComposedChart, Line, - LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; -import { ReactComponent as IconDropdown } from '../../../../../assets/svg/menu.svg'; import { GRAPH_BACKGROUND_COLOR } from '../../../../../constants/constants'; -import { PAGE_HEADERS } from '../../../../../constants/PageHeaders.constant'; import { EntityType } from '../../../../../enums/entity.enum'; import { CustomMetric } from '../../../../../generated/entity/data/table'; import { Operation } from '../../../../../generated/entity/policies/policy'; @@ -48,11 +47,7 @@ import { axisTickFormatter, tooltipFormatter, } from '../../../../../utils/ChartUtils'; -import { entityChartColor } from '../../../../../utils/CommonUtils'; -import { - CustomTooltip, - getRandomHexColor, -} from '../../../../../utils/DataInsightUtils'; +import { CustomDQTooltip } from '../../../../../utils/DataQuality/DataQualityUtils'; import { formatDateTimeLong } from '../../../../../utils/date-time/DateTimeUtils'; import { getPrioritizedEditPermission } from '../../../../../utils/PermissionsUtils'; import { @@ -62,8 +57,7 @@ import { import DeleteWidgetModal from '../../../../common/DeleteWidget/DeleteWidgetModal'; import ErrorPlaceHolder from '../../../../common/ErrorWithPlaceholder/ErrorPlaceHolder'; import CustomMetricForm from '../../../../DataQuality/CustomMetricForm/CustomMetricForm.component'; -import PageHeader from '../../../../PageHeader/PageHeader.component'; -import ProfilerLatestValue from '../../ProfilerLatestValue/ProfilerLatestValue'; +import ProfilerStateWrapper from '../../ProfilerStateWrapper/ProfilerStateWrapper.component'; import { useTableProfiler } from '../TableProfilerProvider'; import './custom-metric-graphs.style.less'; import { @@ -76,6 +70,7 @@ const CustomMetricGraphs = ({ isLoading, customMetrics, }: CustomMetricGraphsProps) => { + const theme = useTheme(); const { t } = useTranslation(); const [form] = Form.useForm(); const { @@ -92,6 +87,9 @@ const CustomMetricGraphs = ({ const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false); const [isEditModalVisible, setIsEditModalVisible] = useState(false); const [isActionLoading, setIsActionLoading] = useState(false); + const [anchorEl, setAnchorEl] = useState>( + {} + ); const items = useMemo( () => [ @@ -168,6 +166,7 @@ const CustomMetricGraphs = ({ setSelectedMetrics( customMetrics?.find((metric) => metric.name === metricName) ); + setAnchorEl((prev) => ({ ...prev, [metricName]: null })); switch (key) { case MenuOptions.EDIT: setIsEditModalVisible(true); @@ -182,119 +181,157 @@ const CustomMetricGraphs = ({ } }; + const handleMenuOpen = ( + event: React.MouseEvent, + metricName: string + ) => { + setAnchorEl((prev) => ({ ...prev, [metricName]: event.currentTarget })); + }; + + const handleMenuClose = (metricName: string) => { + setAnchorEl((prev) => ({ ...prev, [metricName]: null })); + }; + return ( - - {!isEmpty(customMetrics) && ( - - - - )} - {toPairs(customMetricsGraphData).map(([key, metric], i) => { + + {toPairs(customMetricsGraphData).map(([key, metric]) => { const metricDetails = customMetrics?.find( (metric) => metric.name === key ); - const color = entityChartColor(i) ?? getRandomHexColor(); return isUndefined(metricDetails) ? null : ( - - + handleMenuClick(info.key, key), - }} - placement="bottomLeft" - trigger={['click']}> -