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 315692d629 [INLONG-10419][Dashboard] Automatically switch tenants when 
opening a page with groupId (#10420)
315692d629 is described below

commit 315692d62954fddcf3a6d85183b4489facc10d44
Author: haifxu <xhf1208357...@gmail.com>
AuthorDate: Fri Jun 14 14:11:40 2024 +0800

    [INLONG-10419][Dashboard] Automatically switch tenants when opening a page 
with groupId (#10420)
---
 .../src/ui/components/Layout/Tenant/index.tsx             |  2 +-
 inlong-dashboard/src/ui/pages/GroupDetail/index.tsx       | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/inlong-dashboard/src/ui/components/Layout/Tenant/index.tsx 
b/inlong-dashboard/src/ui/components/Layout/Tenant/index.tsx
index d3fddf4b03..9653060ca7 100644
--- a/inlong-dashboard/src/ui/components/Layout/Tenant/index.tsx
+++ b/inlong-dashboard/src/ui/components/Layout/Tenant/index.tsx
@@ -90,7 +90,7 @@ const Comp: React.FC = () => {
     getData(key);
     setLocalStorage({ name: key });
     message.success(t('components.Layout.Tenant.Success'));
-    window.location.reload();
+    window.location.href = '/';
   };
 
   const onFilter = allValues => {
diff --git a/inlong-dashboard/src/ui/pages/GroupDetail/index.tsx 
b/inlong-dashboard/src/ui/pages/GroupDetail/index.tsx
index ec025a322b..02961f38b4 100644
--- a/inlong-dashboard/src/ui/pages/GroupDetail/index.tsx
+++ b/inlong-dashboard/src/ui/pages/GroupDetail/index.tsx
@@ -30,6 +30,7 @@ import Audit from './Audit';
 import ResourceInfo from './ResourceInfo';
 import Delay from './Delay';
 import OperationLog from './OperationLog';
+import { useLocalStorage } from '@/core/utils/localStorage';
 
 const Comp: React.FC = () => {
   const { t } = useTranslation();
@@ -39,6 +40,7 @@ const Comp: React.FC = () => {
 
   const qs = parse(location.search.slice(1));
 
+  const [getLocalStorage, setLocalStorage] = useLocalStorage('tenant');
   const [current, setCurrent] = useState(+qs.step || 0);
   const [, { add: addOpened, has: hasOpened }] = useSet([current]);
   const [confirmLoading, setConfirmLoading] = useState(false);
@@ -58,6 +60,19 @@ const Comp: React.FC = () => {
     onSuccess: result => setMqType(result.mqType),
   });
 
+  useRequest(`/group/getTenant/${id}`, {
+    ready: !!id,
+    refreshDeps: [id],
+    onSuccess: result => {
+      console.log('res', result, getLocalStorage('tenant')?.['name']);
+      if (getLocalStorage('tenant')?.['name'] !== result) {
+        setLocalStorage({ name: result });
+        message.success(t('components.Layout.Tenant.Success'));
+        window.location.reload();
+      }
+    },
+  });
+
   const isReadonly = useMemo(() => [0, 101, 102].includes(data?.status), 
[data]);
 
   const list = useMemo(

Reply via email to