import * as React from 'react'; import { ConsoleSqlOutlined } from '@ant-design/icons'; import { DataJob, EntityType, OwnershipType, PlatformType, SearchResult } from '../../../types.generated'; import { Preview } from './preview/Preview'; import { Entity, IconStyleType, PreviewType } from '../Entity'; import { EntityProfile } from '../shared/containers/profile/EntityProfile'; import { GetDataJobQuery, useGetDataJobQuery, useUpdateDataJobMutation } from '../../../graphql/dataJob.generated'; import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab'; import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab'; import { LineageTab } from '../shared/tabs/Lineage/LineageTab'; import { SidebarAboutSection } from '../shared/containers/profile/sidebar/SidebarAboutSection'; import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection'; import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Ownership/SidebarOwnerSection'; import { GenericEntityProperties } from '../shared/types'; import { DataJobFlowTab } from '../shared/tabs/Entity/DataJobFlowTab'; import { getDataForEntityType } from '../shared/containers/profile/utils'; import { capitalizeFirstLetter } from '../../shared/textUtil'; import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection'; /** * Definition of the DataHub DataJob entity. */ export class DataJobEntity implements Entity { type: EntityType = EntityType.DataJob; icon = (fontSize: number, styleType: IconStyleType) => { if (styleType === IconStyleType.TAB_VIEW) { return ; } if (styleType === IconStyleType.HIGHLIGHT) { return ; } return ( ); }; isSearchEnabled = () => true; isBrowseEnabled = () => false; isLineageEnabled = () => true; getAutoCompleteFieldName = () => 'name'; getPathName = () => 'tasks'; getEntityName = () => 'Task'; getCollectionName = () => 'Tasks'; renderProfile = (urn: string) => ( true, enabled: (_, dataJob: GetDataJobQuery) => (dataJob?.dataJob?.incoming?.count || 0) !== 0 || (dataJob?.dataJob?.outgoing?.count || 0) !== 0, }, }, ]} sidebarSections={[ { component: SidebarAboutSection, }, { component: SidebarTagsSection, properties: { hasTags: true, hasTerms: true, }, }, { component: SidebarOwnerSection, properties: { defaultOwnerType: OwnershipType.TechnicalOwner, }, }, { component: SidebarDomainSection, }, ]} /> ); getOverridePropertiesFromEntity = (dataJob?: DataJob | null): GenericEntityProperties => { // TODO: Get rid of this once we have correctly formed platform coming back. const tool = dataJob?.dataFlow?.orchestrator || ''; const name = dataJob?.properties?.name; const externalUrl = dataJob?.properties?.externalUrl; return { name, externalUrl, platform: { urn: `urn:li:dataPlatform:(${tool})`, type: EntityType.DataPlatform, name: tool, properties: { logoUrl: dataJob?.dataFlow?.platform?.properties?.logoUrl || '', displayName: capitalizeFirstLetter(tool), type: PlatformType.Others, datasetNameDelimiter: '.', }, }, }; }; renderPreview = (_: PreviewType, data: DataJob) => { const platformName = data.dataFlow ? data.dataFlow?.orchestrator.charAt(0).toUpperCase() + data.dataFlow?.orchestrator.slice(1) : ''; return ( ); }; renderSearch = (result: SearchResult) => { const data = result.entity as DataJob; const platformName = data.dataFlow ? data.dataFlow?.orchestrator.charAt(0).toUpperCase() + data.dataFlow?.orchestrator.slice(1) : ''; return ( ); }; getLineageVizConfig = (entity: DataJob) => { return { urn: entity?.urn, name: entity?.properties?.name || '', type: EntityType.DataJob, icon: entity?.dataFlow?.platform?.properties?.logoUrl || '', platform: entity?.dataFlow?.orchestrator || '', }; }; displayName = (data: DataJob) => { return data.properties?.name || data.urn; }; getGenericEntityProperties = (data: DataJob) => { return getDataForEntityType({ data, entityType: this.type, getOverrideProperties: this.getOverridePropertiesFromEntity, }); }; }