forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): sortable domain list (datahub-project#6736)
- Loading branch information
1 parent
1e36ef1
commit e914740
Showing
4 changed files
with
185 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from 'react'; | ||
import { DeleteOutlined } from '@ant-design/icons'; | ||
import { Dropdown, Menu, message, Modal } from 'antd'; | ||
import { EntityType } from '../../types.generated'; | ||
import { useEntityRegistry } from '../useEntityRegistry'; | ||
import { useDeleteDomainMutation } from '../../graphql/domain.generated'; | ||
import { MenuIcon } from '../entity/shared/EntityDropdown/EntityDropdown'; | ||
|
||
type Props = { | ||
urn: string; | ||
name: string; | ||
onDelete?: () => void; | ||
}; | ||
|
||
export default function DomainItemMenu({ name, urn, onDelete }: Props) { | ||
const entityRegistry = useEntityRegistry(); | ||
const [deleteDomainMutation] = useDeleteDomainMutation(); | ||
|
||
const deleteDomain = () => { | ||
deleteDomainMutation({ | ||
variables: { | ||
urn, | ||
}, | ||
}) | ||
.then(({ errors }) => { | ||
if (!errors) { | ||
message.success('Deleted Domain!'); | ||
onDelete?.(); | ||
} | ||
}) | ||
.catch(() => { | ||
message.destroy(); | ||
message.error({ content: `Failed to delete Domain!: An unknown error occurred.`, duration: 3 }); | ||
}); | ||
}; | ||
|
||
const onConfirmDelete = () => { | ||
Modal.confirm({ | ||
title: `Delete Domain '${name}'`, | ||
content: `Are you sure you want to remove this ${entityRegistry.getEntityName(EntityType.Domain)}?`, | ||
onOk() { | ||
deleteDomain(); | ||
}, | ||
onCancel() {}, | ||
okText: 'Yes', | ||
maskClosable: true, | ||
closable: true, | ||
}); | ||
}; | ||
|
||
return ( | ||
<Dropdown | ||
trigger={['click']} | ||
overlay={ | ||
<Menu> | ||
<Menu.Item onClick={onConfirmDelete} key="delete"> | ||
<DeleteOutlined /> Delete | ||
</Menu.Item> | ||
</Menu> | ||
} | ||
> | ||
<MenuIcon fontSize={20} /> | ||
</Dropdown> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from 'react'; | ||
import { Tag, Tooltip, Typography } from 'antd'; | ||
import { Link } from 'react-router-dom'; | ||
import styled from 'styled-components'; | ||
import { Maybe, Ownership } from '../../types.generated'; | ||
import { useEntityRegistry } from '../useEntityRegistry'; | ||
import AvatarsGroup from '../shared/avatar/AvatarsGroup'; | ||
import DomainItemMenu from './DomainItemMenu'; | ||
|
||
interface DomainEntry { | ||
name: string; | ||
entities: string; | ||
urn: string; | ||
ownership?: Maybe<Ownership>; | ||
url: string; | ||
} | ||
|
||
const AvatarGroupWrapper = styled.div` | ||
margin-right: 10px; | ||
display: inline-block; | ||
`; | ||
|
||
const DomainNameContainer = styled.div` | ||
margin-left: 16px; | ||
margin-right: 16px; | ||
display: inline; | ||
`; | ||
|
||
export function DomainListMenuColumn(handleDelete: (urn: string) => void) { | ||
return (record: DomainEntry) => ( | ||
<DomainItemMenu name={record.name} urn={record.urn} onDelete={() => handleDelete(record.urn)} /> | ||
); | ||
} | ||
|
||
export function DomainNameColumn(logoIcon: JSX.Element) { | ||
return (record: DomainEntry) => ( | ||
<Link to={record.url}> | ||
{logoIcon} | ||
<DomainNameContainer> | ||
<Typography.Text>{record.name}</Typography.Text> | ||
</DomainNameContainer> | ||
<Tooltip title={`There are ${record.entities} entities in this domain.`}> | ||
<Tag>{record.entities} entities</Tag> | ||
</Tooltip> | ||
</Link> | ||
); | ||
} | ||
|
||
export function DomainOwnersColumn(ownership: Maybe<Ownership>) { | ||
const entityRegistry = useEntityRegistry(); | ||
|
||
if (!ownership) { | ||
return null; | ||
} | ||
|
||
const { owners } = ownership; | ||
if (!owners || owners.length === 0) { | ||
return null; | ||
} | ||
return ( | ||
<AvatarGroupWrapper> | ||
<AvatarsGroup size={24} owners={owners} entityRegistry={entityRegistry} maxCount={4} /> | ||
</AvatarGroupWrapper> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters