Skip to content

Commit

Permalink
fix Dropdown menu click
Browse files Browse the repository at this point in the history
  • Loading branch information
TianWuwt committed Jan 6, 2025
1 parent 4d8b155 commit e782e60
Showing 1 changed file with 43 additions and 23 deletions.
66 changes: 43 additions & 23 deletions ui/src/pages/Cluster/Detail/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Dropdown,
Form,
Input,
Menu,
MenuProps,
Row,
Select,
Expand Down Expand Up @@ -171,12 +172,33 @@ const ClusterOverview: React.FC = () => {
// 不为空即为绑定了NFS
const removeNFS = !!clusterDetail?.info?.backupVolume;

const menuChange = ({ key }) => {
if (key === 'AddZone') {
return handleAddZone();
} else if (key === 'Upgrade') {
return handleUpgrade();
} else if (key === 'delete') {
return showDeleteConfirm({
onOk: handleDelete,
title: intl.formatMessage({
id: 'OBDashboard.Detail.Overview.AreYouSureYouWant',
defaultMessage: '你确定要删除该集群吗?',
}),
});
} else if (key === 'nfs') {
if (removeNFS) {
setRemoveNFSModal(true);
} else {
setMountNFSModal(true);
}
}
};

const items: MenuProps['items'] = [
{
key: '1',
key: 'AddZone',
label: (
<Button
onClick={handleAddZone}
disabled={
!isEmpty(clusterDetail) && clusterDetail?.status !== 'running'
}
Expand All @@ -190,14 +212,13 @@ const ClusterOverview: React.FC = () => {
),
},
{
key: '2',
key: 'Upgrade',
label: (
<Button
type="text"
disabled={
!isEmpty(clusterDetail) && clusterDetail?.status !== 'running'
}
onClick={handleUpgrade}
>
{intl.formatMessage({
id: 'OBDashboard.Detail.Overview.Upgrade',
Expand All @@ -207,23 +228,14 @@ const ClusterOverview: React.FC = () => {
),
},
{
key: '3',
key: 'delete',
label: (
<Button
type="text"
disabled={
!isEmpty(clusterDetail) &&
(clusterDetail?.status === 'deleting' || deletionProtection)
}
onClick={() =>
showDeleteConfirm({
onOk: handleDelete,
title: intl.formatMessage({
id: 'OBDashboard.Detail.Overview.AreYouSureYouWant',
defaultMessage: '你确定要删除该集群吗?',
}),
})
}
danger
>
{intl.formatMessage({
Expand All @@ -234,7 +246,7 @@ const ClusterOverview: React.FC = () => {
),
},
{
key: '4',
key: 'nfs',
label: (
<Button
type="text"
Expand All @@ -243,13 +255,6 @@ const ClusterOverview: React.FC = () => {
(clusterDetail?.status !== 'running' ||
!clusterDetail?.supportStaticIP)
}
onClick={() => {
if (removeNFS) {
setRemoveNFSModal(true);
} else {
setMountNFSModal(true);
}
}}
>
{removeNFS
? intl.formatMessage({
Expand All @@ -273,7 +278,22 @@ const ClusterOverview: React.FC = () => {
}),
extra: access.obclusterwrite
? [
<Dropdown menu={{ items }} placement="bottomRight">
<Dropdown
overlayStyle={{ marginRight: 24 }}
placement="bottomRight"
overlay={
<Menu>
{items.map((item) => (
<Menu.Item
key={`${item.key}`}
onClick={() => menuChange(item)}
>
{item.label}
</Menu.Item>
))}
</Menu>
}
>
<Button>
{intl.formatMessage({
id: 'src.pages.Cluster.Detail.Overview.A0A43F50',
Expand Down

0 comments on commit e782e60

Please sign in to comment.