import { DashboardFilled, DashboardOutlined } from '@ant-design/icons'; import * as React from 'react'; import { GetDashboardQuery, useGetDashboardQuery, useUpdateDashboardMutation, } from '../../../graphql/dashboard.generated'; import { Dashboard, EntityType, OwnershipType, SearchResult } from '../../../types.generated'; 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 { DashboardDatasetsTab } from '../shared/tabs/Entity/DashboardDatasetsTab'; import { PropertiesTab } from '../shared/tabs/Properties/PropertiesTab'; import { GenericEntityProperties } from '../shared/types'; import { DashboardPreview } from './preview/DashboardPreview'; import { getDataForEntityType } from '../shared/containers/profile/utils'; import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection'; import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown'; import { LineageTab } from '../shared/tabs/Lineage/LineageTab'; /** * 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) => ( true, enabled: (_, dashboard: GetDashboardQuery) => { return ( (dashboard?.dashboard?.upstream?.total || 0) > 0 || (dashboard?.dashboard?.downstream?.total || 0) > 0 ); }, }, }, { name: 'Charts', component: DashboardChartsTab, display: { visible: (_, dashboard: GetDashboardQuery) => (dashboard?.dashboard?.charts?.total || 0) > 0 || (dashboard?.dashboard?.datasets?.total || 0) === 0, enabled: (_, dashboard: GetDashboardQuery) => (dashboard?.dashboard?.charts?.total || 0) > 0, }, }, { name: 'Datasets', component: DashboardDatasetsTab, display: { visible: (_, dashboard: GetDashboardQuery) => (dashboard?.dashboard?.datasets?.total || 0) > 0, enabled: (_, dashboard: GetDashboardQuery) => (dashboard?.dashboard?.datasets?.total || 0) > 0, }, }, ]} sidebarSections={[ { component: SidebarAboutSection, }, { component: SidebarTagsSection, properties: { hasTags: true, hasTerms: true, }, }, { component: SidebarOwnerSection, properties: { defaultOwnerType: OwnershipType.TechnicalOwner, }, }, { component: SidebarDomainSection, }, ]} /> ); getOverridePropertiesFromEntity = (dashboard?: Dashboard | null): GenericEntityProperties => { // TODO: Get rid of this once we have correctly formed platform coming back. const name = dashboard?.properties?.name; const externalUrl = dashboard?.properties?.externalUrl; return { name, externalUrl, }; }; renderPreview = (_: PreviewType, data: Dashboard) => { return ( ); }; renderSearch = (result: SearchResult) => { const data = result.entity as Dashboard; return ( ); }; getLineageVizConfig = (entity: Dashboard) => { return { urn: entity.urn, name: entity.properties?.name || '', type: EntityType.Dashboard, icon: entity?.platform?.properties?.logoUrl || '', platform: entity?.platform.properties?.displayName || entity?.platform.name, }; }; displayName = (data: Dashboard) => { return data.properties?.name || data.urn; }; getGenericEntityProperties = (data: Dashboard) => { return getDataForEntityType({ data, entityType: this.type, getOverrideProperties: this.getOverridePropertiesFromEntity, }); }; }