Skip to content

Commit 113afc4

Browse files
authored
Merge branch 'datahub-project:master' into master
2 parents b06e122 + f58febc commit 113afc4

40 files changed

+2593
-678
lines changed

datahub-web-react/src/app/entity/shared/utils.ts

+81
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,84 @@ export function getStructuredPropertyValue(value: PropertyValue) {
140140
}
141141
return null;
142142
}
143+
144+
// Utility for formatting any casing of type to the expected casing for the API
145+
export function formatEntityType(type: string): string {
146+
if (!type) return '';
147+
148+
switch (type.toLowerCase()) {
149+
case 'dataset':
150+
return EntityType.Dataset;
151+
case 'role':
152+
return EntityType.Role;
153+
case 'corpuser':
154+
return EntityType.CorpUser;
155+
case 'corpgroup':
156+
return EntityType.CorpGroup;
157+
case 'dataplatform':
158+
return EntityType.DataPlatform;
159+
case 'dashboard':
160+
return EntityType.Dashboard;
161+
case 'chart':
162+
return EntityType.Chart;
163+
case 'tag':
164+
return EntityType.Tag;
165+
case 'dataflow':
166+
return EntityType.DataFlow;
167+
case 'datajob':
168+
return EntityType.DataJob;
169+
case 'glossaryterm':
170+
return EntityType.GlossaryTerm;
171+
case 'glossarynode':
172+
return EntityType.GlossaryNode;
173+
case 'mlmodel':
174+
return EntityType.Mlmodel;
175+
case 'mlmodelgroup':
176+
return EntityType.MlmodelGroup;
177+
case 'mlfeaturetable':
178+
return EntityType.MlfeatureTable;
179+
case 'mlfeature':
180+
return EntityType.Mlfeature;
181+
case 'mlprimarykey':
182+
return EntityType.MlprimaryKey;
183+
case 'container':
184+
return EntityType.Container;
185+
case 'domain':
186+
return EntityType.Domain;
187+
case 'notebook':
188+
return EntityType.Notebook;
189+
case 'dataplatforminstance':
190+
return EntityType.DataPlatformInstance;
191+
case 'test':
192+
return EntityType.Test;
193+
case 'schemafield':
194+
return EntityType.SchemaField;
195+
196+
// these are const in the java app
197+
case 'dataprocessinstance': // Constants.DATA_PROCESS_INSTANCE_ENTITY_NAME
198+
return EntityType.DataProcessInstance;
199+
case 'datahubview': // Constants.DATAHUB_VIEW_ENTITY_NAME
200+
return EntityType.DatahubView;
201+
case 'dataproduct': // Constants.DATA_PRODUCT_ENTITY_NAME
202+
return EntityType.DataProduct;
203+
case 'datahubconnection': // Constants.DATAHUB_CONNECTION_ENTITY_NAME
204+
return EntityType.DatahubConnection;
205+
case 'structuredproperty': // Constants.STRUCTURED_PROPERTY_ENTITY_NAME
206+
return EntityType.StructuredProperty;
207+
case 'assertion': // Constants.ASSERTION_ENTITY_NAME
208+
return EntityType.Assertion;
209+
210+
default:
211+
return '';
212+
}
213+
}
214+
215+
// Utility for getting entity type from urn if it's in the 3rd position
216+
export function extractTypeFromUrn(urn: string): EntityType {
217+
const regex = /[^:]+:[^:]+:([^:]+):/;
218+
const match = urn.match(regex);
219+
220+
if (match && match[1]) return formatEntityType(match[1]) as EntityType;
221+
222+
return '' as EntityType;
223+
}

datahub-web-react/src/app/entityV2/shared/components/styled/search/EntitySearchResults.tsx

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { Checkbox, Empty, List } from 'antd';
22
import React from 'react';
33
import styled from 'styled-components';
4-
import { EntityPath, EntityType, SearchResult } from '../../../../../../types.generated';
5-
import { EntityAndType } from '../../../../../entity/shared/types';
4+
import { Entity, EntityPath, EntityType, SearchResult } from '../../../../../../types.generated';
65
import { useSearchContext } from '../../../../../search/context/SearchContext';
76
import { MATCHES_CONTAINER_HEIGHT } from '../../../../../searchV2/SearchResultList';
87
import { MatchContextContainer } from '../../../../../searchV2/matches/MatchContextContainer';
@@ -76,8 +75,8 @@ type Props = {
7675
additionalPropertiesList?: Array<AdditionalProperties>;
7776
searchResults: Array<SearchResult>;
7877
isSelectMode?: boolean;
79-
selectedEntities?: EntityAndType[];
80-
setSelectedEntities?: (entities: EntityAndType[]) => any;
78+
selectedEntities?: Entity[];
79+
setSelectedEntities?: (entities: Entity[]) => any;
8180
bordered?: boolean;
8281
entityAction?: React.FC<EntityActionProps>;
8382
compactUserSearchCardStyle?: boolean;
@@ -120,7 +119,7 @@ export const EntitySearchResults = ({
120119
/**
121120
* Invoked when a new entity is selected. Simply updates the state of the list of selected entities.
122121
*/
123-
const onSelectEntity = (selectedEntity: EntityAndType, selected: boolean) => {
122+
const onSelectEntity = (selectedEntity: Entity, selected: boolean) => {
124123
if (selected) {
125124
setSelectedEntities?.([...selectedEntities, selectedEntity]);
126125
} else {
@@ -177,9 +176,7 @@ export const EntitySearchResults = ({
177176
selectedEntities.length >= selectLimit &&
178177
!selectedEntityUrns.includes(entity.urn)
179178
}
180-
onChange={(e) =>
181-
onSelectEntity({ urn: entity.urn, type: entity.type }, e.target.checked)
182-
}
179+
onChange={(e) => onSelectEntity(entity, e.target.checked)}
183180
/>
184181
)}
185182
{entityRegistry.renderSearchResult(entity.type, searchResult)}

datahub-web-react/src/app/entityV2/shared/components/styled/search/SearchSelect.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { FilterOutlined } from '@ant-design/icons';
22
import { Button, message, Typography } from 'antd';
33
import React, { useState } from 'react';
4-
import styled from 'styled-components';
54
import { useDebounce } from 'react-use';
5+
import styled from 'styled-components';
66

7-
import useSortInput from '@src/app/searchV2/sorting/useSortInput';
87
import SearchSortSelect from '@src/app/searchV2/sorting/SearchSortSelect';
8+
import useSortInput from '@src/app/searchV2/sorting/useSortInput';
99
import { SearchCfg } from '../../../../../../conf';
1010
import { useGetSearchResultsForMultipleQuery } from '../../../../../../graphql/search.generated';
11-
import { EntityType, FacetFilterInput, FilterOperator } from '../../../../../../types.generated';
11+
import { Entity, EntityType, FacetFilterInput, FilterOperator } from '../../../../../../types.generated';
1212
import { EntityAndType } from '../../../../../entity/shared/types';
1313
import { SearchBar } from '../../../../../search/SearchBar';
1414
import { ENTITY_FILTER_NAME, UnionType } from '../../../../../search/utils/constants';
@@ -47,7 +47,7 @@ type Props = {
4747
fixedEntityTypes?: Array<EntityType> | null;
4848
placeholderText?: string | null;
4949
selectedEntities: EntityAndType[];
50-
setSelectedEntities: (Entities: EntityAndType[]) => void;
50+
setSelectedEntities: (Entities: Entity[]) => void;
5151
limit?: number;
5252
};
5353

datahub-web-react/src/app/entityV2/shared/tabs/Lineage/LineageColumnView.tsx

+14-16
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
import { useIsSeparateSiblingsMode } from '@app/entity/shared/siblingUtils';
2-
import React, { useMemo, useState } from 'react';
3-
import { useLocation } from 'react-router';
4-
import styled from 'styled-components/macro';
5-
import * as QueryString from 'query-string';
61
import {
72
ArrowDownOutlined,
83
ArrowUpOutlined,
94
CaretDownFilled,
105
CaretDownOutlined,
6+
LoadingOutlined,
117
ReloadOutlined,
128
SubnodeOutlined,
13-
LoadingOutlined,
149
} from '@ant-design/icons';
15-
import { Button, Select, Typography } from 'antd';
10+
import { useIsSeparateSiblingsMode } from '@app/entity/shared/siblingUtils';
1611
import { Tooltip } from '@components';
1712
import { GenericEntityProperties } from '@src/app/entity/shared/types';
13+
import ManageLineageMenuForImpactAnalysis from '@src/app/entityV2/shared/tabs/Lineage/ManageLineageMenuFromImpactAnalysis';
14+
import { Direction } from '@src/app/lineage/types';
15+
import { Button, Select, Typography } from 'antd';
16+
import * as QueryString from 'query-string';
17+
import React, { useMemo, useState } from 'react';
18+
import { useLocation } from 'react-router';
19+
import styled from 'styled-components/macro';
1820
import { EntityType, LineageDirection } from '../../../../../types.generated';
19-
import ManageLineageMenu from '../../../../lineage/manage/ManageLineageMenu';
21+
import { useEntityData } from '../../../../entity/shared/EntityContext';
2022
import { useGetLineageTimeParams } from '../../../../lineage/utils/useGetLineageTimeParams';
2123
import { useEntityRegistry } from '../../../../useEntityRegistry';
2224
import { downgradeV2FieldPath } from '../../../dataset/profile/schema/utils/utils';
2325
import TabToolbar from '../../components/styled/TabToolbar';
2426
import { ANTD_GRAY } from '../../constants';
25-
import { useEntityData } from '../../../../entity/shared/EntityContext';
2627
import ColumnsLineageSelect from './ColumnLineageSelect';
2728
import { ImpactAnalysis } from './ImpactAnalysis';
2829
import { LineageTabContext } from './LineageTabContext';
@@ -73,9 +74,10 @@ interface SchemaFieldEntityData extends GenericEntityProperties {
7374

7475
interface Props {
7576
defaultDirection: LineageDirection;
77+
setVisualizeViewInEditMode: (view: boolean, direction: Direction) => void;
7678
}
7779

78-
export function LineageColumnView({ defaultDirection }: Props) {
80+
export function LineageColumnView({ defaultDirection, setVisualizeViewInEditMode }: Props) {
7981
const { urn, entityType, entityData } = useEntityData();
8082
const location = useLocation();
8183
const entityRegistry = useEntityRegistry();
@@ -153,10 +155,8 @@ export function LineageColumnView({ defaultDirection }: Props) {
153155
/>
154156
</LeftButtonsWrapper>
155157
<RightButtonsWrapper>
156-
<ManageLineageMenu
157-
entityUrn={urn}
158-
refetchEntity={() => setShouldRefetch(true)}
159-
setUpdatedLineages={() => {}}
158+
<ManageLineageMenuForImpactAnalysis
159+
setVisualizeViewInEditMode={setVisualizeViewInEditMode}
160160
menuIcon={
161161
<Button type="text">
162162
<ManageLineageIcon />
@@ -166,9 +166,7 @@ export function LineageColumnView({ defaultDirection }: Props) {
166166
<StyledCaretDown />
167167
</Button>
168168
}
169-
showLoading
170169
entityType={entityType}
171-
entityPlatform={entityData?.platform?.name}
172170
canEditLineage={canEditLineage}
173171
disableDropdown={!canEditLineage}
174172
/>

datahub-web-react/src/app/entityV2/shared/tabs/Lineage/LineageTab.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import LineageGraph from '@app/lineageV2/LineageGraph';
22
import React, { useContext } from 'react';
33
import styled from 'styled-components';
4-
import { useLineageV2 } from '../../../../lineageV2/useLineageV2';
54
import { LineageDirection } from '../../../../../types.generated';
65
import { useEntityData } from '../../../../entity/shared/EntityContext';
7-
import { TabRenderType } from '../../types';
8-
import { CompactLineageTab } from './CompactLineageTab';
96
import LineageExplorer from '../../../../lineage/LineageExplorer';
10-
import { LineageColumnView } from './LineageColumnView';
7+
import { useLineageV2 } from '../../../../lineageV2/useLineageV2';
118
import TabFullsizedContext from '../../../../shared/TabFullsizedContext';
9+
import { TabRenderType } from '../../types';
10+
import { CompactLineageTab } from './CompactLineageTab';
1211
import { useLineageViewState } from './hooks';
12+
import { LineageColumnView } from './LineageColumnView';
1313

1414
const LINEAGE_SWITCH_WIDTH = 90;
1515

@@ -68,7 +68,7 @@ function WideLineageTab({ defaultDirection }: { defaultDirection: LineageDirecti
6868
const { isTabFullsize } = useContext(TabFullsizedContext);
6969
const { urn, entityType } = useEntityData();
7070
const isLineageV2 = useLineageV2();
71-
const { isVisualizeView, setVisualizeView } = useLineageViewState();
71+
const { isVisualizeView, setVisualizeView, setVisualizeViewInEditMode } = useLineageViewState();
7272

7373
return (
7474
<LineageTabWrapper>
@@ -84,7 +84,12 @@ function WideLineageTab({ defaultDirection }: { defaultDirection: LineageDirecti
8484
</LineageSwitchWrapper>
8585
</LineageTabHeader>
8686
)}
87-
{!isVisualizeView && <LineageColumnView defaultDirection={defaultDirection} />}
87+
{!isVisualizeView && (
88+
<LineageColumnView
89+
defaultDirection={defaultDirection}
90+
setVisualizeViewInEditMode={setVisualizeViewInEditMode}
91+
/>
92+
)}
8893
{isVisualizeView && !isLineageV2 && <LineageExplorer urn={urn} type={entityType} />}
8994
{isVisualizeView && isLineageV2 && (
9095
<VisualizationWrapper>

0 commit comments

Comments
 (0)