Skip to content

Commit

Permalink
render structured props manager in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 committed Dec 11, 2024
1 parent ff3ff15 commit a72e668
Show file tree
Hide file tree
Showing 39 changed files with 166 additions and 35 deletions.
4 changes: 4 additions & 0 deletions datahub-web-react/src/app/entity/Access/RoleEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ export class RoleEntity implements Entity<Role> {
supportedCapabilities = () => {
return new Set([EntityCapabilityType.OWNERS]);
};

getGraphName = () => {
return 'roleEntity';
};
}
5 changes: 5 additions & 0 deletions datahub-web-react/src/app/entity/Entity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ export interface Entity<T> {
*/
getGenericEntityProperties: (data: T) => GenericEntityProperties | null;

/**
* Returns the graph name of the entity, as it appears in the GMS entity registry
*/
getGraphName: () => string;

/**
* Returns the supported features for the entity
*/
Expand Down
4 changes: 4 additions & 0 deletions datahub-web-react/src/app/entity/EntityRegistry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,8 @@ export default class EntityRegistry {
const entity = validatedGet(type, this.entityTypeToEntity);
return entity.getCustomCardUrlPath?.();
}

getGraphNameFromType(type: EntityType): string {
return validatedGet(type, this.entityTypeToEntity).getGraphName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export class BusinessAttributeEntity implements Entity<BusinessAttribute> {

getCollectionName = () => 'Business Attributes';

getGraphName = () => 'businessAttribute';

getCustomCardUrlPath = () => PageRoutes.BUSINESS_ATTRIBUTE;

isBrowseEnabled = () => false;
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/chart/ChartEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export class ChartEntity implements Entity<Chart> {

getAutoCompleteFieldName = () => 'title';

getGraphName = () => 'chart';

getPathName = () => 'chart';

getEntityName = () => 'Chart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export class ContainerEntity implements Entity<Container> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'container';

getPathName = () => 'container';

getEntityName = () => 'Container';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ export class DashboardEntity implements Entity<Dashboard> {
]);
};

getGraphName = () => this.getPathName();

renderEmbeddedProfile = (urn: string) => (
<EmbeddedProfile
urn={urn}
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/dataFlow/DataFlowEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export class DataFlowEntity implements Entity<DataFlow> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'dataFlow';

getPathName = () => 'pipelines';

getEntityName = () => 'Pipeline';
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/dataJob/DataJobEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class DataJobEntity implements Entity<DataJob> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'dataJob';

getPathName = () => 'tasks';

getEntityName = () => 'Task';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ export class DataPlatformEntity implements Entity<DataPlatform> {
supportedCapabilities = () => {
return new Set([]);
};

getGraphName = () => {
return 'dataPlatform';
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ export class DataPlatformInstanceEntity implements Entity<DataPlatformInstance>
supportedCapabilities = () => {
return new Set([]);
};

getGraphName = () => {
return 'dataPlatformInstance';
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,8 @@ export class DataProductEntity implements Entity<DataProduct> {
EntityCapabilityType.DOMAINS,
]);
};

getGraphName = () => {
return 'dataProduct';
};
}
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export class DatasetEntity implements Entity<Dataset> {

getPathName = () => 'dataset';

getGraphName = () => 'dataset';

getEntityName = () => 'Dataset';

getCollectionName = () => 'Datasets';
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/domain/DomainEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export class DomainEntity implements Entity<Domain> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'domain';

getPathName = () => 'domain';

getEntityName = () => 'Domain';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class ERModelRelationshipEntity implements Entity<ErModelRelationship> {

getEntityName = () => 'ER-Model-Relationship';

getGraphName = () => 'erModelRelationship';

renderProfile = (urn: string) => (
<EntityProfile
urn={urn}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class GlossaryNodeEntity implements Entity<GlossaryNode> {
EntityCapabilityType.SOFT_DELETE,
]);
};

getGraphName = () => this.getPathName();
}

export default GlossaryNodeEntity;
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,6 @@ export class GlossaryTermEntity implements Entity<GlossaryTerm> {
EntityCapabilityType.SOFT_DELETE,
]);
};

getGraphName = () => this.getPathName();
}
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/group/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export class GroupEntity implements Entity<CorpGroup> {

getAutoCompleteFieldName = () => 'name';

getGraphName: () => string = () => 'corpGroup';

getPathName: () => string = () => 'group';

getEntityName = () => 'Group';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class MLFeatureEntity implements Entity<MlFeature> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'mlFeature';

getPathName = () => 'features';

getEntityName = () => 'Feature';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export class MLFeatureTableEntity implements Entity<MlFeatureTable> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'mlFeatureTable';

getPathName = () => 'featureTables';

getEntityName = () => 'Feature Table';
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/mlModel/MLModelEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export class MLModelEntity implements Entity<MlModel> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'mlModel';

getPathName = () => 'mlModels';

getEntityName = () => 'ML Model';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class MLModelGroupEntity implements Entity<MlModelGroup> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'mlModelGroup';

getPathName = () => 'mlModelGroup';

getEntityName = () => 'ML Group';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class MLPrimaryKeyEntity implements Entity<MlPrimaryKey> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'mlPrimaryKey';

getPathName = () => 'mlPrimaryKeys';

getEntityName = () => 'ML Primary Key';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class SchemaFieldPropertiesEntity implements Entity<SchemaFieldEntity> {
// Currently unused.
renderProfile = (_: string) => <></>;

getGraphName = () => 'schemaField';

renderPreview = (previewType: PreviewType, data: SchemaFieldEntity) => {
const parent = data.parent as Dataset;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ export function mapStructuredPropertyValues(structuredPropertiesEntry: Structure
}));
}

