import { DashboardFilled, DashboardOutlined } from '@ant-design/icons'; import * as React from 'react'; import { GetDashboardQuery, useGetDashboardQuery, useUpdateDashboardMutation, } from '../../../graphql/dashboard.generated'; import { Dashboard, EntityType, LineageDirection, OwnershipType, SearchResult } from '../../../types.generated'; import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity'; import { EntityProfile } from '../shared/containers/profile/EntityProfile'; import { SidebarOwnerSection } from '../shared/containers/profile/sidebar/Ownership/sidebar/SidebarOwnerSection'; import { SidebarAboutSection } from '../shared/containers/profile/sidebar/AboutSection/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'; import { capitalizeFirstLetterOnly } from '../../shared/textUtil'; import { DashboardStatsSummarySubHeader } from './profile/DashboardStatsSummarySubHeader'; import { EmbedTab } from '../shared/tabs/Embed/EmbedTab'; import EmbeddedProfile from '../shared/embed/EmbeddedProfile'; import DataProductSection from '../shared/containers/profile/sidebar/DataProduct/DataProductSection'; import { getDataProduct } from '../shared/utils'; import { LOOKER_URN } from '../../ingest/source/builder/constants'; import { MatchedFieldList } from '../../search/matches/MatchedFieldList'; import { matchedInputFieldRenderer } from '../../search/matches/matchedInputFieldRenderer'; /** * Definition of the DataHub Dashboard entity. */ export class DashboardEntity implements Entity { type: EntityType = EntityType.Dashboard; icon = (fontSize: number, styleType: IconStyleType, color?: string) => { 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'; useEntityQuery = useGetDashboardQuery; getSidebarSections = () => [ { component: SidebarAboutSection, }, { component: SidebarOwnerSection, properties: { defaultOwnerType: OwnershipType.TechnicalOwner, }, }, { component: SidebarTagsSection, properties: { hasTags: true, hasTerms: true, }, }, { component: SidebarDomainSection, }, { component: DataProductSection, }, ]; renderProfile = (urn: string) => ( (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, }, }, { name: 'Documentation', component: DocumentationTab, }, { name: 'Preview', component: EmbedTab, display: { visible: (_, dashboard: GetDashboardQuery) => !!dashboard?.dashboard?.embed?.renderUrl && dashboard?.dashboard?.platform.urn === LOOKER_URN, enabled: (_, dashboard: GetDashboardQuery) => !!dashboard?.dashboard?.embed?.renderUrl && dashboard?.dashboard?.platform.urn === LOOKER_URN, }, }, { name: 'Lineage', component: LineageTab, properties: { defaultDirection: LineageDirection.Upstream, }, }, { name: 'Properties', component: PropertiesTab, }, ]} sidebarSections={this.getSidebarSections()} /> ); 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; const subTypes = dashboard?.subTypes; return { name, externalUrl, entityTypeOverride: subTypes ? capitalizeFirstLetterOnly(subTypes.typeNames?.[0]) : '', }; }; renderPreview = (_: PreviewType, data: Dashboard) => { const genericProperties = this.getGenericEntityProperties(data); return ( ); }; renderSearch = (result: SearchResult) => { const data = result.entity as Dashboard; const genericProperties = this.getGenericEntityProperties(data); return ( matchedInputFieldRenderer(matchedField, data)} matchSuffix="on a contained chart" /> } subtype={data.subTypes?.typeNames?.[0]} degree={(result as any).degree} paths={(result as any).paths} /> ); }; getLineageVizConfig = (entity: Dashboard) => { return { urn: entity.urn, name: entity.properties?.name || entity.urn, type: EntityType.Dashboard, subtype: entity?.subTypes?.typeNames?.[0] || undefined, icon: entity?.platform?.properties?.logoUrl || undefined, platform: entity?.platform, }; }; displayName = (data: Dashboard) => { return data.properties?.name || data.urn; }; getGenericEntityProperties = (data: Dashboard) => { return getDataForEntityType({ data, entityType: this.type, getOverrideProperties: this.getOverridePropertiesFromEntity, }); }; supportedCapabilities = () => { return new Set([ EntityCapabilityType.OWNERS, EntityCapabilityType.GLOSSARY_TERMS, EntityCapabilityType.TAGS, EntityCapabilityType.DOMAINS, EntityCapabilityType.DEPRECATION, EntityCapabilityType.SOFT_DELETE, EntityCapabilityType.DATA_PRODUCTS, ]); }; renderEmbeddedProfile = (urn: string) => ( ); }