This is an automated email from the ASF dual-hosted git repository.

dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new bce23302b [INLONG-4997][Dashboard] Support cluster tag bind and unbind 
(#4999)
bce23302b is described below

commit bce23302bcbee8fbd7b107ba0a72e6f14b809649
Author: Daniel <[email protected]>
AuthorDate: Tue Jul 12 11:49:36 2022 +0800

    [INLONG-4997][Dashboard] Support cluster tag bind and unbind (#4999)
---
 inlong-dashboard/src/locales/cn.json               |  4 +++-
 inlong-dashboard/src/locales/en.json               |  4 +++-
 .../src/pages/ClusterTags/ClusterBindModal.tsx     | 15 ++++++------
 .../src/pages/ClusterTags/ClusterList.tsx          | 27 +++++++++++-----------
 inlong-dashboard/src/pages/ClusterTags/index.tsx   |  2 +-
 5 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/inlong-dashboard/src/locales/cn.json 
b/inlong-dashboard/src/locales/cn.json
index 302e3ef67..fb6f5f307 100644
--- a/inlong-dashboard/src/locales/cn.json
+++ b/inlong-dashboard/src/locales/cn.json
@@ -410,7 +410,9 @@
   "pages.ClusterTags.ModifyTime": "修改时间",
   "pages.ClusterTags.Modifier": "最后修改人",
   "pages.ClusterTags.BindCluster": "绑定集群",
-  "pages.ClusterTags.DelCluster": "移除",
+  "pages.ClusterTags.DelCluster": "解绑",
+  "pages.ClusterTags.DelClusterConfirm": "确定解绑吗?",
+  "pages.ClusterTags.DelClusterSuccess": "解绑成功",
   "pages.ClusterTags.DelConfirm": "删除集群标签,会同时删除关联的集群,且需确保此标签没有被 InlongGroup 
所使用",
   "pages.ClusterTags.NameEditHelp": "修改集群标签,会同时修改关联的集群,且需确保此标签没有被 InlongGroup 
所使用",
   "pages.Datasources.status.Success": "正常",
diff --git a/inlong-dashboard/src/locales/en.json 
b/inlong-dashboard/src/locales/en.json
index c128af2e7..54f3fcbcb 100644
--- a/inlong-dashboard/src/locales/en.json
+++ b/inlong-dashboard/src/locales/en.json
@@ -410,7 +410,9 @@
   "pages.ClusterTags.ModifyTime": "ModifyTime",
   "pages.ClusterTags.Modifier": "Modifier",
   "pages.ClusterTags.BindCluster": "BindCluster",
-  "pages.ClusterTags.DelCluster": "Remove",
+  "pages.ClusterTags.DelCluster": "Unbind",
+  "pages.ClusterTags.DelClusterConfirm": "Are you sure you want to unbind?",
+  "pages.ClusterTags.DelClusterSuccess": "Unbind successfully",
   "pages.ClusterTags.DelConfirm": "Deleting a cluster label will delete the 
associated cluster at the same time, and make sure that this label is not used 
by InlongGroup",
   "pages.ClusterTags.NameEditHelp": "Modifying a cluster label will delete the 
associated cluster at the same time, and make sure that this label is not used 
by InlongGroup",
   "pages.Datasources.status.Success": "Success",
diff --git a/inlong-dashboard/src/pages/ClusterTags/ClusterBindModal.tsx 
b/inlong-dashboard/src/pages/ClusterTags/ClusterBindModal.tsx
index cd190456b..1705b0f11 100644
--- a/inlong-dashboard/src/pages/ClusterTags/ClusterBindModal.tsx
+++ b/inlong-dashboard/src/pages/ClusterTags/ClusterBindModal.tsx
@@ -26,20 +26,20 @@ import i18n from '@/i18n';
 import request from '@/utils/request';
 
 export interface Props extends ModalProps {
-  tagId: number;
+  clusterTag: string;
 }
 
-const Comp: React.FC<Props> = ({ tagId, ...modalProps }) => {
+const Comp: React.FC<Props> = ({ clusterTag, ...modalProps }) => {
   const [form] = useForm();
 
   const onOk = async () => {
     const values = await form.validateFields();
     const submitData = {
-      tagId,
-      ...values,
+      clusterTag,
+      bindClusters: values.clusters,
     };
     await request({
-      url: '/cluster/tag/bind',
+      url: '/cluster/bindTag',
       method: 'POST',
       data: submitData,
     });
@@ -73,15 +73,14 @@ const Comp: React.FC<Props> = ({ tagId, ...modalProps }) => 
{
                 keyword,
                 pageNum: 1,
                 pageSize: 20,
-                type: '',
               },
             }),
             requestParams: {
               formatResult: result =>
                 result?.list?.map(item => ({
                   ...item,
-                  label: item.clusterTag,
-                  value: item.clusterTag,
+                  label: item.name,
+                  value: item.id,
                 })),
             },
           },
diff --git a/inlong-dashboard/src/pages/ClusterTags/ClusterList.tsx 
b/inlong-dashboard/src/pages/ClusterTags/ClusterList.tsx
index 2b20da331..a8135f440 100644
--- a/inlong-dashboard/src/pages/ClusterTags/ClusterList.tsx
+++ b/inlong-dashboard/src/pages/ClusterTags/ClusterList.tsx
@@ -28,7 +28,6 @@ import ClusterBindModal from './ClusterBindModal';
 import request from '@/utils/request';
 
 export interface ClusterListProps {
-  tagId: number;
   clusterTag: string;
 }
 
@@ -58,7 +57,7 @@ const getFilterFormContent = defaultValues => [
   },
 ];
 
-const Comp: React.FC<ClusterListProps> = ({ tagId, clusterTag }) => {
+const Comp: React.FC<ClusterListProps> = ({ clusterTag }) => {
   const [options, setOptions] = useState({
     keyword: '',
     pageSize: defaultSize,
@@ -93,18 +92,22 @@ const Comp: React.FC<ClusterListProps> = ({ tagId, 
clusterTag }) => {
   const onDelete = useCallback(
     ({ id }) => {
       Modal.confirm({
-        title: i18n.t('basic.DeleteConfirm'),
+        title: i18n.t('pages.ClusterTags.DelClusterConfirm'),
         onOk: async () => {
           await request({
-            url: `/cluster/delete/${id}`,
-            method: 'DELETE',
+            url: '/cluster/bindTag',
+            method: 'POST',
+            data: {
+              unbindClusters: [id],
+              clusterTag,
+            },
           });
           await getList();
-          message.success(i18n.t('basic.DeleteSuccess'));
+          message.success(i18n.t('DelClusterSuccess'));
         },
       });
     },
-    [getList],
+    [clusterTag, getList],
   );
 
   const onChange = ({ current: pageNum, pageSize }) => {
@@ -151,7 +154,7 @@ const Comp: React.FC<ClusterListProps> = ({ tagId, 
clusterTag }) => {
         render: (text, record) => (
           <>
             {/* <Button type="link">{i18n.t('basic.Detail')}</Button> */}
-            <Button type="link" onClick={() => onDelete(record)} style={{ 
display: 'none' }}>
+            <Button type="link" onClick={() => onDelete(record)}>
               {i18n.t('pages.ClusterTags.DelCluster')}
             </Button>
           </>
@@ -168,11 +171,7 @@ const Comp: React.FC<ClusterListProps> = ({ tagId, 
clusterTag }) => {
           onFilter,
         }}
         suffix={
-          <Button
-            type="primary"
-            onClick={() => setClusterBindModal({ visible: true })}
-            style={{ display: 'none' }}
-          >
+          <Button type="primary" onClick={() => setClusterBindModal({ visible: 
true })}>
             {i18n.t('pages.ClusterTags.BindCluster')}
           </Button>
         }
@@ -188,7 +187,7 @@ const Comp: React.FC<ClusterListProps> = ({ tagId, 
clusterTag }) => {
 
       <ClusterBindModal
         {...clusterBindModal}
-        tagId={tagId}
+        clusterTag={clusterTag}
         visible={clusterBindModal.visible as boolean}
         onOk={async () => {
           await getList();
diff --git a/inlong-dashboard/src/pages/ClusterTags/index.tsx 
b/inlong-dashboard/src/pages/ClusterTags/index.tsx
index eec066fd8..6ee569b55 100644
--- a/inlong-dashboard/src/pages/ClusterTags/index.tsx
+++ b/inlong-dashboard/src/pages/ClusterTags/index.tsx
@@ -175,7 +175,7 @@ const Comp: React.FC = () => {
           </Card>
 
           <Card>
-            <ClusterList tagId={1} clusterTag={currentTag.clusterTag} />
+            <ClusterList clusterTag={currentTag.clusterTag} />
           </Card>
         </Col>
       </Row>

Reply via email to