import { DashboardFilled, DashboardOutlined } from '@ant-design/icons'; import * as React from 'react'; import { GetDashboardQuery, useGetDashboardQuery, useUpdateDashboardMutation, } from '../../../graphql/dashboard.generated'; import { Dashboard, EntityType, PlatformType, SearchResult } from '../../../types.generated'; import { Direction } from '../../lineage/types'; import { getLogoFromPlatform } from '../../shared/getLogoFromPlatform'; import { Entity, IconStyleType, PreviewType } from '../Entity'; import { EntityProfile } from '../shared/containers/profile/EntityProfile'; import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Ownership/SidebarOwnerSection'; import { SidebarAboutSection } from '../shared/containers/profile/sidebar/SidebarAboutSection'; import { SidebarTagsSection } from '../shared/containers/profile/sidebar/SidebarTagsSection'; import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab'; import { DashboardChartsTab } from '../shared/tabs/Entity/DashboardChartsTab'; import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab'; import { GenericEntityProperties } from '../shared/types'; import { DashboardPreview } from './preview/DashboardPreview'; export default function getChildren(entity: Dashboard, direction: Direction | null): Array { if (direction === Direction.Upstream) { return entity.info?.charts.map((chart) => chart.urn) || []; } if (direction === Direction.Downstream) { return []; } return []; } /** * Definition of the DataHub Dashboard entity. */ export class DashboardEntity implements Entity { type: EntityType = EntityType.Dashboard; icon = (fontSize: number, styleType: IconStyleType) => { if (styleType === IconStyleType.TAB_VIEW) { return ; } if (styleType === IconStyleType.HIGHLIGHT) { return ; } if (styleType === IconStyleType.SVG) { return ( ); } return ( ); }; isSearchEnabled = () => true; isBrowseEnabled = () => true; isLineageEnabled = () => true; getAutoCompleteFieldName = () => 'title'; getPathName = () => 'dashboard'; getEntityName = () => 'Dashboard'; getCollectionName = () => 'Dashboards'; renderProfile = (urn: string) => ( dashboard?.dashboard?.charts?.total === 0, }, ]} sidebarSections={[ { component: SidebarAboutSection, }, { component: SidebarTagsSection, properties: { hasTags: true, hasTerms: true, }, }, { component: SidebarOwnerSection, }, ]} /> ); getOverrideProperties = (res: GetDashboardQuery): GenericEntityProperties => { // TODO: Get rid of this once we have correctly formed platform coming back. const tool = res.dashboard?.tool || ''; const name = res.dashboard?.info?.name; const externalUrl = res.dashboard?.info?.externalUrl; return { ...res, name, externalUrl, platform: { urn: `urn:li:dataPlatform:(${tool})`, type: EntityType.DataPlatform, name: tool, info: { logoUrl: getLogoFromPlatform(tool), type: PlatformType.Others, datasetNameDelimiter: '.', }, }, }; }; renderPreview = (_: PreviewType, data: Dashboard) => { return ( ); }; renderSearch = (result: SearchResult) => { return this.renderPreview(PreviewType.SEARCH, result.entity as Dashboard); }; getLineageVizConfig = (entity: Dashboard) => { return { urn: entity.urn, name: entity.info?.name || '', type: EntityType.Dashboard, upstreamChildren: getChildren(entity, Direction.Upstream), downstreamChildren: getChildren(entity, Direction.Downstream), icon: getLogoFromPlatform(entity.tool), platform: entity.tool, }; }; displayName = (data: Dashboard) => { return data.info?.name || data.urn; }; }