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'
@@ -24,6 +24,7 @@ import { ReactComponent as Dropdown } from '../../assets/icons/ic-chevron-down.s
24
24
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
+ import { GlobalConfigurationProvider , useGlobalConfiguration } from './GlobalConfigurationProvider'
27
28
28
29
const HostURLConfiguration = lazy ( ( ) => import ( '../hostURL/HostURL' ) )
29
30
const GitOpsConfiguration = lazy ( ( ) => import ( '../gitOps/GitOpsConfiguration' ) )
@@ -34,7 +35,6 @@ const ChartRepo = lazy(() => import('../chartRepo/ChartRepo'))
34
35
const Notifier = lazy ( ( ) => import ( '../notifications/Notifications' ) )
35
36
const Project = lazy ( ( ) => import ( '../project/ProjectList' ) )
36
37
const UserGroup = lazy ( ( ) => import ( '../userGroups/UserGroup' ) )
37
- const SSOLogin = lazy ( ( ) => import ( '../login/SSOLogin' ) )
38
38
const CustomChartList = lazy ( ( ) => import ( '../CustomChart/CustomChartList' ) )
39
39
const ScopedVariables = lazy ( ( ) => import ( '../scopedVariables/ScopedVariables' ) )
40
40
const CodeEditor = lazy ( ( ) => import ( '../CodeEditor/CodeEditor' ) )
@@ -124,22 +124,24 @@ export default function GlobalConfiguration(props) {
124
124
< main className = "global-configuration" >
125
125
< PageHeader headerName = "Global configurations" />
126
126
< Router history = { useHistory ( ) } >
127
- < section className = "global-configuration__navigation" >
128
- < NavItem serverMode = { serverMode } />
129
- </ section >
130
- < section className = "global-configuration__component-wrapper" >
131
- < Suspense fallback = { < Progressing pageLoader /> } >
132
- < ErrorBoundary >
133
- < Body
134
- isSuperAdmin = { props . isSuperAdmin }
135
- getHostURLConfig = { getHostURLConfig }
136
- checkList = { checkList }
137
- serverMode = { serverMode }
138
- handleChecklistUpdate = { handleChecklistUpdate }
139
- />
140
- </ ErrorBoundary >
141
- </ Suspense >
142
- </ section >
127
+ < GlobalConfigurationProvider >
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 >
144
+ </ GlobalConfigurationProvider >
143
145
</ Router >
144
146
</ main >
145
147
)
@@ -153,6 +155,8 @@ function NavItem({ serverMode }) {
153
155
const [ collapsedState , setCollapsedState ] = useState < Record < string , boolean > > ( {
154
156
Authorization : location . pathname . startsWith ( '/global-config/auth' ) ? false : true ,
155
157
} )
158
+ const { tippyConfig, setTippyConfig } = useGlobalConfiguration ( )
159
+
156
160
let moduleStatusTimer = null
157
161
const ConfigRequired = [
158
162
{
@@ -192,12 +196,17 @@ function NavItem({ serverMode }) {
192
196
component : CustomChartList ,
193
197
isAvailableInEA : false ,
194
198
} ,
195
- { name : 'SSO Login Services' , href : URLS . GLOBAL_CONFIG_LOGIN , component : SSOLogin , isAvailableInEA : true } ,
196
199
{
197
200
name : 'Authorization' ,
198
201
href : `${ URLS . GLOBAL_CONFIG_AUTH } /users` ,
199
202
preventDefaultKey : URLS . GLOBAL_CONFIG_AUTH ,
200
203
group : [
204
+ {
205
+ name : 'SSO Login Services' ,
206
+ dataTestId : 'authorization-sso-login-link' ,
207
+ href : `${ URLS . GLOBAL_CONFIG_AUTH } /login-service` ,
208
+ isAvailableInEA : true ,
209
+ } ,
201
210
{
202
211
name : 'User Permissions' ,
203
212
dataTestId : 'authorization-user-permissions-link' ,
@@ -260,28 +269,57 @@ function NavItem({ serverMode }) {
260
269
}
261
270
262
271
const renderNavItem = ( route , className = '' , preventOnClickOp = false ) => {
272
+ const onTippyClose = ( ) => {
273
+ // Resetting the tippy state
274
+ setTippyConfig ( {
275
+ showTippy : false
276
+ } )
277
+ }
278
+
263
279
return (
264
- < NavLink
265
- to = { `${ route . href } ` }
266
- key = { route . href }
267
- activeClassName = "active-route"
268
- data-testid = { route . dataTestId }
269
- className = { `${
270
- route . name === 'API tokens' &&
271
- location . pathname . startsWith ( `${ URLS . GLOBAL_CONFIG_AUTH } /${ Routes . API_TOKEN } ` )
272
- ? 'active-route'
273
- : ''
274
- } `}
275
- onClick = { ( e ) => {
276
- if ( ! preventOnClickOp ) {
277
- handleGroupCollapsedState ( e , route )
278
- }
279
- } }
280
+ // FIXME: Reuse the renderNavItem function for all nav item to extend the tippy support to all links
281
+ < ConditionalWrap
282
+ condition = { tippyConfig . showTippy && tippyConfig . showOnRoute === route . href }
283
+ wrap = { ( children ) => (
284
+ < TippyCustomized
285
+ theme = { TippyTheme . black }
286
+ className = "w-300 ml-2"
287
+ placement = "right"
288
+ showCloseButton
289
+ trigger = "manual"
290
+ interactive
291
+ showOnCreate
292
+ arrow
293
+ animation = "shift-toward-subtle"
294
+ onClose = { onTippyClose }
295
+ { ...tippyConfig }
296
+ >
297
+ { children }
298
+ </ TippyCustomized >
299
+ ) }
280
300
>
281
- < div className = { `flexbox flex-justify ${ className || '' } ` } data-testid = { `${ route . name } -page` } >
282
- < div > { route . name } </ div >
283
- </ div >
284
- </ NavLink >
301
+ < NavLink
302
+ to = { `${ route . href } ` }
303
+ key = { `${ route . name } -${ route . href } ` }
304
+ activeClassName = "active-route"
305
+ data-testid = { route . dataTestId }
306
+ className = { `${
307
+ route . name === 'API tokens' &&
308
+ location . pathname . startsWith ( `${ URLS . GLOBAL_CONFIG_AUTH } /${ Routes . API_TOKEN } ` )
309
+ ? 'active-route'
310
+ : ''
311
+ } `}
312
+ onClick = { ( e ) => {
313
+ if ( ! preventOnClickOp ) {
314
+ handleGroupCollapsedState ( e , route )
315
+ }
316
+ } }
317
+ >
318
+ < div className = { `flexbox flex-justify ${ className || '' } ` } data-testid = { `${ route . name } -page` } >
319
+ < div > { route . name } </ div >
320
+ </ div >
321
+ </ NavLink >
322
+ </ ConditionalWrap >
285
323
)
286
324
}
287
325
@@ -529,13 +567,6 @@ function Body({ getHostURLConfig, checkList, serverMode, handleChecklistUpdate,
529
567
< Route key = { URLS . GLOBAL_CONFIG_CUSTOM_CHARTS } path = { URLS . GLOBAL_CONFIG_CUSTOM_CHARTS } >
530
568
< CustomChartList />
531
569
</ Route > ,
532
- < Route
533
- key = { URLS . GLOBAL_CONFIG_LOGIN }
534
- path = { URLS . GLOBAL_CONFIG_LOGIN }
535
- render = { ( props ) => {
536
- return < SSOLogin { ...props } />
537
- } }
538
- /> ,
539
570
< Route
540
571
key = { URLS . GLOBAL_CONFIG_AUTH }
541
572
path = { URLS . GLOBAL_CONFIG_AUTH }
0 commit comments