diff --git a/src/components/icon-font/index.tsx b/src/components/icon-font/index.tsx
index 61a42720..c3d89719 100644
--- a/src/components/icon-font/index.tsx
+++ b/src/components/icon-font/index.tsx
@@ -2,7 +2,7 @@ import { createFromIconfontCN } from '@ant-design/icons';
// import './iconfont/iconfont.js';
const IconFont = createFromIconfontCN({
- scriptUrl: '//at.alicdn.com/t/c/font_4613488_qgb5xlexehp.js'
+ scriptUrl: '//at.alicdn.com/t/c/font_4613488_pouhrqmodr9.js'
});
export default IconFont;
diff --git a/src/pages/cluster-management/clusters.tsx b/src/pages/cluster-management/clusters.tsx
index 7a384cb5..1a5057a9 100644
--- a/src/pages/cluster-management/clusters.tsx
+++ b/src/pages/cluster-management/clusters.tsx
@@ -2,6 +2,7 @@ import AutoTooltip from '@/components/auto-tooltip';
import DeleteModal from '@/components/delete-modal';
import DropDownActions from '@/components/drop-down-actions';
import DropdownButtons from '@/components/drop-down-buttons';
+import IconFont from '@/components/icon-font';
import PageTools from '@/components/page-tools';
import { PageAction } from '@/config';
import type { PageActionType } from '@/config/types';
@@ -13,7 +14,6 @@ import {
EditOutlined,
KubernetesOutlined,
ProfileOutlined,
- SnippetsOutlined,
SyncOutlined
} from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-components';
@@ -36,6 +36,7 @@ import {
updateCredential
} from './apis';
import AddCluster from './components/add-cluster';
+import AddPool from './components/add-pool';
import { ClusterDataList } from './config';
import {
ClusterFormData as FormData,
@@ -49,14 +50,21 @@ const addActions = [
locale: false,
value: 'custom',
key: 'custom',
- icon:
+ icon:
},
{
label: 'Kubernetes',
locale: false,
value: 'kubernetes',
key: 'kubernetes',
- icon:
+ icon:
+ },
+ {
+ label: 'Digital Ocean',
+ locale: false,
+ value: 'digitalocean',
+ key: 'digitalocean',
+ icon:
}
];
@@ -105,11 +113,18 @@ const ActionList = [
locale: false,
icon:
},
+
{
key: 'terminal',
label: 'common.button.detail',
icon:
},
+ {
+ key: 'addPool',
+ label: 'Add Node Pool',
+ locale: false,
+ icon:
+ },
{
key: 'delete',
props: {
@@ -143,23 +158,50 @@ const Credentials: React.FC = () => {
const intl = useIntl();
const [open, setOpen] = useState(false);
const [openAddModal, setOpenAddModal] = useState(false);
- const [clusterType, setClusterType] = useState('custom');
+ const [provider, setProvider] = useState('custom');
const [action, setAction] = useState(PageAction.CREATE);
const [title, setTitle] = useState('');
+ const [addPoolStatus, setAddPoolStatus] = useState<{
+ open: boolean;
+ action: PageActionType;
+ title: string;
+ provider: string;
+ }>({
+ open: false,
+ action: PageAction.CREATE,
+ title: '',
+ provider: 'digitalocean'
+ });
const [currentData, setCurrentData] = useState(
undefined
);
- const handleAddUser = (value: string) => {
+ const setActions = (row: ListItem) => {
+ if (row.provider !== 'custom') {
+ return ActionList.filter((item) => item.key !== 'add');
+ }
+ return ActionList;
+ };
+
+ const handleAddCluster = (value: string) => {
setOpenAddModal(true);
setAction(PageAction.CREATE);
- setClusterType(value);
- setTitle('Add Cluster');
+ setProvider(value);
+ const label = addActions.find((item) => item.value === value)?.label;
+ setTitle(`Add ${label} Cluster`);
+ };
+
+ const handleAddPool = (value: string) => {
+ setAddPoolStatus({
+ open: true,
+ action: PageAction.CREATE,
+ title: `Add Node Pool`,
+ provider: value
+ });
};
const handleClickDropdown = (item: any) => {
- console.log('handleClickDropdown', item);
- handleAddUser(item.key);
+ handleAddCluster(item.key);
};
const handleModalOk = async (data: FormData) => {
@@ -194,7 +236,7 @@ const Credentials: React.FC = () => {
setCurrentData(row);
setOpenAddModal(true);
setAction(PageAction.EDIT);
- setTitle('Edit Cluster');
+ setTitle(`Edit ${row.name} Cluster`);
};
const handleSelect = (val: any, row: ListItem) => {
@@ -205,6 +247,8 @@ const Credentials: React.FC = () => {
} else if (val === 'add') {
setOpen(true);
setCurrentData(row);
+ } else if (val === 'addPool') {
+ handleAddPool(row.provider);
}
};
@@ -260,7 +304,7 @@ const Credentials: React.FC = () => {
items: addActions,
onClick: handleClickDropdown
}}
- trigger={['hover']}
+ trigger={['click']}
placement="bottomRight"
>