Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): Adding Search Select feature(frontend only) #5507

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions datahub-web-react/src/app/entity/Entity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,36 @@ export enum IconStyleType {
SVG,
}

/**
* A standard set of Entity Capabilities that span across entity types.
*/
export enum EntityCapabilityType {
/**
* Ownership of an entity
*/
OWNERS,
/**
* Adding a glossary term to the entity
*/
GLOSSARY_TERMS,
/**
* Adding a tag to an entity
*/
TAGS,
/**
* Assigning the entity to a domain
*/
DOMAINS,
/**
* Deprecating an entity
*/
DEPRECATION,
/**
* Soft deleting an entity
*/
SOFT_DELETE,
}

/**
* Base interface used for authoring DataHub Entities on the client side.
*
Expand Down Expand Up @@ -124,4 +154,9 @@ export interface Entity<T> {
* Returns generic entity properties for the entity
*/
getGenericEntityProperties: (data: T) => GenericEntityProperties | null;

/**
* Returns the supported features for the entity
*/
supportedCapabilities: () => Set<EntityCapabilityType>;
}
15 changes: 14 additions & 1 deletion datahub-web-react/src/app/entity/EntityRegistry.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Entity as EntityInterface, EntityType, SearchResult } from '../../types.generated';
import { FetchedEntity } from '../lineage/types';
import { Entity, IconStyleType, PreviewType } from './Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from './Entity';
import { GenericEntityProperties } from './shared/types';
import { dictToQueryStringParams, urlEncodeUrn } from './shared/utils';

Expand Down Expand Up @@ -153,4 +153,17 @@ export default class EntityRegistry {
const entity = validatedGet(type, this.entityTypeToEntity);
return entity.getGenericEntityProperties(data);
}

getSupportedEntityCapabilities(type: EntityType): Set<EntityCapabilityType> {
const entity = validatedGet(type, this.entityTypeToEntity);
return entity.supportedCapabilities();
}

