2025-04-16 16:55:38 -07:00
|
|
|
import { PartitionOutlined, PicCenterOutlined, UnorderedListOutlined } from '@ant-design/icons';
|
2025-01-29 20:42:01 -05:00
|
|
|
import * as React from 'react';
|
2025-04-16 16:55:38 -07:00
|
|
|
|
2025-01-29 20:42:01 -05:00
|
|
|
import { globalEntityRegistryV2 } from '@app/EntityRegistryProvider';
|
2025-04-16 16:55:38 -07:00
|
|
|
import { GenericEntityProperties } from '@app/entity/shared/types';
|
|
|
|
import { Entity, IconStyleType, PreviewType } from '@app/entityV2/Entity';
|
|
|
|
import { Preview } from '@app/entityV2/schemaField/preview/Preview';
|
|
|
|
import { EntityMenuItems } from '@app/entityV2/shared/EntityDropdown/EntityMenuActions';
|
|
|
|
import { EntityProfile } from '@app/entityV2/shared/containers/profile/EntityProfile';
|
2025-01-29 20:42:01 -05:00
|
|
|
import SidebarEntityHeader from '@app/entityV2/shared/containers/profile/sidebar/SidebarEntityHeader';
|
2025-04-16 16:55:38 -07:00
|
|
|
import { getDataForEntityType } from '@app/entityV2/shared/containers/profile/utils';
|
|
|
|
import SidebarNotesSection from '@app/entityV2/shared/sidebarSection/SidebarNotesSection';
|
2025-01-29 20:42:01 -05:00
|
|
|
import { LineageTab } from '@app/entityV2/shared/tabs/Lineage/LineageTab';
|
2025-04-16 16:55:38 -07:00
|
|
|
import { PropertiesTab } from '@app/entityV2/shared/tabs/Properties/PropertiesTab';
|
2025-01-29 20:42:01 -05:00
|
|
|
import { FetchedEntity } from '@app/lineage/types';
|
|
|
|
import { decodeSchemaField } from '@app/lineage/utils/columnLineageUtils';
|
2025-04-16 16:55:38 -07:00
|
|
|
import { downgradeV2FieldPath } from '@app/lineageV2/lineageUtils';
|
|
|
|
import TabFullsizedContext from '@src/app/shared/TabFullsizedContext';
|
2025-01-29 20:42:01 -05:00
|
|
|
|
2025-04-16 16:55:38 -07:00
|
|
|
import { useGetSchemaFieldQuery } from '@graphql/schemaField.generated';
|
|
|
|
import { EntityType, SchemaFieldEntity as SchemaField, SearchResult } from '@types';
|
2025-01-29 20:42:01 -05:00
|
|
|
|
|
|
|
const headerDropdownItems = new Set([EntityMenuItems.SHARE, EntityMenuItems.ANNOUNCE]);
|
|
|
|
|
|
|
|
export class SchemaFieldEntity implements Entity<SchemaField> {
|
|
|
|
type: EntityType = EntityType.SchemaField;
|
|
|
|
|
|
|
|
icon = (fontSize?: number, styleType?: IconStyleType, color = 'inherit') => (
|
|
|
|
<PicCenterOutlined style={{ fontSize, color }} />
|
|
|
|
);
|
|
|
|
|
|
|
|
isSearchEnabled = () => true;
|
|
|
|
|
|
|
|
isBrowseEnabled = () => false;
|
|
|
|
|
|
|
|
isLineageEnabled = () => false;
|
|
|
|
|
|
|
|
// Currently unused.
|
|
|
|
getAutoCompleteFieldName = () => 'schemaField';
|
|
|
|
|
|
|
|
getPathName = () => 'schemaField';
|
|
|
|
|
|
|
|
getEntityName = () => 'Column';
|
|
|
|
|
|
|
|
getCollectionName = () => 'Columns';
|
|
|
|
|
|
|
|
useEntityQuery = useGetSchemaFieldQuery;
|
|
|
|
|
|
|
|
renderProfile = (urn: string) => (
|
|
|
|
<TabFullsizedContext.Provider value={{ isTabFullsize: true }}>
|
|
|
|
<EntityProfile
|
|
|
|
urn={urn}
|
|
|
|
entityType={EntityType.SchemaField}
|
|
|
|
useEntityQuery={useGetSchemaFieldQuery}
|
|
|
|
headerDropdownItems={headerDropdownItems}
|
|
|
|
tabs={[
|
|
|
|
{
|
|
|
|
name: 'Lineage',
|
|
|
|
component: LineageTab,
|
|
|
|
icon: PartitionOutlined,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Properties',
|
|
|
|
component: PropertiesTab,
|
|
|
|
icon: UnorderedListOutlined,
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
sidebarSections={this.getSidebarSections()}
|
|
|
|
/>
|
|
|
|
</TabFullsizedContext.Provider>
|
|
|
|
);
|
|
|
|
|
|
|
|
getSidebarSections = () => [{ component: SidebarEntityHeader }, { component: SidebarNotesSection }];
|
|
|
|
|
|
|
|
getGraphName = () => 'schemaField';
|
|
|
|
|
|
|
|
renderPreview = (previewType: PreviewType, data: SchemaField) => {
|
|
|
|
const genericProperties = this.getGenericEntityProperties(data);
|
|
|
|
return (
|
|
|
|
<Preview
|
|
|
|
data={genericProperties}
|
|
|
|
previewType={previewType}
|
|
|
|
datasetUrn={data.parent.urn}
|
|
|
|
name={downgradeV2FieldPath(data.fieldPath) || data.urn}
|
|
|
|
parent={data?.parent as GenericEntityProperties}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
renderSearch = (result: SearchResult) => this.renderPreview(PreviewType.SEARCH, result.entity as SchemaField);
|
|
|
|
|
|
|
|
displayName = (data: SchemaField) => decodeSchemaField(downgradeV2FieldPath(data?.fieldPath) || '') || data.urn;
|
|
|
|
|
2025-05-01 13:40:42 -04:00
|
|
|
getOverridePropertiesFromEntity = (schemaField?: SchemaField | null): GenericEntityProperties => {
|
|
|
|
const parent =
|
|
|
|
schemaField?.parent &&
|
|
|
|
globalEntityRegistryV2.getGenericEntityProperties(schemaField?.parent.type, schemaField?.parent);
|
|
|
|
return {
|
|
|
|
platform: parent?.platform,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2025-01-29 20:42:01 -05:00
|
|
|
getGenericEntityProperties = (data: SchemaField): GenericEntityProperties | null =>
|
|
|
|
getDataForEntityType({
|
|
|
|
data,
|
|
|
|
entityType: this.type,
|
2025-05-01 13:40:42 -04:00
|
|
|
getOverrideProperties: this.getOverridePropertiesFromEntity,
|
2025-01-29 20:42:01 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
getLineageVizConfig = (entity: SchemaField): FetchedEntity => {
|
|
|
|
const parent =
|
|
|
|
entity.parent && globalEntityRegistryV2.getGenericEntityProperties(entity.parent.type, entity.parent);
|
|
|
|
return {
|
|
|
|
urn: entity.urn,
|
|
|
|
type: EntityType.SchemaField,
|
|
|
|
name: entity?.fieldPath,
|
|
|
|
expandedName: `${parent?.name}.${entity?.fieldPath}`,
|
|
|
|
icon: parent?.platform?.properties?.logoUrl ?? undefined,
|
|
|
|
parent: parent ?? undefined,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
supportedCapabilities = () => new Set([]);
|
|
|
|
}
|