Browse Source

fix release dialog bug

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 1 year ago
parent
commit
57ea82c0d0

+ 2 - 4
client/src/pages/collections/Collections.tsx

@@ -176,7 +176,7 @@ const Collections = () => {
           params: {
           params: {
             component: (
             component: (
               <ReleaseCollectionDialog
               <ReleaseCollectionDialog
-                collection={selectedCollections[0].collection_name}
+                collection={selectedCollections[0]}
                 onRelease={async () => {
                 onRelease={async () => {
                   setSelectedCollections([]);
                   setSelectedCollections([]);
                 }}
                 }}
@@ -379,9 +379,7 @@ const Collections = () => {
                         collectionName={v.collection_name}
                         collectionName={v.collection_name}
                       />
                       />
                     ) : (
                     ) : (
-                      <ReleaseCollectionDialog
-                        collectionName={v.collection_name}
-                      />
+                      <ReleaseCollectionDialog collection={v} />
                     ),
                     ),
                 },
                 },
               });
               });

+ 27 - 25
client/src/pages/dialogs/LoadCollectionDialog.tsx

@@ -58,31 +58,33 @@ const LoadCollectionDialog = (props: any) => {
   // check if it is cluster
   // check if it is cluster
   useEffect(() => {
   useEffect(() => {
     async function fetchData() {
     async function fetchData() {
-      const res = await MilvusService.getMetrics();
-      const parsedJson = parseJson(res);
-      // get root cord
-      const rootCoords = getNode(
-        parsedJson.workingNodes,
-        MILVUS_NODE_TYPE.ROOTCOORD
-      );
-      // get query nodes
-      const queryNodes = getNode(
-        parsedJson.workingNodes,
-        MILVUS_NODE_TYPE.QUERYNODE
-      );
-
-      const rootCoord = rootCoords[0];
-
-      // should we show replic toggle
-      const enableRelica =
-        rootCoord.infos.system_info.deploy_mode ===
-        MILVUS_DEPLOY_MODE.DISTRIBUTED;
-
-      // only show replica toggle in distributed mode && query node > 1
-      if (enableRelica && queryNodes.length > 1 && !isManaged) {
-        setMaxQueryNode(queryNodes.length);
-        setEnableRelica(enableRelica);
-      }
+      try {
+        const res = await MilvusService.getMetrics();
+        const parsedJson = parseJson(res);
+        // get root cord
+        const rootCoords = getNode(
+          parsedJson.workingNodes,
+          MILVUS_NODE_TYPE.ROOTCOORD
+        );
+        // get query nodes
+        const queryNodes = getNode(
+          parsedJson.workingNodes,
+          MILVUS_NODE_TYPE.QUERYNODE
+        );
+
+        const rootCoord = rootCoords[0];
+
+        // should we show replic toggle
+        const enableRelica =
+          rootCoord.infos.system_info.deploy_mode ===
+          MILVUS_DEPLOY_MODE.DISTRIBUTED;
+
+        // only show replica toggle in distributed mode && query node > 1
+        if (enableRelica && queryNodes.length > 1 && !isManaged) {
+          setMaxQueryNode(queryNodes.length);
+          setEnableRelica(enableRelica);
+        }
+      } catch (error) {}
     }
     }
     fetchData();
     fetchData();
   }, []);
   }, []);

+ 12 - 6
client/src/pages/dialogs/ReleaseCollectionDialog.tsx

@@ -3,6 +3,7 @@ import { Typography, makeStyles, Theme } from '@material-ui/core';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import DialogTemplate from '@/components/customDialog/DialogTemplate';
 import DialogTemplate from '@/components/customDialog/DialogTemplate';
 import { rootContext, dataContext } from '@/context';
 import { rootContext, dataContext } from '@/context';
+import { CollectionObject } from '@server/types';
 
 
 const useStyles = makeStyles((theme: Theme) => ({
 const useStyles = makeStyles((theme: Theme) => ({
   desc: {
   desc: {
@@ -11,12 +12,15 @@ const useStyles = makeStyles((theme: Theme) => ({
   },
   },
 }));
 }));
 
 
-const ReleaseCollectionDialog = (props: any) => {
+const ReleaseCollectionDialog = (props: {
+  collection: CollectionObject;
+  onRelease?: (collection: CollectionObject) => void;
+}) => {
   const { releaseCollection } = useContext(dataContext);
   const { releaseCollection } = useContext(dataContext);
 
 
   const classes = useStyles();
   const classes = useStyles();
 
 
-  const { collectionName, onRelease } = props;
+  const { collection, onRelease } = props;
   const { t: dialogTrans } = useTranslation('dialog');
   const { t: dialogTrans } = useTranslation('dialog');
   const { t: btnTrans } = useTranslation('btn');
   const { t: btnTrans } = useTranslation('btn');
   const { t: successTrans } = useTranslation('success');
   const { t: successTrans } = useTranslation('success');
@@ -30,7 +34,7 @@ const ReleaseCollectionDialog = (props: any) => {
     setDisabled(true);
     setDisabled(true);
     try {
     try {
       // release collection
       // release collection
-      await releaseCollection(collectionName);
+      await releaseCollection(collection.collection_name);
 
 
       // show success message
       // show success message
       openSnackBar(
       openSnackBar(
@@ -40,7 +44,7 @@ const ReleaseCollectionDialog = (props: any) => {
       );
       );
 
 
       // execute callback
       // execute callback
-      onRelease && (await onRelease(collectionName));
+      onRelease && (await onRelease(collection));
       // enable confirm button
       // enable confirm button
       setDisabled(false);
       setDisabled(false);
       // close dialog
       // close dialog
@@ -54,13 +58,15 @@ const ReleaseCollectionDialog = (props: any) => {
   return (
   return (
     <DialogTemplate
     <DialogTemplate
       title={dialogTrans('releaseTitle', {
       title={dialogTrans('releaseTitle', {
-        type: collectionName,
+        type: collection.collection_name,
       })}
       })}
       handleClose={handleCloseDialog}
       handleClose={handleCloseDialog}
       children={
       children={
         <>
         <>
           <Typography variant="body1" component="p" className={classes.desc}>
           <Typography variant="body1" component="p" className={classes.desc}>
-            {dialogTrans('releaseContent', { type: collectionName })}
+            {dialogTrans('releaseContent', {
+              type: collection.collection_name,
+            })}
           </Typography>
           </Typography>
         </>
         </>
       }
       }