getTypesWithSupportedCapabilities(capability: EntityCapabilityType): Set<EntityType> {
return new Set(
this.getEntities()
.filter((entity) => entity.supportedCapabilities().has(capability))
.map((entity) => entity.type),
);
}
}
13 changes: 12 additions & 1 deletion datahub-web-react/src/app/entity/chart/ChartEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LineChartOutlined } from '@ant-design/icons';
import * as React from 'react';
import { Chart, EntityType, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { ChartPreview } from './preview/ChartPreview';
import { GetChartQuery, useGetChartQuery, useUpdateChartMutation } from '../../../graphql/chart.generated';
import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab';
Expand Down Expand Up @@ -209,4 +209,15 @@ export class ChartEntity implements Entity<Chart> {
getOverrideProperties: this.getOverridePropertiesFromEntity,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.GLOSSARY_TERMS,
EntityCapabilityType.TAGS,
EntityCapabilityType.DOMAINS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
Comment on lines +215 to +220
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking out loud here: can we somehow unify capabilities & entity page layout some day so that we don't have to extend both places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly - But I'm not sure the two are strictly equivalent... For example, the stats tab merges a few things already

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is, entity capabilities not necessarily 1:1 with tabs

]);
};
}
12 changes: 11 additions & 1 deletion datahub-web-react/src/app/entity/container/ContainerEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { FolderOutlined } from '@ant-design/icons';
import { Container, EntityType, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { Preview } from './preview/Preview';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab';
Expand Down Expand Up @@ -164,4 +164,14 @@ export class ContainerEntity implements Entity<Container> {
getOverrideProperties: this.getOverridePropertiesFromEntity,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.GLOSSARY_TERMS,
EntityCapabilityType.TAGS,
EntityCapabilityType.DOMAINS,
EntityCapabilityType.SOFT_DELETE,
]);
};
}
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 @@ -6,7 +6,7 @@ import {
useUpdateDashboardMutation,
} from '../../../graphql/dashboard.generated';
import { Dashboard, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, 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';
Expand Down Expand Up @@ -226,4 +226,15 @@ export class DashboardEntity implements Entity<Dashboard> {
getOverrideProperties: this.getOverridePropertiesFromEntity,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.GLOSSARY_TERMS,
EntityCapabilityType.TAGS,
EntityCapabilityType.DOMAINS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
]);
};
}
13 changes: 12 additions & 1 deletion datahub-web-react/src/app/entity/dataFlow/DataFlowEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { ShareAltOutlined } from '@ant-design/icons';
import { DataFlow, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
import { Preview } from './preview/Preview';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
import { useGetDataFlowQuery, useUpdateDataFlowMutation } from '../../../graphql/dataFlow.generated';
import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab';
Expand Down Expand Up @@ -158,4 +158,15 @@ export class DataFlowEntity implements Entity<DataFlow> {
getOverrideProperties: this.getOverridePropertiesFromEntity,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.GLOSSARY_TERMS,
EntityCapabilityType.TAGS,
EntityCapabilityType.DOMAINS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
]);
};
}
13 changes: 12 additions & 1 deletion datahub-web-react/src/app/entity/dataJob/DataJobEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { ConsoleSqlOutlined } from '@ant-design/icons';
import { DataJob, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
import { Preview } from './preview/Preview';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
import { GetDataJobQuery, useGetDataJobQuery, useUpdateDataJobMutation } from '../../../graphql/dataJob.generated';
import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab';
Expand Down Expand Up @@ -195,4 +195,15 @@ export class DataJobEntity implements Entity<DataJob> {
getOverrideProperties: this.getOverridePropertiesFromEntity,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.GLOSSARY_TERMS,
EntityCapabilityType.TAGS,
EntityCapabilityType.DOMAINS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
]);
};
}
13 changes: 12 additions & 1 deletion datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { DatabaseFilled, DatabaseOutlined } from '@ant-design/icons';
import { Typography } from 'antd';
import { Dataset, DatasetProperties, EntityType, OwnershipType, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { Preview } from './preview/Preview';
import { FIELDS_TO_HIGHLIGHT } from './search/highlights';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
Expand Down Expand Up @@ -322,4 +322,15 @@ export class DatasetEntity implements Entity<Dataset> {
getOverrideProperties: this.getOverridePropertiesFromEntity,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.GLOSSARY_TERMS,
EntityCapabilityType.TAGS,
EntityCapabilityType.DOMAINS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
]);
};
}
9 changes: 8 additions & 1 deletion datahub-web-react/src/app/entity/domain/DomainEntity.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { FolderOutlined } from '@ant-design/icons';
import { Domain, EntityType, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { Preview } from './preview/Preview';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab';
Expand All @@ -11,6 +11,7 @@ import { getDataForEntityType } from '../shared/containers/profile/utils';
import { useGetDomainQuery } from '../../../graphql/domain.generated';
import { DomainEntitiesTab } from './DomainEntitiesTab';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';
import { EntityActionItem } from '../shared/entity/EntityActions';

/**
* Definition of the DataHub Domain entity.
Expand Down Expand Up @@ -65,6 +66,7 @@ export class DomainEntity implements Entity<Domain> {
useUpdateQuery={undefined}
getOverrideProperties={this.getOverridePropertiesFromEntity}
headerDropdownItems={new Set([EntityMenuItems.COPY_URL, EntityMenuItems.DELETE])}
headerActionItems={new Set([EntityActionItem.BATCH_ADD_DOMAIN])}
isNameEditable
tabs={[
{
Expand Down Expand Up @@ -134,4 +136,9 @@ export class DomainEntity implements Entity<Domain> {
getOverrideProperties: this.getOverridePropertiesFromEntity,
});
};

supportedCapabilities = () => {
// TODO.. Determine whether SOFT_DELETE should go into here.
return new Set([EntityCapabilityType.OWNERS]);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { useGetGlossaryNodeQuery } from '../../../graphql/glossaryNode.generated';
import { EntityType, GlossaryNode, SearchResult } from '../../../types.generated';
import GlossaryEntitiesPath from '../../glossary/GlossaryEntitiesPath';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, 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';
Expand Down Expand Up @@ -135,6 +135,14 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
getOverrideProperties: (data) => data,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
]);
};
}

export default GlossaryNodeEntity;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { BookFilled, BookOutlined } from '@ant-design/icons';
import { EntityType, GlossaryTerm, SearchResult } from '../../../types.generated';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { Preview } from './preview/Preview';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
Expand All @@ -16,6 +16,7 @@ import { DocumentationTab } from '../shared/tabs/Documentation/DocumentationTab'
import { SidebarAboutSection } from '../shared/containers/profile/sidebar/SidebarAboutSection';
import GlossaryEntitiesPath from '../../glossary/GlossaryEntitiesPath';
import { EntityMenuItems } from '../shared/EntityDropdown/EntityDropdown';
import { EntityActionItem } from '../shared/entity/EntityActions';

/**
* Definition of the DataHub Dataset entity.
Expand Down Expand Up @@ -62,6 +63,7 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
urn={urn}
entityType={EntityType.GlossaryTerm}
useEntityQuery={useGetGlossaryTermQuery as any}
headerActionItems={new Set([EntityActionItem.BATCH_ADD_GLOSSARY_TERM])}
headerDropdownItems={
new Set([
EntityMenuItems.COPY_URL,
Expand Down Expand Up @@ -154,4 +156,12 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
getOverrideProperties: (data) => data,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
]);
};
}
4 changes: 4 additions & 0 deletions datahub-web-react/src/app/entity/group/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ export class GroupEntity implements Entity<CorpGroup> {
getGenericEntityProperties = (group: CorpGroup) => {
return getDataForEntityType({ data: group, entityType: this.type, getOverrideProperties: (data) => data });
};

supportedCapabilities = () => {
return new Set([]);
};
}
13 changes: 12 additions & 1 deletion datahub-web-react/src/app/entity/mlFeature/MLFeatureEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { DotChartOutlined } from '@ant-design/icons';
import { MlFeature, EntityType, SearchResult, OwnershipType } from '../../../types.generated';
import { Preview } from './preview/Preview';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { EntityProfile } from '../shared/containers/profile/EntityProfile';
import { GenericEntityProperties } from '../shared/types';
Expand Down Expand Up @@ -172,4 +172,15 @@ export class MLFeatureEntity implements Entity<MlFeature> {
platform: entity?.['featureTables']?.relationships?.[0]?.entity?.platform?.name,
};
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.GLOSSARY_TERMS,
EntityCapabilityType.TAGS,
EntityCapabilityType.DOMAINS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
]);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { DotChartOutlined } from '@ant-design/icons';
import { MlFeatureTable, EntityType, SearchResult, OwnershipType } from '../../../types.generated';
import { Preview } from './preview/Preview';
import { Entity, IconStyleType, PreviewType } from '../Entity';
import { Entity, EntityCapabilityType, IconStyleType, PreviewType } from '../Entity';
import { getDataForEntityType } from '../shared/containers/profile/utils';
import { GenericEntityProperties } from '../shared/types';
import { useGetMlFeatureTableQuery } from '../../../graphql/mlFeatureTable.generated';
Expand Down Expand Up @@ -159,4 +159,15 @@ export class MLFeatureTableEntity implements Entity<MlFeatureTable> {
getOverrideProperties: (data) => data,
});
};

supportedCapabilities = () => {
return new Set([
EntityCapabilityType.OWNERS,
EntityCapabilityType.GLOSSARY_TERMS,
EntityCapabilityType.TAGS,
EntityCapabilityType.DOMAINS,
EntityCapabilityType.DEPRECATION,
EntityCapabilityType.SOFT_DELETE,
]);
};
}
Loading