export function mapStructuredPropertyToPropertyRow(structuredPropertiesEntry: StructuredPropertiesEntry) {
const { displayName, qualifiedName } = structuredPropertiesEntry.structuredProperty.definition;
return {
displayName: displayName || qualifiedName,
qualifiedName,
values: mapStructuredPropertyValues(structuredPropertiesEntry),
dataType: structuredPropertiesEntry.structuredProperty.definition.valueType,
structuredProperty: structuredPropertiesEntry.structuredProperty,
type:
structuredPropertiesEntry.values[0] && structuredPropertiesEntry.values[0].__typename
? {
type: typeNameToType[structuredPropertiesEntry.values[0].__typename].type,
nativeDataType: typeNameToType[structuredPropertiesEntry.values[0].__typename].nativeDataType,
}
: undefined,
associatedUrn: structuredPropertiesEntry.associatedUrn,
};
}

// map the properties map into a list of PropertyRow objects to render in a table
function getStructuredPropertyRows(entityData?: GenericEntityProperties | null) {
const structuredPropertyRows: PropertyRow[] = [];
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class TagEntity implements Entity<Tag> {

getAutoCompleteFieldName = () => 'name';

getGraphName = () => 'tag';

getPathName: () => string = () => 'tag';

getCollectionName: () => string = () => 'Tags';
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/user/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export class UserEntity implements Entity<CorpUser> {

getAutoCompleteFieldName = () => 'username';

getGraphName: () => string = () => 'corpuser';

getPathName: () => string = () => 'user';

getEntityName = () => 'Person';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { colors, Icon, Input, Text, TextArea } from '@src/alchemy-components';
import { StyledButton } from '@src/app/shared/share/v2/styledComponents';
import { Button, Icon, Input, Text, TextArea } from '@src/alchemy-components';
import { AllowedValue } from '@src/types.generated';
import { Form, FormInstance } from 'antd';
import { Tooltip } from '@components';
Expand Down Expand Up @@ -122,15 +121,15 @@ const AllowedValuesDrawer = ({

<AddButtonContainer>
<Tooltip title="Add a new value to the allowed list" showArrow={false}>
<StyledButton
<Button
onClick={() => {
add();
setTimeout(() => scrollToBottom(), 0);
}}
$color={colors.violet[500]}
color={'violet'}
>
Add
</StyledButton>
</Button>
</Tooltip>
</AddButtonContainer>
</FormContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Icon, Pill, Switch, Text } from '@src/alchemy-components';
import { ConfirmationModal } from '@src/app/sharedV2/modals/ConfirmationModal';
import { AllowedValue, StructuredPropertyEntity, StructuredPropertyFilterStatus } from '@src/types.generated';
import { AllowedValue, StructuredPropertyEntity } from '@src/types.generated';
import { Collapse } from 'antd';
import React, { useState } from 'react';
import { useUpdateStructuredPropertyMutation } from '@src/graphql/structuredProperties.generated';
Expand Down Expand Up @@ -81,10 +81,7 @@ const DisplayPreferences = ({
<Switch
label="Show in Search Filters"
size="sm"
checked={
formValues?.settings?.showInSearchFilters ||
formValues?.filterStatus === StructuredPropertyFilterStatus.Enabled
}
checked={formValues?.settings?.showInSearchFilters}
onChange={(e) => handleDisplaySettingChange('showInSearchFilters', e.target.checked)}
isDisabled={formValues?.settings?.isHidden}
labelHoverText="If enabled, this property will appear in search filters"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
SearchResult,
SearchResults,
StructuredPropertyEntity,
StructuredPropertyFilterStatus,
UpdateStructuredPropertyInput,
} from '@src/types.generated';
import { Form } from 'antd';
Expand Down Expand Up @@ -126,11 +125,6 @@ const StructuredPropsDrawer = ({
allowedValues,
};

let filterStatus: StructuredPropertyFilterStatus | null = null;
if (updateValues.settings?.showInSearchFilters === false) {
filterStatus = StructuredPropertyFilterStatus.Disabled;
}

const editInput: UpdateStructuredPropertyInput = {
urn: selectedProperty.entity.urn,
displayName: updateValues.displayName,
Expand All @@ -150,7 +144,6 @@ const StructuredPropsDrawer = ({
updateValues,
),
setCardinalityAsMultiple: cardinality === PropertyCardinality.Multiple,
filterStatus: filterStatus ?? undefined,
settings: {
isHidden: updateValues.settings?.isHidden ?? false,
showInSearchFilters: updateValues.settings?.showInSearchFilters ?? false,
Expand Down Expand Up @@ -268,7 +261,6 @@ const StructuredPropsDrawer = ({
},
immutable: entity.definition.immutable,
settings: entity.settings,
filterStatus: entity.definition.filterStatus,
};

setFormValues(values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { Link } from 'react-router-dom';
import { removeFromPropertiesList } from './cacheUtils';
import EmptyStructuredProperties from './EmptyStructuredProperties';
import {
CardIcons,
CreatedByContainer,
DataContainer,
IconContainer,
Expand Down Expand Up @@ -234,7 +235,7 @@ const StructuredPropsTable = ({
return (
<>
{createdByUser && (
<HoverEntityTooltip entity={createdByUser as Entity} showArrow={false}>
<HoverEntityTooltip entity={createdByUser as Entity}>
<Link
to={`${entityRegistry.getEntityUrl(
EntityType.CorpUser,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { colors, Icon, Switch, Text } from '@src/alchemy-components';
import { StructuredPropertyEntity, StructuredPropertyFilterStatus } from '@src/types.generated';
import { StructuredPropertyEntity } from '@src/types.generated';
import { Collapse } from 'antd';
import React from 'react';
import { CollapseHeader, StyledCollapse, StyledFormItem, TogglesContainer } from './styledComponents';
Expand Down Expand Up @@ -44,10 +44,7 @@ const ViewDisplayPreferences = ({ propEntity }: Props) => {
<Switch
label="Show in Search Filters"
size="sm"
checked={
propEntity?.settings?.showInSearchFilters ||
propEntity?.definition.filterStatus === StructuredPropertyFilterStatus.Enabled
}
checked={propEntity?.settings?.showInSearchFilters}
labelStyle={{ fontSize: 12, color: colors.gray[1700], fontWeight: 700 }}
isDisabled
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Text } from '@components';
import { useEntityRegistryV2 } from '@src/app/useEntityRegistry';
import { useEntityRegistry } from '@src/app/useEntityRegistry';
import { PropertyCardinality, SearchResult, StructuredPropertyEntity } from '@src/types.generated';
import React from 'react';
import {
Expand Down Expand Up @@ -31,7 +31,7 @@ const ViewStructuredPropsDrawer = ({
selectedProperty,
setSelectedProperty,
}: Props) => {
const entityRegistry = useEntityRegistryV2();
const entityRegistry = useEntityRegistry();

const handleClose = () => {
setIsViewDrawerOpen(false);
Expand Down
Loading

0 comments on commit a72e668

Please sign in to comment.