From 890433a8d6a2fa6105a80461d690b6c47e833fd3 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Mon, 8 May 2023 18:42:57 +0530 Subject: [PATCH] fix(ui): fix the icon squeezing issue in entity headers and only name in right panel header (#11480) * fix the icon squeezing issue in service pages * minor fixes --- .../EntityHeader/EntityHeader.component.tsx | 62 ++++++-------- .../EntityHeaderTitle.component.tsx | 8 +- .../EntitySummaryPanel.component.tsx | 44 +++++----- .../EntitySummaryPanel.test.tsx | 15 ++-- .../GlossaryHeader.component.tsx | 80 +++++++++---------- .../common/entityPageInfo/EntityPageInfo.tsx | 38 +++++---- .../table-data-card-v2/TableDataCardV2.tsx | 32 ++++---- .../ui/src/pages/database-details/index.tsx | 57 ++++++------- .../resources/ui/src/pages/service/index.tsx | 37 +++++---- 9 files changed, 191 insertions(+), 182 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeader/EntityHeader.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeader/EntityHeader.component.tsx index 39332c5819c..f4eb7493110 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeader/EntityHeader.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeader/EntityHeader.component.tsx @@ -11,7 +11,6 @@ * limitations under the License. */ -import { Col, Row } from 'antd'; import classNames from 'classnames'; import TitleBreadcrumb from 'components/common/title-breadcrumb/title-breadcrumb.component'; import { TitleBreadcrumbProps } from 'components/common/title-breadcrumb/title-breadcrumb.interface'; @@ -22,7 +21,6 @@ import { getEncodedFqn } from 'utils/StringsUtils'; import EntityHeaderTitle from '../EntityHeaderTitle/EntityHeaderTitle.component'; interface Props { - extra?: ReactNode; breadcrumb: TitleBreadcrumbProps['titleLinks']; entityData: { displayName?: string; @@ -41,7 +39,6 @@ interface Props { export const EntityHeader = ({ breadcrumb, entityData, - extra, icon, titleIsLink = false, entityType, @@ -50,39 +47,32 @@ export const EntityHeader = ({ serviceName, }: Props) => { return ( - - -
- -
+
+
+ +
- - - {extra} - + +
); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx index 9fecdc6f055..366508848a0 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityHeaderTitle/EntityHeaderTitle.component.tsx @@ -43,11 +43,11 @@ const EntityHeaderTitle = ({ data-testid={`${serviceName}-${name}`} gutter={8} wrap={false}> - {icon} - + {icon} +
{stringToHTML(name)} @@ -80,7 +80,7 @@ const EntityHeaderTitle = ({ return link && !isTourRoute ? ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.component.tsx index 4daef22b824..20c33dc9711 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.component.tsx @@ -12,8 +12,7 @@ */ import { CloseOutlined } from '@ant-design/icons'; -import { Drawer } from 'antd'; -import { EntityHeader } from 'components/Entity/EntityHeader/EntityHeader.component'; +import { Drawer, Typography } from 'antd'; import { EntityType } from 'enums/entity.enum'; import { Tag } from 'generated/entity/classification/tag'; import { Container } from 'generated/entity/data/container'; @@ -22,9 +21,9 @@ import { GlossaryTerm } from 'generated/entity/data/glossaryTerm'; import { Table } from 'generated/entity/data/table'; import { get } from 'lodash'; import React, { useMemo } from 'react'; -import { useParams } from 'react-router-dom'; -import { getEntityBreadcrumbs } from 'utils/EntityUtils'; -import { getServiceIcon } from 'utils/TableUtils'; +import { Link, useParams } from 'react-router-dom'; +import { getEntityLinkFromType, getEntityName } from 'utils/EntityUtils'; +import { getEncodedFqn } from 'utils/StringsUtils'; import { Mlmodel } from '../../../generated/entity/data/mlmodel'; import { Pipeline } from '../../../generated/entity/data/pipeline'; import { Topic } from '../../../generated/entity/data/topic'; @@ -78,9 +77,17 @@ export default function EntitySummaryPanel({ } }, [tab, entityDetails]); - const icon = useMemo(() => { - return getServiceIcon(entityDetails.details); - }, [entityDetails]); + const entityLink = useMemo( + () => + (entityDetails.details.fullyQualifiedName && + entityDetails.details.entityType && + getEntityLinkFromType( + getEncodedFqn(entityDetails.details.fullyQualifiedName), + entityDetails.details.entityType as EntityType + )) ?? + '', + [entityDetails, getEntityLinkFromType, getEncodedFqn] + ); return ( - -
+ + + {getEntityName(entityDetails.details)} + + } width="100%"> {summaryComponent} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.test.tsx index 17e87bff408..3c79c90ab8f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/EntitySummaryPanel.test.tsx @@ -48,6 +48,14 @@ jest.mock('./DashboardSummary/DashboardSummary.component', () => )) ); +jest.mock('utils/EntityUtils', () => ({ + getEntityLinkFromType: jest.fn().mockImplementation(() => 'link'), + getEntityName: jest.fn().mockImplementation(() => 'displayName'), +})); +jest.mock('utils/StringsUtils', () => ({ + getEncodedFqn: jest.fn().mockImplementation((fqn) => fqn), +})); + jest.mock('./PipelineSummary/PipelineSummary.component', () => jest .fn() @@ -66,10 +74,7 @@ jest.mock('./MlModelSummary/MlModelSummary.component', () => jest.mock('react-router-dom', () => ({ useParams: jest.fn().mockImplementation(() => ({ tab: 'table' })), -})); - -jest.mock('components/Entity/EntityHeader/EntityHeader.component', () => ({ - EntityHeader: jest.fn().mockImplementation(() =>

EntityHeader

), + Link: jest.fn().mockImplementation(({ children }) => <>{children}), })); describe('EntitySummaryPanel component tests', () => { @@ -83,11 +88,9 @@ describe('EntitySummaryPanel component tests', () => { /> ); - const entityHeader = screen.getByText('EntityHeader'); const tableSummary = screen.getByTestId('TableSummary'); const closeIcon = screen.getByTestId('summary-panel-close-icon'); - expect(entityHeader).toBeInTheDocument(); expect(tableSummary).toBeInTheDocument(); expect(closeIcon).toBeInTheDocument(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryHeader/GlossaryHeader.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryHeader/GlossaryHeader.component.tsx index 91124759360..39b7d15d120 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryHeader/GlossaryHeader.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryHeader/GlossaryHeader.component.tsx @@ -362,50 +362,12 @@ const GlossaryHeader = ({ return ( <> - - + + -
- {createButtons} - {selectedData && selectedData.version && ( - - )} - - {permissions.Delete && ( - - - - - - )} -
- - } gutter="large" icon={ isGlossary ? ( @@ -427,6 +389,44 @@ const GlossaryHeader = ({ serviceName="" /> + +
+
+ {createButtons} + {selectedData && selectedData.version && ( + + )} + + {permissions.Delete && ( + + + + + + )} +
+
+
{selectedData && ( - + + + ) + } + serviceName={serviceType ?? ''} + /> + + {!isUndefined(version) && ( )} - } - icon={ - serviceType && ( - - ) - } - serviceName={serviceType ?? ''} - /> + +
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card-v2/TableDataCardV2.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card-v2/TableDataCardV2.tsx index 2ee49a5bd09..92541815fef 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card-v2/TableDataCardV2.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/table-data-card-v2/TableDataCardV2.tsx @@ -11,7 +11,7 @@ * limitations under the License. */ -import { Checkbox } from 'antd'; +import { Checkbox, Col, Row } from 'antd'; import classNames from 'classnames'; import { EntityHeader } from 'components/Entity/EntityHeader/EntityHeader.component'; import { isString, startCase, uniqueId } from 'lodash'; @@ -151,20 +151,24 @@ const TableDataCardV2: React.FC = forwardRef< onClick={() => { handleSummaryPanelDisplay && handleSummaryPanelDisplay(source, tab); }}> - + + + + + {showCheckboxes && ( - ) - } - icon={serviceIcon} - openEntityInNewPage={openEntityInNewPage} - serviceName={source.serviceType ?? ''} - /> + )} + +
{ /> ) : ( <> - - {database && ( - - } - icon={ - - } - serviceName={database.service.name ?? ''} - /> - )} - - + {database && ( + + + + } + serviceName={database.service.name ?? ''} + /> + + + + + + )} {extraInfo.map((info, index) => ( diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx index 96f8c570e04..687af8cabc9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx @@ -1088,13 +1088,24 @@ const ServicePage: FunctionComponent = () => { entity: getEntityName(serviceDetails), })}> {servicePermission.ViewAll || servicePermission.ViewBasic ? ( - + {serviceDetails && ( - + + + } + serviceName={serviceDetails.name} + /> + + + {serviceDetails?.serviceType !== MetadataServiceType.OpenMetadata && ( { {t('label.delete')} - ) - } - icon={ - - } - serviceName={serviceDetails.name} - /> + )} + + )} + {extraInfo.map((info) => (