Browse Source

hide

Signed-off-by: shanghaikid <jiangruiyi@gmail.com>
shanghaikid 2 years ago
parent
commit
c97e28b685

+ 10 - 1
client/src/context/Auth.tsx

@@ -6,6 +6,7 @@ import { AuthContextType } from './Types';
 export const authContext = createContext<AuthContextType>({
 export const authContext = createContext<AuthContextType>({
   isAuth: false,
   isAuth: false,
   address: '',
   address: '',
+  isManaged: false,
   setAddress: () => {},
   setAddress: () => {},
   setIsAuth: () => {},
   setIsAuth: () => {},
 });
 });
@@ -46,7 +47,15 @@ export const AuthProvider = (props: { children: React.ReactNode }) => {
   }, [address]);
   }, [address]);
 
 
   return (
   return (
-    <Provider value={{ isAuth, address, setAddress, setIsAuth }}>
+    <Provider
+      value={{
+        isAuth,
+        address,
+        setAddress,
+        setIsAuth,
+        isManaged: address.includes('vectordb.zillizcloud.com'),
+      }}
+    >
       {props.children}
       {props.children}
     </Provider>
     </Provider>
   );
   );

+ 1 - 0
client/src/context/Types.ts

@@ -57,6 +57,7 @@ export type OpenSnackBarType = (
 export type AuthContextType = {
 export type AuthContextType = {
   isAuth: boolean;
   isAuth: boolean;
   address: string;
   address: string;
+  isManaged: boolean;
   setAddress: Dispatch<SetStateAction<string>>;
   setAddress: Dispatch<SetStateAction<string>>;
   setIsAuth: Dispatch<SetStateAction<boolean>>;
   setIsAuth: Dispatch<SetStateAction<boolean>>;
 };
 };

+ 8 - 1
client/src/pages/collections/Collection.tsx

@@ -1,7 +1,8 @@
-import { useMemo } from 'react';
+import { useMemo, useContext } from 'react';
 import { useNavigate, useLocation, useParams } from 'react-router-dom';
 import { useNavigate, useLocation, useParams } from 'react-router-dom';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import { makeStyles, Theme } from '@material-ui/core';
 import { makeStyles, Theme } from '@material-ui/core';
+import { authContext } from '../../context/Auth';
 import { useNavigationHook } from '../../hooks/Navigation';
 import { useNavigationHook } from '../../hooks/Navigation';
 import { ALL_ROUTER_TYPES } from '../../router/Types';
 import { ALL_ROUTER_TYPES } from '../../router/Types';
 import CustomTabList from '../../components/customTabList/CustomTabList';
 import CustomTabList from '../../components/customTabList/CustomTabList';
@@ -34,6 +35,7 @@ const useStyles = makeStyles((theme: Theme) => ({
 
 
 const Collection = () => {
 const Collection = () => {
   const classes = useStyles();
   const classes = useStyles();
+  const { isManaged } = useContext(authContext);
 
 
   const { collectionName = '' } = useParams<{
   const { collectionName = '' } = useParams<{
     collectionName: string;
     collectionName: string;
@@ -77,6 +79,11 @@ const Collection = () => {
     },
     },
   ];
   ];
 
 
+  // exclude parititon on cloud
+  if (isManaged) {
+    tabs.splice(1, 1);
+  }
+
   return (
   return (
     <section className={`page-wrapper ${classes.wrapper}`}>
     <section className={`page-wrapper ${classes.wrapper}`}>
       <CustomTabList
       <CustomTabList

+ 21 - 14
client/src/pages/collections/Collections.tsx

@@ -2,6 +2,7 @@ import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
 import { Link, useSearchParams } from 'react-router-dom';
 import { Link, useSearchParams } from 'react-router-dom';
 import { makeStyles, Theme } from '@material-ui/core';
 import { makeStyles, Theme } from '@material-ui/core';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
+import { authContext } from '../../context/Auth';
 import { useNavigationHook } from '../../hooks/Navigation';
 import { useNavigationHook } from '../../hooks/Navigation';
 import { ALL_ROUTER_TYPES } from '../../router/Types';
 import { ALL_ROUTER_TYPES } from '../../router/Types';
 import AttuGrid from '../../components/grid/Grid';
 import AttuGrid from '../../components/grid/Grid';
@@ -57,6 +58,8 @@ const useStyles = makeStyles((theme: Theme) => ({
 
 
 const Collections = () => {
 const Collections = () => {
   useNavigationHook(ALL_ROUTER_TYPES.COLLECTIONS);
   useNavigationHook(ALL_ROUTER_TYPES.COLLECTIONS);
+  const { isManaged } = useContext(authContext);
+
   const [searchParams] = useSearchParams();
   const [searchParams] = useSearchParams();
   const [search, setSearch] = useState<string>(
   const [search, setSearch] = useState<string>(
     (searchParams.get('search') as string) || ''
     (searchParams.get('search') as string) || ''
@@ -160,7 +163,7 @@ const Collections = () => {
     fieldData: any[]
     fieldData: any[]
   ): Promise<{ result: boolean; msg: string }> => {
   ): Promise<{ result: boolean; msg: string }> => {
     const param: InsertDataParam = {
     const param: InsertDataParam = {
-      partition_names: [partitionName],
+      partition_name: partitionName,
       fields_data: fieldData,
       fields_data: fieldData,
     };
     };
     try {
     try {
@@ -357,19 +360,7 @@ const Collections = () => {
         </span>
         </span>
       ),
       ),
     },
     },
-    {
-      id: '_aliasElement',
-      align: 'left',
-      disablePadding: false,
-      label: (
-        <span className="flex-center">
-          {collectionTrans('alias')}
-          <CustomToolTip title={collectionTrans('aliasInfo')}>
-            <InfoIcon classes={{ root: classes.icon }} />
-          </CustomToolTip>
-        </span>
-      ),
-    },
+
     {
     {
       id: 'consistency_level',
       id: 'consistency_level',
       align: 'left',
       align: 'left',
@@ -475,6 +466,22 @@ const Collections = () => {
     },
     },
   ];
   ];
 
 
+  if (!isManaged) {
+    colDefinitions.splice(3, 0, {
+      id: '_aliasElement',
+      align: 'left',
+      disablePadding: false,
+      label: (
+        <span className="flex-center">
+          {collectionTrans('alias')}
+          <CustomToolTip title={collectionTrans('aliasInfo')}>
+            <InfoIcon classes={{ root: classes.icon }} />
+          </CustomToolTip>
+        </span>
+      ),
+    });
+  }
+
   const handleSelectChange = (value: any) => {
   const handleSelectChange = (value: any) => {
     setSelectedCollections(value);
     setSelectedCollections(value);
   };
   };

+ 4 - 1
client/src/pages/dialogs/LoadCollectionDialog.tsx

@@ -7,6 +7,7 @@ import {
   FormControlLabel,
   FormControlLabel,
 } from '@material-ui/core';
 } from '@material-ui/core';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
+import { authContext } from '../../context/Auth';
 import { CollectionHttp } from '../../http/Collection';
 import { CollectionHttp } from '../../http/Collection';
 import { rootContext } from '../../context/Root';
 import { rootContext } from '../../context/Root';
 import { useFormValidation } from '../../hooks/Form';
 import { useFormValidation } from '../../hooks/Form';
@@ -49,6 +50,8 @@ const LoadCollectionDialog = (props: any) => {
   const [form, setForm] = useState({
   const [form, setForm] = useState({
     replica: 1,
     replica: 1,
   });
   });
+  const { isManaged } = useContext(authContext);
+
   const [enableRelica, setEnableRelica] = useState(false);
   const [enableRelica, setEnableRelica] = useState(false);
   const [replicaToggle, setReplicaToggle] = useState(false);
   const [replicaToggle, setReplicaToggle] = useState(false);
   const [maxQueryNode, setMaxQueryNode] = useState(1);
   const [maxQueryNode, setMaxQueryNode] = useState(1);
@@ -77,7 +80,7 @@ const LoadCollectionDialog = (props: any) => {
         MILVUS_DEPLOY_MODE.DISTRIBUTED;
         MILVUS_DEPLOY_MODE.DISTRIBUTED;
 
 
       // only show replica toggle in distributed mode && query node > 1
       // only show replica toggle in distributed mode && query node > 1
-      if (enableRelica && queryNodes.length > 1) {
+      if (enableRelica && queryNodes.length > 1 && !isManaged) {
         setMaxQueryNode(queryNodes.length);
         setMaxQueryNode(queryNodes.length);
         setEnableRelica(enableRelica);
         setEnableRelica(enableRelica);
       }
       }

+ 19 - 16
client/src/pages/index.tsx

@@ -45,7 +45,7 @@ const useStyles = makeStyles((theme: Theme) =>
 
 
 function Index() {
 function Index() {
   const navigate = useNavigate();
   const navigate = useNavigate();
-  const { isAuth } = useContext(authContext);
+  const { isAuth, isManaged } = useContext(authContext);
   const { isPrometheusReady } = useContext(prometheusContext);
   const { isPrometheusReady } = useContext(prometheusContext);
   const { versionInfo } = useContext(rootContext);
   const { versionInfo } = useContext(rootContext);
   const { t: navTrans } = useTranslation('nav');
   const { t: navTrans } = useTranslation('nav');
@@ -90,23 +90,26 @@ function Index() {
       iconActiveClass: 'normal',
       iconActiveClass: 'normal',
       iconNormalClass: 'active',
       iconNormalClass: 'active',
     },
     },
-    {
-      icon: icons.navSystem,
-      label: navTrans('system'),
-      onClick: () =>
-        isPrometheusReady
-          ? navigate('/system_healthy')
-          : navigate('/system'),
-      iconActiveClass: 'normal',
-      iconNormalClass: 'active',
-    },
-    {
-      icon: icons.navPerson,
-      label: navTrans('user'),
-      onClick: () => navigate('/users'),
-    },
   ];
   ];
 
 
+  if (!isManaged) {
+    menuItems.push(
+      {
+        icon: icons.navSystem,
+        label: navTrans('system'),
+        onClick: () =>
+          isPrometheusReady ? navigate('/system_healthy') : navigate('/system'),
+        iconActiveClass: 'normal',
+        iconNormalClass: 'active',
+      },
+      {
+        icon: icons.navPerson,
+        label: navTrans('user'),
+        onClick: () => navigate('/users'),
+      }
+    );
+  }
+
   // check if is connected
   // check if is connected
   if (!isAuth) {
   if (!isAuth) {
     return <Navigate to="/connect" />;
     return <Navigate to="/connect" />;

+ 23 - 10
client/src/router/Router.tsx

@@ -1,4 +1,6 @@
 import { createHashRouter, RouterProvider } from 'react-router-dom';
 import { createHashRouter, RouterProvider } from 'react-router-dom';
+import { useContext } from 'react';
+import { authContext } from '../context/Auth';
 import Collection from '../pages/collections/Collection';
 import Collection from '../pages/collections/Collection';
 import Collections from '../pages/collections/Collections';
 import Collections from '../pages/collections/Collections';
 import Connect from '../pages/connect/Connect';
 import Connect from '../pages/connect/Connect';
@@ -8,7 +10,7 @@ import Search from '../pages/search/VectorSearch';
 import System from '../pages/system/SystemView';
 import System from '../pages/system/SystemView';
 import SystemHealthy from '../pages/systemHealthy/SystemHealthyView';
 import SystemHealthy from '../pages/systemHealthy/SystemHealthyView';
 
 
-const router = createHashRouter([
+const routeObj = [
   {
   {
     path: '/',
     path: '/',
     element: <Index />,
     element: <Index />,
@@ -21,18 +23,12 @@ const router = createHashRouter([
         path: '/collections/:collectionName',
         path: '/collections/:collectionName',
         element: <Collection />,
         element: <Collection />,
       },
       },
-      {
-        path: '/users',
-        element: <Users />,
-      },
+
       {
       {
         path: '/search',
         path: '/search',
         element: <Search />,
         element: <Search />,
       },
       },
-      {
-        path: '/system',
-        element: <System />,
-      },
+
       {
       {
         path: '/system_healthy',
         path: '/system_healthy',
         element: <SystemHealthy />,
         element: <SystemHealthy />,
@@ -40,9 +36,26 @@ const router = createHashRouter([
     ],
     ],
   },
   },
   { path: '/connect', element: <Connect /> },
   { path: '/connect', element: <Connect /> },
-]);
+];
 
 
 const Router = () => {
 const Router = () => {
+  const { isManaged } = useContext(authContext);
+
+  if (!isManaged) {
+    routeObj[0].children?.push(
+      {
+        path: '/users',
+        element: <Users />,
+      },
+      {
+        path: '/system',
+        element: <System />,
+      }
+    );
+  }
+
+  const router = createHashRouter(routeObj);
+
   return <RouterProvider router={router}></RouterProvider>;
   return <RouterProvider router={router}></RouterProvider>;
 };
 };
 export default Router;
 export default Router;

+ 3 - 1
server/src/collections/collections.service.ts

@@ -180,7 +180,9 @@ export class CollectionsService {
                 collectionID: collectionInfo.collectionID,
                 collectionID: collectionInfo.collectionID,
               })
               })
             : replicas;
             : replicas;
-        } catch (e) {}
+        } catch (e) {
+          console.log('ignore getReplica');
+        }
 
 
         data.push({
         data.push({
           aliases: collectionInfo.aliases,
           aliases: collectionInfo.aliases,