Skip to content

Commit

Permalink
feat(dashboards): add datasets field to DashboardInfo aspect
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchen09 committed Jun 16, 2022
1 parent f4674c3 commit 216129e
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 1 deletion.
13 changes: 12 additions & 1 deletion datahub-web-react/src/app/entity/dashboard/DashboardEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { SidebarAboutSection } from '../shared/containers/profile/sidebar/Sideba
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';
Expand Down Expand Up @@ -87,10 +88,20 @@ export class DashboardEntity implements Entity<Dashboard> {
name: 'Charts',
component: DashboardChartsTab,
display: {
visible: (_, _1) => true,
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={[
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { useBaseEntity } from '../../EntityContext';
import { EntityType } from '../../../../../types.generated';
import { EntityList } from './components/EntityList';
import { useEntityRegistry } from '../../../../useEntityRegistry';

export const DashboardDatasetsTab = () => {
const entity = useBaseEntity() as any;
const dashboard = entity && entity.dashboard;
const datasets = dashboard?.datasets?.relationships.map((relationship) => relationship.entity);
const entityRegistry = useEntityRegistry();
const totalDatasets = dashboard?.datasets?.total || 0;
const title = `Consumes ${totalDatasets} ${
totalDatasets === 1
? entityRegistry.getEntityName(EntityType.Dataset)
: entityRegistry.getCollectionName(EntityType.Dataset)
}`;
return <EntityList title={title} type={EntityType.Dataset} entities={datasets || []} />;
};
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/dashboard.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ query getDashboard($urn: String!) {
charts: relationships(input: { types: ["Contains"], direction: OUTGOING, start: 0, count: 100 }) {
...fullRelationshipResults
}
datasets: relationships(input: { types: ["Consumes"], direction: OUTGOING, start: 0, count: 100 }) {
...fullRelationshipResults
}
upstream: lineage(input: { direction: UPSTREAM, start: 0, count: 100 }) {
...fullLineageResults
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace com.linkedin.dashboard
import com.linkedin.common.AccessLevel
import com.linkedin.common.ChangeAuditStamps
import com.linkedin.common.ChartUrn
import com.linkedin.common.DatasetUrn
import com.linkedin.common.Time
import com.linkedin.common.Url
import com.linkedin.common.CustomProperties
Expand Down Expand Up @@ -47,6 +48,18 @@ record DashboardInfo includes CustomProperties, ExternalReference {
}
charts: array[ChartUrn] = [ ]

/**
* Datasets consumed by a dashboard
*/
@Relationship = {
"/*": {
"name": "Consumes",
"entityTypes": [ "dataset" ],
"isLineage": true
}
}
datasets: array[DatasetUrn] = [ ]

/**
* Captures information about who created/last modified/deleted this dashboard and when
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,21 @@
"name" : "Contains"
}
}
}, {
"name" : "datasets",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.DatasetUrn"
},
"doc" : "Datasets consumed by a dashboard",
"default" : [ ],
"Relationship" : {
"/*" : {
"entityTypes" : [ "dataset" ],
"isLineage" : true,
"name" : "Consumes"
}
}
}, {
"name" : "lastModified",
"type" : "com.linkedin.common.ChangeAuditStamps",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,21 @@
"name" : "Contains"
}
}
}, {
"name" : "datasets",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.DatasetUrn"
},
"doc" : "Datasets consumed by a dashboard",
"default" : [ ],
"Relationship" : {
"/*" : {
"entityTypes" : [ "dataset" ],
"isLineage" : true,
"name" : "Consumes"
}
}
}, {
"name" : "lastModified",
"type" : "com.linkedin.common.ChangeAuditStamps",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,21 @@
"name" : "Contains"
}
}
}, {
"name" : "datasets",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.DatasetUrn"
},
"doc" : "Datasets consumed by a dashboard",
"default" : [ ],
"Relationship" : {
"/*" : {
"entityTypes" : [ "dataset" ],
"isLineage" : true,
"name" : "Consumes"
}
}
}, {
"name" : "lastModified",
"type" : "com.linkedin.common.ChangeAuditStamps",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,21 @@
"name" : "Contains"
}
}
}, {
"name" : "datasets",
"type" : {
"type" : "array",
"items" : "com.linkedin.common.DatasetUrn"
},
"doc" : "Datasets consumed by a dashboard",
"default" : [ ],
"Relationship" : {
"/*" : {
"entityTypes" : [ "dataset" ],
"isLineage" : true,
"name" : "Consumes"
}
}
}, {
"name" : "lastModified",
"type" : "com.linkedin.common.ChangeAuditStamps",
Expand Down

0 comments on commit 216129e

Please sign in to comment.