1
- import React , { lazy , useState , useEffect , Suspense , useContext } from 'react'
1
+ import React , { lazy , useState , useEffect , Suspense , useContext , createContext } from 'react'
2
2
import { Route , NavLink , Router , Switch , Redirect } from 'react-router-dom'
3
3
import { useHistory , useLocation } from 'react-router'
4
4
import { URLS } from '../../config'
5
5
import { ErrorBoundary , importComponentFromFELibrary } from '../common'
6
- import { showError , Progressing , Toggle } from '@devtron-labs/devtron-fe-common-lib'
6
+ import { showError , Progressing , Toggle , ConditionalWrap , TippyCustomized , TippyTheme } from '@devtron-labs/devtron-fe-common-lib'
7
7
import arrowTriangle from '../../assets/icons/ic-chevron-down.svg'
8
8
import { AddNotification } from '../notifications/AddNotification'
9
9
import { ReactComponent as FormError } from '../../assets/icons/ic-warning.svg'
@@ -25,6 +25,7 @@ import { ModuleStatus } from '../v2/devtronStackManager/DevtronStackManager.type
25
25
import { getModuleInfo } from '../v2/devtronStackManager/DevtronStackManager.service'
26
26
import { BodyType , ProtectedInputType } from './globalConfiguration.type'
27
27
import CodeEditor from '../CodeEditor/CodeEditor'
28
+ import { GlobalConfigurationProvider , useGlobalConfiguration } from './GlobalConfigurationProvider'
28
29
29
30
const HostURLConfiguration = lazy ( ( ) => import ( '../hostURL/HostURL' ) )
30
31
const GitOpsConfiguration = lazy ( ( ) => import ( '../gitOps/GitOpsConfiguration' ) )
@@ -35,7 +36,6 @@ const ChartRepo = lazy(() => import('../chartRepo/ChartRepo'))
35
36
const Notifier = lazy ( ( ) => import ( '../notifications/Notifications' ) )
36
37
const Project = lazy ( ( ) => import ( '../project/ProjectList' ) )
37
38
const UserGroup = lazy ( ( ) => import ( '../userGroups/UserGroup' ) )
38
- const SSOLogin = lazy ( ( ) => import ( '../login/SSOLogin' ) )
39
39
const CustomChartList = lazy ( ( ) => import ( '../CustomChart/CustomChartList' ) )
40
40
const ScopedVariables = lazy ( ( ) => import ( '../scopedVariables/ScopedVariables' ) )
41
41
const TagListContainer = importComponentFromFELibrary ( 'TagListContainer' )
@@ -125,22 +125,24 @@ export default function GlobalConfiguration(props) {
125
125
< main className = "global-configuration" >
126
126
< PageHeader headerName = "Global configurations" />
127
127
< Router history = { useHistory ( ) } >
128
- < section className = "global-configuration__navigation" >
129
- < NavItem serverMode = { serverMode } />
130
- </ section >
131
- < section className = "global-configuration__component-wrapper" >
132
- < Suspense fallback = { < Progressing pageLoader /> } >
133
- < ErrorBoundary >
134
- < Body
135
- isSuperAdmin = { props . isSuperAdmin }
136
- getHostURLConfig = { getHostURLConfig }
137
- checkList = { checkList }
138
- serverMode = { serverMode }
139
- handleChecklistUpdate = { handleChecklistUpdate }
140
- />
141
- </ ErrorBoundary >
142
- </ Suspense >
143
- </ section >
128
+ < GlobalConfigurationProvider >
129
+ < section className = "global-configuration__navigation" >
130
+ < NavItem serverMode = { serverMode } />
131
+ </ section >
132
+ < section className = "global-configuration__component-wrapper" >
133
+ < Suspense fallback = { < Progressing pageLoader /> } >
134
+ < ErrorBoundary >
135
+ < Body
136
+ isSuperAdmin = { props . isSuperAdmin }
137
+ getHostURLConfig = { getHostURLConfig }
138
+ checkList = { checkList }
139
+ serverMode = { serverMode }
140
+ handleChecklistUpdate = { handleChecklistUpdate }
141
+ />
142
+ </ ErrorBoundary >
143
+ </ Suspense >
144
+ </ section >
145
+ </ GlobalConfigurationProvider >
144
146
</ Router >
145
147
</ main >
146
148
)
@@ -154,6 +156,8 @@ function NavItem({ serverMode }) {
154
156
const [ collapsedState , setCollapsedState ] = useState < Record < string , boolean > > ( {
155
157
Authorization : location . pathname . startsWith ( '/global-config/auth' ) ? false : true ,
156
158
} )
159
+ const { tippyConfig, setTippyConfig } = useGlobalConfiguration ( )
160
+
157
161
let moduleStatusTimer = null
158
162
const ConfigRequired = [
159
163
{
@@ -193,12 +197,17 @@ function NavItem({ serverMode }) {
193
197
component : CustomChartList ,
194
198
isAvailableInEA : false ,
195
199
} ,
196
- { name : 'SSO Login Services' , href : URLS . GLOBAL_CONFIG_LOGIN , component : SSOLogin , isAvailableInEA : true } ,
197
200
{
198
201
name : 'Authorization' ,
199
202
href : `${ URLS . GLOBAL_CONFIG_AUTH } /users` ,
200
203
preventDefaultKey : URLS . GLOBAL_CONFIG_AUTH ,
201
204
group : [
205
+ {
206
+ name : 'SSO Login Services' ,
207
+ dataTestId : 'authorization-sso-login-link' ,
208
+ href : `${ URLS . GLOBAL_CONFIG_AUTH } /login-service` ,
209
+ isAvailableInEA : true ,
210
+ } ,
202
211
{
203
212
name : 'User Permissions' ,
204
213
dataTestId : 'authorization-user-permissions-link' ,
@@ -261,28 +270,57 @@ function NavItem({ serverMode }) {
261
270
}
262
271
263
272
const renderNavItem = ( route , className = '' , preventOnClickOp = false ) => {
273
+ const onTippyClose = ( ) => {
274
+ // Resetting the tippy state
275
+ setTippyConfig ( {
276
+ showTippy : false
277
+ } )
278
+ }
279
+
264
280
return (
265
- < NavLink
266
- to = { `${ route . href } ` }
267
- key = { route . href }
268
- activeClassName = "active-route"
269
- data-testid = { route . dataTestId }
270
- className = { `${
271
- route . name === 'API tokens' &&
272
- location . pathname . startsWith ( `${ URLS . GLOBAL_CONFIG_AUTH } /${ Routes . API_TOKEN } ` )
273
- ? 'active-route'
274
- : ''
275
- } `}
276
- onClick = { ( e ) => {
277
- if ( ! preventOnClickOp ) {
278
- handleGroupCollapsedState ( e , route )
279
- }
280
- } }
281
+ // FIXME: Reuse the renderNavItem function for all nav item to extend the tippy support to all links
282
+ < ConditionalWrap
283
+ condition = { tippyConfig . showTippy && tippyConfig . showOnRoute === route . href }
284
+ wrap = { ( children ) => (
285
+ < TippyCustomized
286
+ theme = { TippyTheme . black }
287
+ className = "w-300 ml-2"
288
+ placement = "right"
289
+ showCloseButton
290
+ trigger = "manual"
291
+ interactive
292
+ showOnCreate
293
+ arrow
294
+ animation = "shift-toward-subtle"
295
+ onClose = { onTippyClose }
296
+ { ...tippyConfig }
297
+ >
298
+ { children }
299
+ </ TippyCustomized >
300
+ ) }
281
301
>
282
- < div className = { `flexbox flex-justify ${ className || '' } ` } data-testid = { `${ route . name } -page` } >
283
- < div > { route . name } </ div >
284
- </ div >
285
- </ NavLink >
302
+ < NavLink
303
+ to = { `${ route . href } ` }
304
+ key = { `${ route . name } -${ route . href } ` }
305
+ activeClassName = "active-route"
306
+ data-testid = { route . dataTestId }
307
+ className = { `${
308
+ route . name === 'API tokens' &&
309
+ location . pathname . startsWith ( `${ URLS . GLOBAL_CONFIG_AUTH } /${ Routes . API_TOKEN } ` )
310
+ ? 'active-route'
311
+ : ''
312
+ } `}
313
+ onClick = { ( e ) => {
314
+ if ( ! preventOnClickOp ) {
315
+ handleGroupCollapsedState ( e , route )
316
+ }
317
+ } }
318
+ >
319
+ < div className = { `flexbox flex-justify ${ className || '' } ` } data-testid = { `${ route . name } -page` } >
320
+ < div > { route . name } </ div >
321
+ </ div >
322
+ </ NavLink >
323
+ </ ConditionalWrap >
286
324
)
287
325
}
288
326
@@ -539,13 +577,6 @@ function Body({ getHostURLConfig, checkList, serverMode, handleChecklistUpdate,
539
577
< Route key = { URLS . GLOBAL_CONFIG_CUSTOM_CHARTS } path = { URLS . GLOBAL_CONFIG_CUSTOM_CHARTS } >
540
578
< CustomChartList />
541
579
</ Route > ,
542
- < Route
543
- key = { URLS . GLOBAL_CONFIG_LOGIN }
544
- path = { URLS . GLOBAL_CONFIG_LOGIN }
545
- render = { ( props ) => {
546
- return < SSOLogin { ...props } />
547
- } }
548
- /> ,
549
580
< Route
550
581
key = { URLS . GLOBAL_CONFIG_AUTH }
551
582
path = { URLS . GLOBAL_CONFIG_AUTH }
0 commit comments