2021-02-23 12:45:42 -08:00
|
|
|
import { DashboardFilled, DashboardOutlined } from '@ant-design/icons';
|
2021-02-18 12:33:17 -08:00
|
|
|
import * as React from 'react';
|
2021-09-28 10:30:37 -07:00
|
|
|
import {
|
|
|
|
|
GetDashboardQuery,
|
|
|
|
|
useGetDashboardQuery,
|
|
|
|
|
useUpdateDashboardMutation,
|
|
|
|
|
} from '../../../graphql/dashboard.generated';
|
2022-07-01 14:35:21 -04:00
|
|
|
import { Dashboard, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
|
2021-02-23 12:45:42 -08:00
|
|
|
import { Entity, IconStyleType, PreviewType } from '../Entity';
|
2021-09-28 10:30:37 -07:00
|
|
|
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';
|
2021-02-18 12:33:17 -08:00
|
|
|
import { DashboardPreview } from './preview/DashboardPreview';
|
2021-10-26 21:23:08 -07:00
|
|
|
import { getDataForEntityType } from '../shared/containers/profile/utils';
|
2022-01-27 22:02:41 -08:00
|
|
|
import { SidebarDomainSection } from '../shared/containers/profile/sidebar/Domain/SidebarDomainSection';
|
2022-05-30 00:26:07 -04:00
|
|
|
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';
|
2021-02-18 12:33:17 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Definition of the DataHub Dashboard entity.
|
|
|
|
|
*/
|
|
|
|
|
export class DashboardEntity implements Entity<Dashboard> {
|
|
|
|
|
type: EntityType = EntityType.Dashboard;
|
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
icon = (fontSize: number, styleType: IconStyleType) => {
|
|
|
|
|
if (styleType === IconStyleType.TAB_VIEW) {
|
|
|
|
|
return <DashboardOutlined style={{ fontSize }} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (styleType === IconStyleType.HIGHLIGHT) {
|
|
|
|
|
return <DashboardFilled style={{ fontSize, color: 'rgb(144 163 236)' }} />;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-17 00:46:02 +08:00
|
|
|
if (styleType === IconStyleType.SVG) {
|
|
|
|
|
return (
|
|
|
|
|
<path d="M924.8 385.6a446.7 446.7 0 00-96-142.4 446.7 446.7 0 00-142.4-96C631.1 123.8 572.5 112 512 112s-119.1 11.8-174.4 35.2a446.7 446.7 0 00-142.4 96 446.7 446.7 0 00-96 142.4C75.8 440.9 64 499.5 64 560c0 132.7 58.3 257.7 159.9 343.1l1.7 1.4c5.8 4.8 13.1 7.5 20.6 7.5h531.7c7.5 0 14.8-2.7 20.6-7.5l1.7-1.4C901.7 817.7 960 692.7 960 560c0-60.5-11.9-119.1-35.2-174.4zM761.4 836H262.6A371.12 371.12 0 01140 560c0-99.4 38.7-192.8 109-263 70.3-70.3 163.7-109 263-109 99.4 0 192.8 38.7 263 109 70.3 70.3 109 163.7 109 263 0 105.6-44.5 205.5-122.6 276zM623.5 421.5a8.03 8.03 0 00-11.3 0L527.7 506c-18.7-5-39.4-.2-54.1 14.5a55.95 55.95 0 000 79.2 55.95 55.95 0 0079.2 0 55.87 55.87 0 0014.5-54.1l84.5-84.5c3.1-3.1 3.1-8.2 0-11.3l-28.3-28.3zM490 320h44c4.4 0 8-3.6 8-8v-80c0-4.4-3.6-8-8-8h-44c-4.4 0-8 3.6-8 8v80c0 4.4 3.6 8 8 8zm260 218v44c0 4.4 3.6 8 8 8h80c4.4 0 8-3.6 8-8v-44c0-4.4-3.6-8-8-8h-80c-4.4 0-8 3.6-8 8zm12.7-197.2l-31.1-31.1a8.03 8.03 0 00-11.3 0l-56.6 56.6a8.03 8.03 0 000 11.3l31.1 31.1c3.1 3.1 8.2 3.1 11.3 0l56.6-56.6c3.1-3.1 3.1-8.2 0-11.3zm-458.6-31.1a8.03 8.03 0 00-11.3 0l-31.1 31.1a8.03 8.03 0 000 11.3l56.6 56.6c3.1 3.1 8.2 3.1 11.3 0l31.1-31.1c3.1-3.1 3.1-8.2 0-11.3l-56.6-56.6zM262 530h-80c-4.4 0-8 3.6-8 8v44c0 4.4 3.6 8 8 8h80c4.4 0 8-3.6 8-8v-44c0-4.4-3.6-8-8-8z" />
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-23 12:45:42 -08:00
|
|
|
return (
|
|
|
|
|
<DashboardOutlined
|
|
|
|
|
style={{
|
|
|
|
|
fontSize,
|
|
|
|
|
color: '#BFBFBF',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-18 12:33:17 -08:00
|
|
|
isSearchEnabled = () => true;
|
|
|
|
|
|
2021-03-04 23:24:49 -08:00
|
|
|
isBrowseEnabled = () => true;
|
2021-02-18 12:33:17 -08:00
|
|
|
|
2021-04-09 11:55:25 -07:00
|
|
|
isLineageEnabled = () => true;
|
|
|
|
|
|
2021-02-18 12:33:17 -08:00
|
|
|
getAutoCompleteFieldName = () => 'title';
|
|
|
|
|
|
|
|
|
|
getPathName = () => 'dashboard';
|
|
|
|
|
|
2021-09-28 10:30:37 -07:00
|
|
|
getEntityName = () => 'Dashboard';
|
|
|
|
|
|
2021-02-18 12:33:17 -08:00
|
|
|
getCollectionName = () => 'Dashboards';
|
|
|
|
|
|
2021-09-28 10:30:37 -07:00
|
|
|
renderProfile = (urn: string) => (
|
|
|
|
|
<EntityProfile
|
|
|
|
|
urn={urn}
|
|
|
|
|
entityType={EntityType.Dashboard}
|
|
|
|
|
useEntityQuery={useGetDashboardQuery}
|
|
|
|
|
useUpdateQuery={useUpdateDashboardMutation}
|
2021-10-26 21:23:08 -07:00
|
|
|
getOverrideProperties={this.getOverridePropertiesFromEntity}
|
2022-05-30 00:26:07 -04:00
|
|
|
headerDropdownItems={new Set([EntityMenuItems.COPY_URL, EntityMenuItems.UPDATE_DEPRECATION])}
|
2021-09-28 10:30:37 -07:00
|
|
|
tabs={[
|
|
|
|
|
{
|
|
|
|
|
name: 'Documentation',
|
|
|
|
|
component: DocumentationTab,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Properties',
|
|
|
|
|
component: PropertiesTab,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Charts',
|
|
|
|
|
component: DashboardChartsTab,
|
2021-10-12 15:47:29 -07:00
|
|
|
display: {
|
|
|
|
|
visible: (_, _1) => true,
|
|
|
|
|
enabled: (_, dashboard: GetDashboardQuery) => (dashboard?.dashboard?.charts?.total || 0) > 0,
|
|
|
|
|
},
|
2021-09-28 10:30:37 -07:00
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
sidebarSections={[
|
|
|
|
|
{
|
|
|
|
|
component: SidebarAboutSection,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: SidebarTagsSection,
|
|
|
|
|
properties: {
|
|
|
|
|
hasTags: true,
|
|
|
|
|
hasTerms: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
component: SidebarOwnerSection,
|
2022-03-14 11:14:32 -07:00
|
|
|
properties: {
|
|
|
|
|
defaultOwnerType: OwnershipType.TechnicalOwner,
|
|
|
|
|
},
|
2021-09-28 10:30:37 -07:00
|
|
|
},
|
2022-01-27 22:02:41 -08:00
|
|
|
{
|
|
|
|
|
component: SidebarDomainSection,
|
|
|
|
|
},
|
2021-09-28 10:30:37 -07:00
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
|
2021-10-26 21:23:08 -07:00
|
|
|
getOverridePropertiesFromEntity = (dashboard?: Dashboard | null): GenericEntityProperties => {
|
2021-09-28 10:30:37 -07:00
|
|
|
// TODO: Get rid of this once we have correctly formed platform coming back.
|
2021-11-08 16:24:50 -08:00
|
|
|
const name = dashboard?.properties?.name;
|
|
|
|
|
const externalUrl = dashboard?.properties?.externalUrl;
|
2021-09-28 10:30:37 -07:00
|
|
|
return {
|
|
|
|
|
name,
|
|
|
|
|
externalUrl,
|
|
|
|
|
};
|
|
|
|
|
};
|
2021-02-18 12:33:17 -08:00
|
|
|
|
|
|
|
|
renderPreview = (_: PreviewType, data: Dashboard) => {
|
|
|
|
|
return (
|
|
|
|
|
<DashboardPreview
|
|
|
|
|
urn={data.urn}
|
2022-07-01 14:35:21 -04:00
|
|
|
platform={data.platform.properties?.displayName || data.platform.name}
|
2021-11-08 16:24:50 -08:00
|
|
|
name={data.properties?.name}
|
|
|
|
|
description={data.editableProperties?.description || data.properties?.description}
|
|
|
|
|
access={data.properties?.access}
|
2021-03-07 11:26:47 -08:00
|
|
|
tags={data.globalTags || undefined}
|
2021-02-23 12:45:42 -08:00
|
|
|
owners={data.ownership?.owners}
|
2021-09-28 10:30:37 -07:00
|
|
|
glossaryTerms={data?.glossaryTerms}
|
2022-01-25 21:03:31 -06:00
|
|
|
logoUrl={data?.platform?.properties?.logoUrl}
|
2022-01-27 22:02:41 -08:00
|
|
|
domain={data.domain}
|
2022-02-02 13:51:39 -08:00
|
|
|
container={data.container}
|
2021-02-18 12:33:17 -08:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
2021-03-23 15:18:32 -07:00
|
|
|
|
|
|
|
|
renderSearch = (result: SearchResult) => {
|
2021-10-14 10:11:56 -07:00
|
|
|
const data = result.entity as Dashboard;
|
|
|
|
|
return (
|
|
|
|
|
<DashboardPreview
|
|
|
|
|
urn={data.urn}
|
2022-07-01 14:35:21 -04:00
|
|
|
platform={data.platform.properties?.displayName || data.platform.name}
|
2021-11-08 16:24:50 -08:00
|
|
|
name={data.properties?.name}
|
2022-05-09 17:28:50 -04:00
|
|
|
platformInstanceId={data.dataPlatformInstance?.instanceId}
|
2021-11-08 16:24:50 -08:00
|
|
|
description={data.editableProperties?.description || data.properties?.description}
|
|
|
|
|
access={data.properties?.access}
|
2021-10-14 10:11:56 -07:00
|
|
|
tags={data.globalTags || undefined}
|
|
|
|
|
owners={data.ownership?.owners}
|
|
|
|
|
glossaryTerms={data?.glossaryTerms}
|
|
|
|
|
insights={result.insights}
|
2022-01-25 21:03:31 -06:00
|
|
|
logoUrl={data?.platform?.properties?.logoUrl || ''}
|
2022-01-27 22:02:41 -08:00
|
|
|
domain={data.domain}
|
2022-02-02 13:51:39 -08:00
|
|
|
container={data.container}
|
2022-05-13 00:17:19 -04:00
|
|
|
parentContainers={data.parentContainers}
|
2021-10-14 10:11:56 -07:00
|
|
|
/>
|
|
|
|
|
);
|
2021-03-23 15:18:32 -07:00
|
|
|
};
|
2021-04-09 11:55:25 -07:00
|
|
|
|
|
|
|
|
getLineageVizConfig = (entity: Dashboard) => {
|
|
|
|
|
return {
|
|
|
|
|
urn: entity.urn,
|
2021-11-08 16:24:50 -08:00
|
|
|
name: entity.properties?.name || '',
|
2021-04-09 11:55:25 -07:00
|
|
|
type: EntityType.Dashboard,
|
2022-01-25 21:03:31 -06:00
|
|
|
icon: entity?.platform?.properties?.logoUrl || '',
|
2022-07-01 14:35:21 -04:00
|
|
|
platform: entity?.platform.properties?.displayName || entity?.platform.name,
|
2021-04-09 11:55:25 -07:00
|
|
|
};
|
|
|
|
|
};
|
2021-09-02 19:05:13 -07:00
|
|
|
|
|
|
|
|
displayName = (data: Dashboard) => {
|
2021-11-08 16:24:50 -08:00
|
|
|
return data.properties?.name || data.urn;
|
2021-09-02 19:05:13 -07:00
|
|
|
};
|
2021-10-26 21:23:08 -07:00
|
|
|
|
|
|
|
|
getGenericEntityProperties = (data: Dashboard) => {
|
|
|
|
|
return getDataForEntityType({
|
|
|
|
|
data,
|
|
|
|
|
entityType: this.type,
|
|
|
|
|
getOverrideProperties: this.getOverridePropertiesFromEntity,
|
|
|
|
|
});
|
|
|
|
|
};
|
2021-02-18 12:33:17 -08:00
|
|
|
}
|