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

fix(ui) Show editable field info for fields based on exact fieldPath version #12570

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
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 @@
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 @@
: undefined;
const editableFieldInfo = properties.editableSchemaMetadata?.editableSchemaFieldInfo.find(
(candidateEditableFieldInfo) =>
pathMatchesNewPath(candidateEditableFieldInfo.fieldPath, expandedField?.fieldPath),
pathMatchesExact(candidateEditableFieldInfo.fieldPath, expandedField?.fieldPath),

Check warning on line 58 in datahub-web-react/src/app/entityV2/shared/tabs/Dataset/Schema/components/SchemaFieldDrawer/AboutFieldTab.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/shared/tabs/Dataset/Schema/components/SchemaFieldDrawer/AboutFieldTab.tsx#L58

Added line #L58 was not covered by tests
);

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 { 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 @@

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),

Check warning on line 34 in datahub-web-react/src/app/entityV2/shared/tabs/Dataset/Schema/utils/useDescriptionRenderer.tsx

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/shared/tabs/Dataset/Schema/utils/useDescriptionRenderer.tsx#L34

Added line #L34 was not covered by tests
);
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 @@
) {
return (record: SchemaField, description: string | undefined | null = null) => {
const editableFieldInfoB = editableSchemaMetadata?.editableSchemaFieldInfo.find((candidateEditableFieldInfo) =>
pathMatchesNewPath(candidateEditableFieldInfo.fieldPath, record.fieldPath),
pathMatchesExact(candidateEditableFieldInfo.fieldPath, record.fieldPath),

Check warning on line 11 in datahub-web-react/src/app/entityV2/shared/tabs/Dataset/Schema/utils/useExtractFieldDescriptionInfo.ts

View check run for this annotation

Codecov / codecov/patch

datahub-web-react/src/app/entityV2/shared/tabs/Dataset/Schema/utils/useExtractFieldDescriptionInfo.ts#L11

Added line #L11 was not covered by tests
);
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
Loading