Skip to content

Commit

Permalink
fix(ui) Show editable field info for fields based on exact fieldPath …
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 authored Feb 10, 2025
1 parent 2323aff commit 15ac294
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ export function pathMatchesNewPath(fieldPathA?: string | null, fieldPathB?: stri
return fieldPathA === fieldPathB || fieldPathA === downgradeV2FieldPath(fieldPathB);
}

// should use pathMatchesExact when rendering editable info so the user edits the correct field
export function pathMatchesExact(fieldPathA?: string | null, fieldPathB?: string | null) {
return fieldPathA === fieldPathB;
}

// group schema fields by fieldPath and grouping for hierarchy in schema table
export function groupByFieldPath(
schemaRows?: Array<SchemaField>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
UsageQueryResult,
} from '../../../../../../../../types.generated';
import { useMutationUrn } from '../../../../../../../entity/shared/EntityContext';
import { pathMatchesNewPath } from '../../../../../../dataset/profile/schema/utils/utils';
import { pathMatchesExact } from '../../../../../../dataset/profile/schema/utils/utils';
import NotesSection from '../../../../../notes/NotesSection';
import FieldDescription from './FieldDescription';
import { FieldDetails } from './FieldDetails';
Expand Down Expand Up @@ -55,7 +55,7 @@ export function AboutFieldTab({ properties }: AboutFieldTabProps) {
: undefined;
const editableFieldInfo = properties.editableSchemaMetadata?.editableSchemaFieldInfo.find(
(candidateEditableFieldInfo) =>
pathMatchesNewPath(candidateEditableFieldInfo.fieldPath, expandedField?.fieldPath),
pathMatchesExact(candidateEditableFieldInfo.fieldPath, expandedField?.fieldPath),
);

const notes = properties.notes?.sort((a, b) => moment(b.lastModified.time).diff(moment(a.lastModified.time))) || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';

import { EditableSchemaMetadata, SchemaField, SubResourceType } from '../../../../../../../types.generated';
import DescriptionField from '../../../../../dataset/profile/schema/components/SchemaDescriptionField';
import { pathMatchesNewPath } from '../../../../../dataset/profile/schema/utils/utils';
import { pathMatchesExact } from '../../../../../dataset/profile/schema/utils/utils';
import { useUpdateDescriptionMutation } from '../../../../../../../graphql/mutations.generated';
import { useMutationUrn, useRefetch } from '../../../../../../entity/shared/EntityContext';
import { useSchemaRefetch } from '../SchemaContext';
Expand Down Expand Up @@ -31,7 +31,7 @@ export default function useDescriptionRenderer(

return (description: string | undefined, record: SchemaField, index: number): JSX.Element => {
const editableFieldInfo = editableSchemaMetadata?.editableSchemaFieldInfo.find((candidateEditableFieldInfo) =>
pathMatchesNewPath(candidateEditableFieldInfo.fieldPath, record.fieldPath),
pathMatchesExact(candidateEditableFieldInfo.fieldPath, record.fieldPath),
);
const { schemaFieldEntity } = record;
const { displayedDescription, sanitizedDescription, isPropagated, sourceDetail } = extractFieldDescription(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { pathMatchesNewPath } from '@src/app/entityV2/dataset/profile/schema/utils/utils';
import { pathMatchesExact } from '@src/app/entityV2/dataset/profile/schema/utils/utils';
import { EditableSchemaMetadata, SchemaField } from '@src/types.generated';
import { getFieldDescriptionDetails } from './getFieldDescriptionDetails';
import { sanitizeRichText } from '../../../Documentation/components/editor/utils';
Expand All @@ -8,7 +8,7 @@ export default function useExtractFieldDescriptionInfo(
) {
return (record: SchemaField, description: string | undefined | null = null) => {
const editableFieldInfoB = editableSchemaMetadata?.editableSchemaFieldInfo.find((candidateEditableFieldInfo) =>
pathMatchesNewPath(candidateEditableFieldInfo.fieldPath, record.fieldPath),
pathMatchesExact(candidateEditableFieldInfo.fieldPath, record.fieldPath),
);
const { displayedDescription, isPropagated, sourceDetail } = getFieldDescriptionDetails({
schemaFieldEntity: record.schemaFieldEntity,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { pathMatchesNewPath } from '@src/app/entityV2/dataset/profile/schema/utils/utils';
import { pathMatchesExact } from '@src/app/entityV2/dataset/profile/schema/utils/utils';
import { EditableSchemaMetadata, GlossaryTerms, SchemaField } from '@src/types.generated';

export default function useExtractFieldGlossaryTermsInfo(
editableSchemaMetadata: EditableSchemaMetadata | null | undefined,
) {
return (record: SchemaField, defaultUneditableTerms: GlossaryTerms | null = null) => {
const editableTerms = editableSchemaMetadata?.editableSchemaFieldInfo.find((candidateEditableFieldInfo) =>
pathMatchesNewPath(candidateEditableFieldInfo.fieldPath, record.fieldPath),
pathMatchesExact(candidateEditableFieldInfo.fieldPath, record.fieldPath),
)?.glossaryTerms;

const uneditableTerms = defaultUneditableTerms || record?.glossaryTerms;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { pathMatchesNewPath } from '@src/app/entityV2/dataset/profile/schema/utils/utils';
import { pathMatchesExact } from '@src/app/entityV2/dataset/profile/schema/utils/utils';
import { EditableSchemaMetadata, GlobalTags, SchemaField } from '@src/types.generated';

export default function useExtractFieldTagsInfo(editableSchemaMetadata: EditableSchemaMetadata | null | undefined) {
return (record: SchemaField, defaultUneditableTags: GlobalTags | null = null) => {
const editableTags = editableSchemaMetadata?.editableSchemaFieldInfo.find((candidateEditableFieldInfo) =>
pathMatchesNewPath(candidateEditableFieldInfo.fieldPath, record.fieldPath),
pathMatchesExact(candidateEditableFieldInfo.fieldPath, record.fieldPath),
)?.globalTags;

const uneditableTags = defaultUneditableTags || record?.globalTags;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { EditableSchemaMetadata, EntityType, GlobalTags, SchemaField } from '../../../../../../../types.generated';
import TagTermGroup from '../../../../../../sharedV2/tags/TagTermGroup';
import { pathMatchesNewPath } from '../../../../../dataset/profile/schema/utils/utils';
import { pathMatchesExact } from '../../../../../dataset/profile/schema/utils/utils';
import { useEntityData, useRefetch } from '../../../../../../entity/shared/EntityContext';

export default function useTagsAndTermsRendererFeatureTable(
Expand All @@ -15,7 +15,7 @@ export default function useTagsAndTermsRendererFeatureTable(

const tagAndTermRender = (tags: GlobalTags, record: SchemaField, rowIndex: number | undefined) => {
const relevantEditableFieldInfo = editableSchemaMetadata?.editableSchemaFieldInfo.find(
(candidateEditableFieldInfo) => pathMatchesNewPath(candidateEditableFieldInfo.fieldPath, record.fieldPath),
(candidateEditableFieldInfo) => pathMatchesExact(candidateEditableFieldInfo.fieldPath, record.fieldPath),
);

return (
Expand Down

0 comments on commit 15ac294

Please sign in to comment.