Skip to content

Commit

Permalink
fix(ui): replace ant dropdown overlay with menu (#11229)
Browse files Browse the repository at this point in the history
Co-authored-by: salman <[email protected]>
  • Loading branch information
sakethvarma397 and Salman-Apptware authored Aug 27, 2024
1 parent 56a563b commit 12eb225
Show file tree
Hide file tree
Showing 33 changed files with 774 additions and 685 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { DeleteOutlined } from '@ant-design/icons';
import { Dropdown, Menu, message, Modal } from 'antd';
import { Dropdown, message, Modal } from 'antd';
import { MenuIcon } from '../entity/shared/EntityDropdown/EntityDropdown';
import { useDeleteBusinessAttributeMutation } from '../../graphql/businessAttribute.generated';
import { MenuItemStyle } from '../entity/view/menu/item/styledComponent';

type Props = {
urn: string;
Expand Down Expand Up @@ -48,17 +49,19 @@ export default function BusinessAttributeItemMenu({ title, urn, onDelete }: Prop
});
};

const items = [
{
key: 'delete',
label: (
<MenuItemStyle onClick={onConfirmDelete}>
<DeleteOutlined /> &nbsp;Delete
</MenuItemStyle>
),
},
];

return (
<Dropdown
trigger={['click']}
overlay={
<Menu>
<Menu.Item onClick={onConfirmDelete} key="delete">
<DeleteOutlined /> &nbsp;Delete
</Menu.Item>
</Menu>
}
>
<Dropdown trigger={['click']} menu={{ items }}>
<MenuIcon data-testid={`dropdown-menu-${urn}`} fontSize={20} />
</Dropdown>
);
Expand Down
22 changes: 12 additions & 10 deletions datahub-web-react/src/app/domain/DomainItemMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,19 @@ export default function DomainItemMenu({ name, urn, onDelete }: Props) {
});
};

const items = [
{
key: 0,
label: (
<Menu.Item onClick={onConfirmDelete} key="delete">
<DeleteOutlined /> &nbsp;Delete
</Menu.Item>
),
},
];

return (
<Dropdown
trigger={['click']}
overlay={
<Menu>
<Menu.Item onClick={onConfirmDelete} key="delete">
<DeleteOutlined /> &nbsp;Delete
</Menu.Item>
</Menu>
}
>
<Dropdown trigger={['click']} menu={{ items }}>
<MenuIcon data-testid={`dropdown-menu-${urn}`} fontSize={20} />
</Dropdown>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useState } from 'react';
import { Button, Menu, Dropdown, Typography } from 'antd';
import { Button, Dropdown, Typography } from 'antd';
import { LeftOutlined, RightOutlined } from '@ant-design/icons';
import styled from 'styled-components';
import { MenuItemStyle } from '../../../../view/menu/item/styledComponent';

const CustomPaginationContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -60,27 +61,29 @@ export default function CustomPagination({ onChange, maxVersion }: Props) {
onChange(version1, parseInt(key, 10));
};

const menu1 = (
<Menu onClick={onVersion1Click} selectedKeys={[`${version1}`]}>
{[...Array(maxVersion)].map((_, i) => (
// eslint-disable-next-line react/no-array-index-key
<Menu.Item key={maxVersion - i}>
const items1 = [...Array(maxVersion)].map((_, i) => {
// eslint-disable-next-line react/no-array-index-key
return {
key: maxVersion - i,
label: (
<MenuItemStyle onClick={() => onVersion1Click({ key: maxVersion - i })}>
<Typography.Text>{i === 0 ? 'latest' : `version ${maxVersion + 1 - i}`}</Typography.Text>
</Menu.Item>
))}
</Menu>
);
</MenuItemStyle>
),
};
});

const menu2 = (
<Menu onClick={onVersion2Click} selectedKeys={[`${version2}`]}>
{[...Array(version1)].map((_, i) => (
// eslint-disable-next-line react/no-array-index-key
<Menu.Item key={version1 - i - 1}>
const items2 = [...Array(version1)].map((_, i) => {
// eslint-disable-next-line react/no-array-index-key
return {
key: version1 - i - 1,
label: (
<MenuItemStyle onClick={() => onVersion2Click({ key: version1 - i - 1 })}>
<Typography.Text>{`version ${version1 - i}`}</Typography.Text>
</Menu.Item>
))}
</Menu>
);
</MenuItemStyle>
),
};
});

return (
<CustomPaginationContainer>
Expand All @@ -92,13 +95,13 @@ export default function CustomPagination({ onChange, maxVersion }: Props) {
disabled={version1 >= maxVersion}
/>
<DescriptionText>Comparing</DescriptionText>
<Dropdown overlay={menu1} trigger={['click']}>
<Dropdown menu={{ items: items1 }} trigger={['click']}>
<VersionText strong type="success">
{version1 === maxVersion ? 'latest' : `version ${version1 + 1}`}
</VersionText>
</Dropdown>
<DescriptionText>to</DescriptionText>
<Dropdown overlay={menu2} trigger={['click']}>
<Dropdown menu={{ items: items2 }} trigger={['click']}>
<VersionRightText strong type="success">{`version ${version2 + 1}`}</VersionRightText>
</Dropdown>
<NavButton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeleteOutlined, MoreOutlined } from '@ant-design/icons';
import { Divider, Dropdown, Menu } from 'antd';
import { Divider, Dropdown } from 'antd';
import React from 'react';
import styled from 'styled-components/macro';
import { useGetGlossaryTermQuery } from '../../../../graphql/glossaryTerm.generated';
Expand Down Expand Up @@ -51,23 +51,23 @@ function RelatedTerm(props: Props) {

if (loading) return null;

const items = [
{
key: '0',
label: (
<MenuItem onClick={onRemove}>
<DeleteOutlined /> &nbsp; Remove Term
</MenuItem>
),
},
];

return (
<ListItem>
<Profile>
{entityRegistry.renderPreview(EntityType.GlossaryTerm, PreviewType.PREVIEW, data?.glossaryTerm)}
{isEditable && (
<Dropdown
overlay={
<Menu>
<Menu.Item key="0">
<MenuItem onClick={onRemove}>
<DeleteOutlined /> &nbsp; Remove Term
</MenuItem>
</Menu.Item>
</Menu>
}
trigger={['click']}
>
<Dropdown menu={{ items }} trigger={['click']}>
<MenuIcon />
</Dropdown>
)}
Expand Down
Loading

0 comments on commit 12eb225

Please sign in to comment.