UI: Fix the icon on lineage Node (#10528)

* Fix the icon on lineage Node

* added pipeline icon

---------

Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
This commit is contained in:
Ashish Gupta 2023-03-11 23:32:37 +05:30 committed by GitHub
parent 203d41c88e
commit 385a2e87d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 11 deletions

View File

@ -11,14 +11,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { Modal } from 'antd'; import { Modal, Space } from 'antd';
import { AxiosError } from 'axios'; import { AxiosError } from 'axios';
import { import {
debounce, debounce,
isEmpty, isEmpty,
isNil, isNil,
isUndefined, isUndefined,
lowerCase,
uniqueId, uniqueId,
upperCase, upperCase,
} from 'lodash'; } from 'lodash';
@ -83,6 +82,7 @@ import {
getDeletedLineagePlaceholder, getDeletedLineagePlaceholder,
getEdgeStyle, getEdgeStyle,
getEdgeType, getEdgeType,
getEntityNodeIcon,
getLayoutedElements, getLayoutedElements,
getLineageData, getLineageData,
getLoadingStatusValue, getLoadingStatusValue,
@ -105,7 +105,6 @@ import {
onNodeMouseMove, onNodeMouseMove,
} from '../../utils/EntityLineageUtils'; } from '../../utils/EntityLineageUtils';
import { getEntityReferenceFromPipeline } from '../../utils/PipelineServiceUtils'; import { getEntityReferenceFromPipeline } from '../../utils/PipelineServiceUtils';
import SVGIcons from '../../utils/SvgUtils';
import { showErrorToast } from '../../utils/ToastUtils'; import { showErrorToast } from '../../utils/ToastUtils';
import EdgeInfoDrawer from '../EntityInfoDrawer/EdgeInfoDrawer.component'; import EdgeInfoDrawer from '../EntityInfoDrawer/EdgeInfoDrawer.component';
import EntityInfoDrawer from '../EntityInfoDrawer/EntityInfoDrawer.component'; import EntityInfoDrawer from '../EntityInfoDrawer/EntityInfoDrawer.component';
@ -1058,6 +1057,7 @@ const EntityLineageComponent: FunctionComponent<EntityLineageProp> = ({
y: event.clientY - (reactFlowBounds?.top ?? 0), y: event.clientY - (reactFlowBounds?.top ?? 0),
}); });
const [label, nodeType] = type.split('-'); const [label, nodeType] = type.split('-');
const Icon = getEntityNodeIcon(label);
const newNode = { const newNode = {
id: uniqueId(), id: uniqueId(),
nodeType, nodeType,
@ -1072,18 +1072,18 @@ const EntityLineageComponent: FunctionComponent<EntityLineageProp> = ({
{getNodeRemoveButton(() => { {getNodeRemoveButton(() => {
removeNodeHandler(newNode as Node); removeNodeHandler(newNode as Node);
})} })}
<div className="tw-flex"> <Space align="center" size={2}>
<SVGIcons <Icon
alt="entity-icon" className="m-r-xs"
className="tw-mr-2" height={16}
icon={`${lowerCase(label)}-grey`} name="entity-icon"
width="16px" width={16}
/> />
<NodeSuggestions <NodeSuggestions
entityType={upperCase(label)} entityType={upperCase(label)}
onSelectHandler={setSelectedEntity} onSelectHandler={setSelectedEntity}
/> />
</div> </Space>
</div> </div>
), ),
removeNodeHandler, removeNodeHandler,

View File

@ -30,7 +30,7 @@ import LineageNodeLabel from 'components/EntityLineage/LineageNodeLabel';
import Loader from 'components/Loader/Loader'; import Loader from 'components/Loader/Loader';
import dagre from 'dagre'; import dagre from 'dagre';
import { t } from 'i18next'; import { t } from 'i18next';
import { isEmpty, isNil, isUndefined } from 'lodash'; import { isEmpty, isNil, isUndefined, lowerCase } from 'lodash';
import { LoadingState } from 'Models'; import { LoadingState } from 'Models';
import React, { Fragment, MouseEvent as ReactMouseEvent } from 'react'; import React, { Fragment, MouseEvent as ReactMouseEvent } from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
@ -77,6 +77,13 @@ import { getEncodedFqn } from './StringsUtils';
import SVGIcons from './SvgUtils'; import SVGIcons from './SvgUtils';
import { getEntityLink } from './TableUtils'; import { getEntityLink } from './TableUtils';
import { ReactComponent as DashboardIcon } from '../assets/svg/dashboard-grey.svg';
import { ReactComponent as MlModelIcon } from '../assets/svg/mlmodal.svg';
import { ReactComponent as PipelineIcon } from '../assets/svg/pipeline-grey.svg';
import { ReactComponent as TableIcon } from '../assets/svg/table-grey.svg';
import { ReactComponent as TopicIcon } from '../assets/svg/topic-grey.svg';
export const getHeaderLabel = ( export const getHeaderLabel = (
name = '', name = '',
fqn = '', fqn = '',
@ -1125,3 +1132,21 @@ export const getEdgeStyle = (value: boolean) => {
stroke: value ? SECONDARY_COLOR : undefined, stroke: value ? SECONDARY_COLOR : undefined,
}; };
}; };
// Nodes Icons
export const getEntityNodeIcon = (label: string) => {
switch (lowerCase(label)) {
case EntityType.TABLE:
return TableIcon;
case EntityType.DASHBOARD:
return DashboardIcon;
case EntityType.TOPIC:
return TopicIcon;
case EntityType.PIPELINE:
return PipelineIcon;
case EntityType.MLMODEL:
return MlModelIcon;
default:
return TableIcon;
}
};