@@ -23,7 +23,6 @@ import * as Sentry from '@sentry/browser'
23
23
import {
24
24
AboutDevtronDialog ,
25
25
animate ,
26
- AppListConstants ,
27
26
AppThemeType ,
28
27
BaseConfirmationModal ,
29
28
ConfirmationModalProvider ,
@@ -54,8 +53,6 @@ import {
54
53
ToastManager ,
55
54
ToastVariantType ,
56
55
URLS as CommonURLS ,
57
- useAsync ,
58
- useMainContext ,
59
56
useMotionTemplate ,
60
57
useMotionValue ,
61
58
UserPreferencesType ,
@@ -69,15 +66,14 @@ import { getUserRole } from '@Pages/GlobalConfigurations/Authorization/authoriza
69
66
import { Configurations } from '@Pages/Releases/Detail'
70
67
71
68
import { SERVER_MODE , URLS , ViewType } from '../../../config'
72
- import { ExternalFluxAppDetailsRoute } from '../../../Pages/App/Details/ExternalFlux'
73
69
import {
74
70
dashboardLoggedIn ,
75
71
getAppListMin ,
76
72
getClusterListMinWithoutAuth ,
77
73
getLoginData ,
78
74
updateLoginCount ,
79
75
} from '../../../services/service'
80
- import { AppRouterType , LoginCountType } from '../../../services/service.types'
76
+ import { LoginCountType } from '../../../services/service.types'
81
77
import { HelmAppListResponse } from '../../app/list-new/AppListType'
82
78
import { LOGIN_COUNT , MAX_LOGIN_COUNT } from '../../onboardingGuide/onboarding.utils'
83
79
import { Security } from '../../security/Security'
@@ -94,14 +90,11 @@ import { SidePanel } from '../SidePanel'
94
90
import { AppContext , ErrorBoundary } from '..'
95
91
import { ENVIRONMENT_DATA_FALLBACK , INITIAL_ENV_DATA_STATE , NAVBAR_WIDTH } from './constants'
96
92
import Navigation from './Navigation'
93
+ import { AppRouter , RedirectUserWithSentry } from './NavRoutes.components'
97
94
import { EnvironmentDataStateType , NavigationRoutesTypes } from './types'
98
95
99
96
const Charts = lazy ( ( ) => import ( '../../charts/Charts' ) )
100
- const ExternalApps = lazy ( ( ) => import ( '../../external-apps/ExternalApps' ) )
101
- const ExternalArgoApps = lazy ( ( ) => import ( '../../externalArgoApps/ExternalArgoApp' ) )
102
- const AppDetailsPage = lazy ( ( ) => import ( '../../app/details/main' ) )
103
- const NewAppList = lazy ( ( ) => import ( '../../app/list-new/AppList' ) )
104
- const DevtronChartRouter = lazy ( ( ) => import ( '../../v2/index' ) )
97
+
105
98
const GlobalConfig = lazy ( ( ) => import ( '../../globalConfigurations/GlobalConfiguration' ) )
106
99
const BulkEdit = lazy ( ( ) => import ( '../../bulkEdits/BulkEdits' ) )
107
100
const ResourceBrowser = lazy ( ( ) => import ( '../../ResourceBrowser/ResourceBrowserRouter' ) )
@@ -130,124 +123,6 @@ const ViewIsPipelineRBACConfigured: FunctionComponent<{
130
123
const LicenseInfoDialog = importComponentFromFELibrary ( 'LicenseInfoDialog' , null , 'function' )
131
124
const AIResponseWidget = importComponentFromFELibrary ( 'AIResponseWidget' , null , 'function' )
132
125
133
- const RedirectUserWithSentry = ( { isFirstLoginUser } : { isFirstLoginUser : boolean } ) => {
134
- const { push } = useHistory ( )
135
- const { pathname } = useLocation ( )
136
- const { serverMode } = useMainContext ( )
137
- useEffect ( ( ) => {
138
- if ( pathname && pathname !== '/' ) {
139
- Sentry . captureMessage (
140
- `redirecting to ${ window . _env_ . HIDE_NETWORK_STATUS_INTERFACE ? 'app-list' : 'network status interface' } from ${ pathname } ` ,
141
- 'warning' ,
142
- )
143
- }
144
-
145
- if ( ! window . _env_ . HIDE_NETWORK_STATUS_INTERFACE && ! ! NetworkStatusInterface ) {
146
- push ( CommonURLS . NETWORK_STATUS_INTERFACE )
147
- return
148
- }
149
-
150
- if ( window . _env_ . K8S_CLIENT ) {
151
- push ( URLS . RESOURCE_BROWSER )
152
- } else if ( isFirstLoginUser ) {
153
- push ( URLS . GETTING_STARTED )
154
- } else if ( serverMode === SERVER_MODE . EA_ONLY && window . _env_ . FEATURE_DEFAULT_LANDING_RB_ENABLE ) {
155
- push ( URLS . RESOURCE_BROWSER )
156
- } else {
157
- push ( `${ URLS . APP } /${ URLS . APP_LIST } ` )
158
- }
159
- } , [ ] )
160
- return null
161
- }
162
-
163
- const RedirectToAppList = ( ) => {
164
- const { replace } = useHistory ( )
165
- const { serverMode } = useMainContext ( )
166
- useEffect ( ( ) => {
167
- const baseUrl = `${ URLS . APP } /${ URLS . APP_LIST } `
168
- if ( serverMode === SERVER_MODE . FULL ) {
169
- replace ( `${ baseUrl } /${ AppListConstants . AppType . DEVTRON_APPS } ` )
170
- } else {
171
- replace ( `${ baseUrl } /${ AppListConstants . AppType . HELM_APPS } ` )
172
- }
173
- } , [ ] )
174
- return null
175
- }
176
-
177
- const AppListRouter = ( { isSuperAdmin, appListCount, loginCount } : AppRouterType ) => {
178
- const { path } = useRouteMatch ( )
179
- const [ , argoInfoData ] = useAsync ( ( ) => getModuleInfo ( ModuleNameMap . ARGO_CD ) )
180
- const isArgoInstalled : boolean = argoInfoData ?. result ?. status === ModuleStatus . INSTALLED
181
-
182
- return (
183
- < ErrorBoundary >
184
- < Switch >
185
- < Route path = { `${ path } /:appType` } render = { ( ) => < NewAppList isArgoInstalled = { isArgoInstalled } /> } />
186
- < Route exact path = "" >
187
- < RedirectToAppList />
188
- </ Route >
189
- < Route >
190
- < RedirectUserWithSentry isFirstLoginUser = { isSuperAdmin && loginCount === 0 && appListCount === 0 } />
191
- </ Route >
192
- </ Switch >
193
- </ ErrorBoundary >
194
- )
195
- }
196
-
197
- const AppRouter = ( { isSuperAdmin, appListCount, loginCount } : AppRouterType ) => {
198
- const { path } = useRouteMatch ( )
199
- const [ environmentId , setEnvironmentId ] = useState ( null )
200
- const [ currentAppName , setCurrentAppName ] = useState < string > ( '' )
201
-
202
- const appContextValue = useMemo (
203
- ( ) => ( { environmentId, setEnvironmentId, currentAppName, setCurrentAppName } ) ,
204
- [ environmentId , currentAppName ] ,
205
- )
206
-
207
- return (
208
- < ErrorBoundary >
209
- < AppContext . Provider value = { appContextValue } >
210
- < Switch >
211
- < Route
212
- path = { `${ path } /${ URLS . APP_LIST } ` }
213
- render = { ( ) => (
214
- < AppListRouter
215
- isSuperAdmin = { isSuperAdmin }
216
- appListCount = { appListCount }
217
- loginCount = { loginCount }
218
- />
219
- ) }
220
- />
221
- < Route path = { `${ path } /${ URLS . EXTERNAL_APPS } /:appId/:appName` } render = { ( ) => < ExternalApps /> } />
222
- < Route
223
- path = { `${ path } /${ URLS . EXTERNAL_ARGO_APP } /:clusterId(\\d+)/:appName/:namespace` }
224
- render = { ( ) => < ExternalArgoApps /> }
225
- />
226
- { window . _env_ . FEATURE_EXTERNAL_FLUX_CD_ENABLE && (
227
- < Route path = { `${ path } /${ URLS . EXTERNAL_FLUX_APP } /:clusterId/:appName/:namespace/:templateType` } >
228
- < ExternalFluxAppDetailsRoute />
229
- </ Route >
230
- ) }
231
- < Route
232
- path = { `${ path } /${ URLS . DEVTRON_CHARTS } /deployments/:appId(\\d+)/env/:envId(\\d+)` }
233
- render = { ( ) => < DevtronChartRouter /> }
234
- />
235
- < Route path = { `${ path } /:appId(\\d+)` } render = { ( ) => < AppDetailsPage /> } />
236
-
237
- < Route exact path = "" >
238
- < RedirectToAppList />
239
- </ Route >
240
- < Route >
241
- < RedirectUserWithSentry
242
- isFirstLoginUser = { isSuperAdmin && loginCount === 0 && appListCount === 0 }
243
- />
244
- </ Route >
245
- </ Switch >
246
- </ AppContext . Provider >
247
- </ ErrorBoundary >
248
- )
249
- }
250
-
251
126
const NavigationRoutes = ( { reloadVersionConfig } : Readonly < NavigationRoutesTypes > ) => {
252
127
const history = useHistory ( )
253
128
const location = useLocation ( )
0 commit comments