Skip to content

Commit

Permalink
(bugfix): correct rendering terms' markdown on dataset structure page (
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyNenashev authored Oct 12, 2023
1 parent 20c0b84 commit edb15cf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import React, { type FC, useCallback } from 'react';
import { Box } from '@mui/material';
import { Permission, type TermRef } from 'generated-sources';
import { WithPermissions } from 'components/shared/contexts';
import { Button, CollapsibleInfoContainer, InfoItem } from 'components/shared/elements';
import {
Button,
CollapsibleInfoContainer,
InfoItem,
Markdown,
} from 'components/shared/elements';
import { DeleteIcon, LinkedTermIcon } from 'components/shared/icons';
import { useAppPaths, useDeleteDatasetFieldTerm } from 'lib/hooks';

Expand Down Expand Up @@ -49,7 +54,7 @@ const TermItem: FC<TermItemProps> = ({
}
info={
<CollapsibleInfoContainer
content={<>{definition}</>}
content={<Markdown value={definition} />}
actions={
!isDescriptionLink ? (
<WithPermissions permissionTo={Permission.DATASET_FIELD_DELETE_TERM}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const TermItem: React.FC<TermItemProps> = ({
{linkedTerm.isDescriptionLink && <LinkedTermIcon />}
</Box>
<S.TermDefinition variant='subtitle2'>
{linkedTerm.term.definition}
{linkedTerm.term.namespace.name}
</S.TermDefinition>
</Grid>
{!linkedTerm.isDescriptionLink && !isStatusDeleted && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Button from 'components/shared/elements/Button/Button';
import TermsAutocomplete from 'components/shared/elements/Autocomplete/TermsAutocomplete/TermsAutocomplete';
import type { TermRef } from 'generated-sources';
import DialogWrapper from 'components/shared/elements/DialogWrapper/DialogWrapper';
import Markdown from 'components/shared/elements/Markdown/Markdown';

interface AssignTermFormData {
termId: number;
Expand Down Expand Up @@ -75,7 +76,7 @@ const AssignTermForm: FC<AssignTermFormProps> = ({
<Typography variant='body2' color='texts.secondary' component='span'>
{t('Definition')}:
</Typography>
{selectedTerm.definition}
<Markdown value={selectedTerm.definition} />
</Grid>
</>
)}
Expand Down
12 changes: 4 additions & 8 deletions odd-platform-ui/src/lib/hooks/api/terms.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { useQueryClient } from '@tanstack/react-query';
import { termApi } from 'lib/api';
import type { TermApiGetTermByNamespaceAndNameRequest, TermRef } from 'generated-sources';
import type { TermApiGetTermByNamespaceAndNameRequest } from 'generated-sources';
import type { AppError } from 'lib/errorHandling';

export function useGetTermByNamespaceAndName() {
const queryClient = useQueryClient();

return async ({
namespaceName,
termName,
}: TermApiGetTermByNamespaceAndNameRequest): Promise<TermRef | AppError> => {
return async ({ namespaceName, termName }: TermApiGetTermByNamespaceAndNameRequest) => {
try {
const params = { namespaceName, termName };
return await queryClient.fetchQuery(['term', namespaceName, termName], () =>
termApi.getTermByNamespaceAndName(params)
return await queryClient.fetchQuery(['terms', namespaceName, termName], () =>
termApi.getTermByNamespaceAndName({ namespaceName, termName })
);
} catch (error) {
return error as AppError;
Expand Down

0 comments on commit edb15cf

Please sign in to comment.