@@ -5,37 +5,49 @@ import { OverallAppSignIn } from '@/features/auth/store/authStore';
55import { useParams } from '@tanstack/react-router' ;
66import { useMemo } from 'react' ;
77
8- export function useInstanceClient ( operationsUrl ?: string | null , port ?: number , secure ?: boolean ) {
8+ interface UseParams {
9+ operationsUrl ?: string | null ;
10+ port ?: number ;
11+ secure ?: boolean ;
12+ disableFabricConnect ?: boolean ;
13+ instanceId ?: string ;
14+ clusterId ?: string ;
15+ }
16+
17+ export function useInstanceClient (
18+ params : UseParams = { } ,
19+ ) {
920 const { instanceId, clusterId } : { instanceId ?: string ; clusterId ?: string } = useParams ( { strict : false } ) ;
10- const id = isLocalStudio ? OverallAppSignIn : instanceId ?? clusterId ;
11- return getInstanceClient ( { id, operationsUrl , port , secure } ) ;
21+ const id = isLocalStudio ? OverallAppSignIn : params . instanceId ?? instanceId ?? params . clusterId ?? clusterId ;
22+ return getInstanceClient ( { id, ... params } ) ;
1223}
1324
1425export function useInstanceClientParams (
15- operationsUrl ?: string | null ,
16- port ?: number ,
17- secure ?: boolean ,
26+ params : UseParams = { } ,
1827) : InstanceClientConfig & InstanceTypeConfig {
1928 const { instanceId, clusterId } : { instanceId ?: string ; clusterId ?: string } = useParams ( { strict : false } ) ;
20- const id = isLocalStudio ? OverallAppSignIn : instanceId ?? clusterId ;
29+ const id = isLocalStudio ? OverallAppSignIn : params . instanceId ?? instanceId ?? params . clusterId ?? clusterId ;
2130 return {
22- instanceClient : getInstanceClient ( { id, operationsUrl , port , secure } ) ,
31+ instanceClient : getInstanceClient ( { id, ... params } ) ,
2332 entityType : ( isLocalStudio || instanceId ) ? 'instance' : 'cluster' ,
2433 } ;
2534}
2635
2736export function useInstanceClientIdParams (
28- operationsUrl ?: string | null ,
29- port ?: number ,
30- secure ?: boolean ,
37+ params : UseParams = { } ,
3138) : InstanceClientIdConfig & InstanceTypeConfig {
32- const params : { instanceId ?: string ; clusterId ?: string } = useParams ( { strict : false } ) ;
33- return useMemo ( ( ) => getInstanceClientIdFromParams ( { ...params , operationsUrl, port, secure } ) , [
34- params ,
35- operationsUrl ,
36- port ,
37- secure ,
38- ] ) ;
39+ const { instanceId, clusterId } : { instanceId ?: string ; clusterId ?: string } = useParams ( { strict : false } ) ;
40+ return useMemo (
41+ ( ) => getInstanceClientIdFromParams ( { instanceId, clusterId, ...params } ) ,
42+ [
43+ params . instanceId ?? instanceId ,
44+ params . clusterId ?? clusterId ,
45+ params . operationsUrl ,
46+ params . port ,
47+ params . secure ,
48+ params . disableFabricConnect ,
49+ ] ,
50+ ) ;
3951}
4052
4153export function getInstanceClientIdFromParams ( {
@@ -44,19 +56,21 @@ export function getInstanceClientIdFromParams({
4456 operationsUrl,
4557 port,
4658 secure,
59+ disableFabricConnect,
4760} : {
4861 instanceId ?: string ;
4962 clusterId ?: string ;
5063 operationsUrl ?: string | null ;
5164 port ?: number ;
5265 secure ?: boolean ;
66+ disableFabricConnect ?: boolean ;
5367} ) : InstanceClientIdConfig & InstanceTypeConfig {
5468 const id = isLocalStudio ? OverallAppSignIn : instanceId ?? clusterId ;
5569 if ( ! id ) {
5670 throw new Error ( 'id could not be automatically calculated in useInstanceClientIdParams' ) ;
5771 }
5872 return {
59- instanceClient : getInstanceClient ( { id, operationsUrl, port, secure } ) ,
73+ instanceClient : getInstanceClient ( { id, operationsUrl, port, secure, disableFabricConnect } ) ,
6074 entityId : id ,
6175 entityType : ( isLocalStudio || instanceId ) ? 'instance' : 'cluster' ,
6276 } ;
0 commit comments