Skip to content

Commit

Permalink
feat(dashboard): add subTypes aspect to dashboard entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterchen09 committed Sep 11, 2022
1 parent e556bcb commit 06c9408
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public class DashboardType implements SearchableEntityType<Dashboard, String>, B
DOMAINS_ASPECT_NAME,
DEPRECATION_ASPECT_NAME,
DATA_PLATFORM_INSTANCE_ASPECT_NAME,
INPUT_FIELDS_ASPECT_NAME
INPUT_FIELDS_ASPECT_NAME,
SUB_TYPES_ASPECT_NAME
);
private static final Set<String> FACET_FIELDS = ImmutableSet.of("access", "tool");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.linkedin.common.InstitutionalMemory;
import com.linkedin.common.Ownership;
import com.linkedin.common.Status;
import com.linkedin.common.SubTypes;
import com.linkedin.common.urn.Urn;
import com.linkedin.dashboard.EditableDashboardProperties;
import com.linkedin.data.DataMap;
Expand Down Expand Up @@ -86,6 +87,7 @@ public Dashboard apply(@Nonnull final EntityResponse entityResponse) {
dataset.setDataPlatformInstance(DataPlatformInstanceAspectMapper.map(new DataPlatformInstance(dataMap))));
mappingHelper.mapToResult(INPUT_FIELDS_ASPECT_NAME, (dashboard, dataMap) ->
dashboard.setInputFields(InputFieldsMapper.map(new InputFields(dataMap), entityUrn)));
mappingHelper.mapToResult(SUB_TYPES_ASPECT_NAME, this::mapSubTypes);

return mappingHelper.getResult();
}
Expand Down Expand Up @@ -195,4 +197,13 @@ private void mapDomains(@Nonnull Dashboard dashboard, @Nonnull DataMap dataMap)
final Domains domains = new Domains(dataMap);
dashboard.setDomain(DomainAssociationMapper.map(domains, dashboard.getUrn()));
}

private void mapSubTypes(@Nonnull Dashboard dashboard, DataMap dataMap) {
SubTypes pegasusSubTypes = new SubTypes(dataMap);
if (pegasusSubTypes.hasTypeNames()) {
com.linkedin.datahub.graphql.generated.SubTypes subTypes = new com.linkedin.datahub.graphql.generated.SubTypes();
subTypes.setTypeNames(pegasusSubTypes.getTypeNames().stream().collect(Collectors.toList()));
dashboard.setSubTypes(subTypes);
}
}
}
5 changes: 5 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4342,6 +4342,11 @@ type Dashboard implements EntityWithRelationships & Entity & BrowsableEntity {
Input fields that power all the charts in the dashboard
"""
inputFields: InputFields

"""
Sub Types of the dashboard
"""
subTypes: SubTypes
}

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ 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 { ChartSnippet } from '../chart/ChartSnippet';

Expand Down Expand Up @@ -153,9 +154,11 @@ export class DashboardEntity implements Entity<Dashboard> {
// 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]) : '',
};
};

Expand All @@ -179,6 +182,7 @@ export class DashboardEntity implements Entity<Dashboard> {
statsSummary={data.statsSummary}
lastUpdatedMs={data.properties?.lastModified?.time}
createdMs={data.properties?.created?.time}
subtype={data.subTypes?.typeNames?.[0]}
/>
);
};
Expand Down Expand Up @@ -214,6 +218,7 @@ export class DashboardEntity implements Entity<Dashboard> {
inputFields={data.inputFields}
/>
}
subtype={data.subTypes?.typeNames?.[0]}
/>
);
};
Expand All @@ -223,6 +228,7 @@ export class DashboardEntity implements Entity<Dashboard> {
urn: entity.urn,
name: entity.properties?.name || '',
type: EntityType.Dashboard,
subtype: entity?.subTypes?.typeNames?.[0] || undefined,
icon: entity?.platform?.properties?.logoUrl || '',
platform: entity?.platform,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ import {
} from '../../../../types.generated';
import DefaultPreviewCard from '../../../preview/DefaultPreviewCard';
import { useEntityRegistry } from '../../../useEntityRegistry';
import { capitalizeFirstLetter } from '../../../shared/textUtil';
import { capitalizeFirstLetter, capitalizeFirstLetterOnly } from '../../../shared/textUtil';
import { IconStyleType } from '../../Entity';
import { DashboardStatsSummary as DashboardStatsSummaryView } from '../shared/DashboardStatsSummary';

export const DashboardPreview = ({
urn,
name,
platform,
platformInstanceId,
name,
subtype,
description,
platform,
access,
owners,
tags,
Expand All @@ -45,6 +46,7 @@ export const DashboardPreview = ({
platform: string;
platformInstanceId?: string;
name?: string;
subtype?: string | null;
description?: string | null;
access?: AccessLevel | null;
owners?: Array<Owner> | null;
Expand All @@ -71,7 +73,7 @@ export const DashboardPreview = ({
url={entityRegistry.getEntityUrl(EntityType.Dashboard, urn)}
name={name || ''}
description={description || ''}
type="Dashboard"
type={capitalizeFirstLetterOnly(subtype) || 'Dashboard'}
typeIcon={entityRegistry.getIcon(EntityType.Dashboard, 14, IconStyleType.ACCENT)}
logoUrl={logoUrl || ''}
platformInstanceId={platformInstanceId}
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/app/ingest/source/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const ENTITIES_WITH_SUBTYPES = new Set([
EntityType.Dataset.toLowerCase(),
EntityType.Container.toLowerCase(),
EntityType.Notebook.toLowerCase(),
EntityType.Dashboard.toLowerCase(),
]);

type EntityTypeCount = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,6 @@ export const dashboardEntity = (tool): Dashboard => {
},
platform: dataPlatform,
__typename: 'Dashboard',
subTypes: null,
};
};
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/browse.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ query getBrowseResults($input: BrowseInput!) {
domain {
...entityDomain
}
subTypes {
typeNames
}
}
... on GlossaryTerm {
ownership {
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ fragment dashboardFields on Dashboard {
inputFields {
...inputFieldsFields
}
subTypes {
typeNames
}
}

fragment nonRecursiveMLFeature on MLFeature {
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/lineage.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ fragment lineageNodeProperties on EntityWithRelationships {
status {
removed
}
subTypes {
typeNames
}
}
... on Chart {
tool
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/preview.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ fragment entityPreview on Entity {
deprecation {
...deprecationFields
}
subTypes {
typeNames
}
}
... on Chart {
urn
Expand Down
3 changes: 3 additions & 0 deletions datahub-web-react/src/graphql/search.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ fragment searchResultFields on Entity {
inputFields {
...inputFieldsFields
}
subTypes {
typeNames
}
}
... on Chart {
chartId
Expand Down
1 change: 1 addition & 0 deletions metadata-models/src/main/resources/entity-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ entities:
- deprecation
- dashboardUsageStatistics
- inputFields
- subTypes
- name: notebook
doc: Notebook represents a combination of query, text, chart and etc. This is in BETA version
keyAspect: notebookKey
Expand Down

0 comments on commit 06c9408

Please sign in to comment.