diff --git a/datahub-web-react/src/app/entity/dataset/profile/Documentation.tsx b/datahub-web-react/src/app/entity/dataset/profile/Documentation.tsx deleted file mode 100644 index b23c615fbb72a4..00000000000000 --- a/datahub-web-react/src/app/entity/dataset/profile/Documentation.tsx +++ /dev/null @@ -1,217 +0,0 @@ -import { Button, Form, Input, Space, Table, Typography } from 'antd'; -import React, { useEffect, useMemo, useState } from 'react'; -import { Link } from 'react-router-dom'; -import { - CorpUser, - EntityType, - InstitutionalMemoryMetadata, - InstitutionalMemoryUpdate, -} from '../../../../types.generated'; -import { useEntityRegistry } from '../../../useEntityRegistry'; -import { useEntityData } from '../../shared/EntityContext'; -import analytics, { EventType, EntityActionType } from '../../../analytics'; - -export type Props = { - authenticatedUserUrn?: string; - authenticatedUserUsername?: string; - documents: Array; - updateDocumentation: (update: InstitutionalMemoryUpdate) => void; -}; - -function formatDateString(time: number) { - const date = new Date(time); - return date.toLocaleDateString('en-US'); -} - -function FormInput({ name, placeholder, type }: { name: string; placeholder: string; type: 'url' | 'string' }) { - return ( - - - - ); -} - -export default function Documentation({ - authenticatedUserUrn, - documents, - updateDocumentation, - authenticatedUserUsername, -}: Props) { - const entityRegistry = useEntityRegistry(); - - const [form] = Form.useForm(); - const [editingIndex, setEditingIndex] = useState(-1); - const [stagedDocs, setStagedDocs] = useState(documents); - - useEffect(() => { - setStagedDocs(documents); - }, [documents]); - - const tableData = useMemo( - () => - stagedDocs.map((doc, index) => ({ - key: index, - author: { urn: doc.author.urn, username: doc.author.username, type: EntityType.CorpUser }, - url: doc.url, - description: doc.description, - createdAt: doc.created.time, - })), - [stagedDocs], - ); - - const isEditing = (record: any) => record.key === editingIndex; - - const onAdd = (authorUrn: string, authorUsername: string) => { - setEditingIndex(stagedDocs.length); - - form.setFieldsValue({ - url: '', - description: '', - }); - - const newDoc = { - url: '', - description: '', - label: '', - author: { urn: authorUrn, username: authorUsername, type: EntityType.CorpUser }, - created: { - time: Date.now(), - }, - }; - - const newStagedDocs = [...stagedDocs, newDoc]; - setStagedDocs(newStagedDocs); - }; - - const { urn, entityType } = useEntityData(); - - const onSave = async (record: any) => { - const row = await form.validateFields(); - - const updatedInstitutionalMemory = stagedDocs.map((doc, index) => { - if (record.key === index) { - return { - url: row.url, - description: row.description, - author: doc.author.urn, - createdAt: doc.created.time, - }; - } - return { - author: doc.author.urn, - url: doc.url, - description: doc.description, - createdAt: doc.created.time, - }; - }); - updateDocumentation({ elements: updatedInstitutionalMemory }); - analytics.event({ - type: EventType.EntityActionEvent, - actionType: EntityActionType.UpdateDescription, - entityType, - entityUrn: urn, - }); - setEditingIndex(-1); - }; - - const onCancel = () => { - const newStagedDocs = stagedDocs.filter((_, index) => index !== editingIndex); - setStagedDocs(newStagedDocs); - setEditingIndex(-1); - }; - - const onDelete = (index: number) => { - const newDocs = stagedDocs.filter((_, i) => !(index === i)); - const updatedInstitutionalMemory = newDocs.map((doc) => ({ - author: doc.author.urn, - url: doc.url, - description: doc.description, - })); - updateDocumentation({ elements: updatedInstitutionalMemory }); - analytics.event({ - type: EventType.EntityActionEvent, - actionType: EntityActionType.UpdateDescription, - entityType, - entityUrn: urn, - }); - setStagedDocs(newDocs); - }; - - const tableColumns = [ - { - title: 'Document', - dataIndex: 'description', - render: (description: string, record: any) => { - return isEditing(record) ? ( - - - - - ) : ( - - {description} - - ); - }, - }, - { - title: 'Author', - dataIndex: 'author', - render: (user: CorpUser) => ( - {user.username} - ), - }, - { - title: 'Date Added', - dataIndex: 'createdAt', - render: (createdAt: number) => formatDateString(createdAt), - }, - { - title: '', - key: 'action', - render: (_: string, record: any) => { - return isEditing(record) ? ( - - - - - ) : ( - - ); - }, - }, - ]; - - return ( - - Documentation - Keep track of documentation about this Dataset. -
- - - {authenticatedUserUrn && authenticatedUserUsername && editingIndex < 0 && ( - - )} - - ); -} diff --git a/datahub-web-react/src/app/entity/dataset/profile/__tests__/Documentation.test.tsx b/datahub-web-react/src/app/entity/dataset/profile/__tests__/Documentation.test.tsx deleted file mode 100644 index 6e15a7a7a8703c..00000000000000 --- a/datahub-web-react/src/app/entity/dataset/profile/__tests__/Documentation.test.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import Documentation from '../Documentation'; -import { sampleDocs } from '../stories/documentation'; -import TestPageContainer from '../../../../../utils/test-utils/TestPageContainer'; - -describe('Documentation', () => { - it('renders', async () => { - const { getByText } = render( - - undefined} - /> - , - , - ); - expect(getByText('Documentation')).toBeInTheDocument(); - expect(getByText('1')).toBeInTheDocument(); - expect(getByText('This doc spans the internet web')).toBeInTheDocument(); - expect(getByText('This doc spans the internet web').closest('a')).toHaveAttribute( - 'href', - 'https://www.google.com', - ); - expect(getByText('This doc spans the internet web')).toBeInTheDocument(); - expect(getByText('Add a link')).toBeInTheDocument(); - }); -}); diff --git a/datahub-web-react/src/app/entity/group/GroupMembersSideBarSection.tsx b/datahub-web-react/src/app/entity/group/GroupMembersSideBarSection.tsx index 173f191042bf64..24dc208049c374 100644 --- a/datahub-web-react/src/app/entity/group/GroupMembersSideBarSection.tsx +++ b/datahub-web-react/src/app/entity/group/GroupMembersSideBarSection.tsx @@ -47,7 +47,7 @@ export default function GroupMembersSideBarSection({ total, relationships, onSee const name = entityRegistry.getDisplayName(EntityType.CorpUser, user); return ( - + { return ( - + {(!popOver && <>{name}) || ( diff --git a/datahub-web-react/src/app/entity/shared/components/styled/ExpandedOwner.tsx b/datahub-web-react/src/app/entity/shared/components/styled/ExpandedOwner.tsx index 2f82db0ee111bd..deb1e25067a94a 100644 --- a/datahub-web-react/src/app/entity/shared/components/styled/ExpandedOwner.tsx +++ b/datahub-web-react/src/app/entity/shared/components/styled/ExpandedOwner.tsx @@ -10,7 +10,6 @@ import { useEntityRegistry } from '../../../../useEntityRegistry'; import analytics, { EventType, EntityActionType } from '../../../../analytics'; import { useEntityData } from '../../EntityContext'; import { getDescriptionFromType, getNameFromType } from '../../containers/profile/sidebar/Ownership/ownershipUtils'; -import { urlEncodeUrn } from '../../utils'; type Props = { entityUrn?: string; @@ -89,7 +88,7 @@ export const ExpandedOwner = ({ entityUrn, owner, hidePopOver, refetch }: Props) return ( - + {(hidePopOver && <>{name}) || ( { <> Added {formatDateString(link.created.time)} by{' '} {link.author.username} diff --git a/datahub-web-react/src/app/glossary/GlossaryBrowser/NodeItem.tsx b/datahub-web-react/src/app/glossary/GlossaryBrowser/NodeItem.tsx index f1af3f20b44a81..0606ca24f92e4a 100644 --- a/datahub-web-react/src/app/glossary/GlossaryBrowser/NodeItem.tsx +++ b/datahub-web-react/src/app/glossary/GlossaryBrowser/NodeItem.tsx @@ -123,7 +123,7 @@ function NodeItem(props: Props) { {areChildrenVisible && setAreChildrenVisible(false)} />} {!isSelecting && ( diff --git a/datahub-web-react/src/app/glossary/GlossaryBrowser/TermItem.tsx b/datahub-web-react/src/app/glossary/GlossaryBrowser/TermItem.tsx index 6386020ad8396d..81c65dfb54ef73 100644 --- a/datahub-web-react/src/app/glossary/GlossaryBrowser/TermItem.tsx +++ b/datahub-web-react/src/app/glossary/GlossaryBrowser/TermItem.tsx @@ -68,7 +68,7 @@ function TermItem(props: Props) { {!isSelecting && ( {entityRegistry.getDisplayName(term.type, isOnEntityPage ? entityData : term)} diff --git a/datahub-web-react/src/app/glossary/GlossaryEntitiesPath.tsx b/datahub-web-react/src/app/glossary/GlossaryEntitiesPath.tsx index 2afb077aa96bf2..f5b9933154709a 100644 --- a/datahub-web-react/src/app/glossary/GlossaryEntitiesPath.tsx +++ b/datahub-web-react/src/app/glossary/GlossaryEntitiesPath.tsx @@ -43,7 +43,7 @@ function GlossaryEntitiesPath() { breadcrumbs.map((node) => { return ( - + {entityRegistry.getDisplayName(node.type, node)} diff --git a/datahub-web-react/src/app/glossary/GlossaryEntityItem.tsx b/datahub-web-react/src/app/glossary/GlossaryEntityItem.tsx index e8bbfbacf616a5..5e2ed055eceb57 100644 --- a/datahub-web-react/src/app/glossary/GlossaryEntityItem.tsx +++ b/datahub-web-react/src/app/glossary/GlossaryEntityItem.tsx @@ -58,7 +58,7 @@ function GlossaryEntityItem(props: Props) { const entityRegistry = useEntityRegistry(); return ( - + diff --git a/datahub-web-react/src/app/glossary/GlossarySearch.tsx b/datahub-web-react/src/app/glossary/GlossarySearch.tsx index 2fa1a1d9c4e7cb..75cd3b10d581e8 100644 --- a/datahub-web-react/src/app/glossary/GlossarySearch.tsx +++ b/datahub-web-react/src/app/glossary/GlossarySearch.tsx @@ -89,7 +89,7 @@ function GlossarySearch() { {searchResults.map((result) => { return ( setIsSearchBarFocused(false)} > diff --git a/datahub-web-react/src/app/permissions/policy/PolicyDetailsModal.tsx b/datahub-web-react/src/app/permissions/policy/PolicyDetailsModal.tsx index f8e841e3153513..3b5fc03f10a15b 100644 --- a/datahub-web-react/src/app/permissions/policy/PolicyDetailsModal.tsx +++ b/datahub-web-react/src/app/permissions/policy/PolicyDetailsModal.tsx @@ -94,7 +94,7 @@ export default function PolicyDetailsModal({ policy, visible, onClose, privilege `/${entityRegistry.getPathName(criterionValue.entity!.type)}/${criterionValue.value}`} + to={() => `${entityRegistry.getEntityUrl(criterionValue.entity!.type, criterionValue.value)}`} > {getDisplayName(criterionValue.entity)} diff --git a/datahub-web-react/src/app/permissions/policy/PolicyPrivilegeForm.tsx b/datahub-web-react/src/app/permissions/policy/PolicyPrivilegeForm.tsx index 918c310108dd45..5594b161385178 100644 --- a/datahub-web-react/src/app/permissions/policy/PolicyPrivilegeForm.tsx +++ b/datahub-web-react/src/app/permissions/policy/PolicyPrivilegeForm.tsx @@ -262,7 +262,7 @@ export default function PolicyPrivilegeForm({ `/${entityRegistry.getPathName(result.entity.type)}/${result.entity.urn}`} + to={() => `${entityRegistry.getEntityUrl(result.entity.type, result.entity.urn)}`} > View