22
22
*
23
23
******************************************************************************/
24
24
25
- import React , { createContext , PropsWithChildren , useEffect , useState } from "react" ;
25
+ import React , {
26
+ createContext ,
27
+ PropsWithChildren ,
28
+ useEffect ,
29
+ useState ,
30
+ } from "react"
26
31
import * as QuestDB from "../../utils/questdb"
27
32
import { useSelector } from "react-redux"
28
33
import { selectors } from "../../store"
29
34
import { useAuth } from "../AuthProvider"
30
35
import { AuthPayload } from "../../modules/OAuth2/types"
31
36
import { getValue } from "../../utils/localStorage"
32
37
import { StoreKey } from "../../utils/localStorage/types"
33
- import { formatCommitHash , formatVersion } from "./services" ;
34
- import { Versions } from "./types" ;
38
+ import { formatCommitHash , formatVersion } from "./services"
39
+ import { Versions } from "./types"
35
40
36
41
const questClient = new QuestDB . Client ( )
37
42
38
43
type Props = { }
39
44
40
45
type ContextProps = {
41
- quest : QuestDB . Client ,
42
- buildVersion : Versions ,
46
+ quest : QuestDB . Client
47
+ buildVersion : Versions
43
48
commitHash : string
44
49
}
45
50
@@ -57,8 +62,14 @@ export const QuestContext = createContext<ContextProps>(defaultValues)
57
62
export const QuestProvider = ( { children } : PropsWithChildren < Props > ) => {
58
63
const settings = useSelector ( selectors . console . getSettings )
59
64
const { sessionData, refreshAuthToken } = useAuth ( )
60
- const [ authCheckFinished , setAuthCheckFinished ] = React . useState ( settings [ "acl.basic.auth.realm.enabled" ] )
61
- const [ buildVersion , setBuildVersion ] = useState < Versions > ( defaultValues . buildVersion )
65
+ const [ authCheckFinished , setAuthCheckFinished ] = useState (
66
+ settings [ "acl.basic.auth.realm.enabled" ] ||
67
+ ( ! settings [ "acl.oidc.enabled" ] &&
68
+ ! settings [ "acl.basic.auth.realm.enabled" ] ) ,
69
+ )
70
+ const [ buildVersion , setBuildVersion ] = useState < Versions > (
71
+ defaultValues . buildVersion ,
72
+ )
62
73
const [ commitHash , setCommitHash ] = useState < string > ( "" )
63
74
64
75
const finishAuthCheck = async ( ) => {
@@ -115,7 +126,7 @@ export const QuestProvider = ({ children }: PropsWithChildren<Props>) => {
115
126
value = { {
116
127
quest : questClient ,
117
128
buildVersion,
118
- commitHash
129
+ commitHash,
119
130
} }
120
131
>
121
132
{ children }
0 commit comments