1
1
import React , { lazy , Suspense , useRef , useState , useEffect } from 'react'
2
2
import { Route , Switch , Redirect , useHistory , useLocation } from 'react-router-dom'
3
- import { APPROVAL_MODAL_TYPE , URLS } from './config'
3
+ import { URLS } from './config'
4
4
import { toast } from 'react-toastify'
5
5
import 'patternfly/dist/css/patternfly.css'
6
6
import 'patternfly/dist/css/patternfly-additions.css'
@@ -19,7 +19,7 @@ import {
19
19
ErrorBoundary ,
20
20
importComponentFromFELibrary ,
21
21
} from './components/common'
22
- import { showError , BreadcrumbStore , Reload , DevtronProgressing } from '@devtron-labs/devtron-fe-common-lib'
22
+ import { showError , BreadcrumbStore , Reload , DevtronProgressing , APPROVAL_MODAL_TYPE } from '@devtron-labs/devtron-fe-common-lib'
23
23
import * as serviceWorker from './serviceWorker'
24
24
import Hotjar from './components/Hotjar/Hotjar'
25
25
import { validateToken } from './services/service'
@@ -50,10 +50,10 @@ export default function App() {
50
50
const [ forceUpdateOnLocationChange , setForceUpdateOnLocationChange ] = useState ( false )
51
51
const [ approvalToken , setApprovalToken ] = useState < string > ( '' )
52
52
const [ approvalType , setApprovalType ] = useState < APPROVAL_MODAL_TYPE > ( APPROVAL_MODAL_TYPE . CONFIG )
53
-
54
53
const location = useLocation ( )
55
54
const { push } = useHistory ( )
56
55
const didMountRef = useRef ( false )
56
+ const isDirectApprovalNotification = location . pathname && location . pathname . includes ( 'approve' ) && location . search && location . search . includes ( '?token=' )
57
57
58
58
function onlineToast ( toastBody : JSX . Element , options ) {
59
59
if ( onlineToastRef . current && toast . isActive ( onlineToastRef . current ) ) {
@@ -130,7 +130,7 @@ export default function App() {
130
130
// If not K8S_CLIENT then validateToken otherwise directly redirect
131
131
if ( ! window . _env_ . K8S_CLIENT ) {
132
132
// Pass validation for direct email approval notification
133
- if ( location . pathname && location . pathname . includes ( 'approve' ) ) {
133
+ if ( isDirectApprovalNotification ) {
134
134
redirectToDirectApprovalNotification ( )
135
135
} else {
136
136
validation ( )
@@ -245,8 +245,7 @@ export default function App() {
245
245
) : (
246
246
< ErrorBoundary >
247
247
< BreadcrumbStore >
248
- { console . log ( approvalToken ) }
249
- { location . pathname && location . pathname . includes ( 'approve' ) ? (
248
+ { isDirectApprovalNotification ? (
250
249
< Switch >
251
250
< Route
252
251
exact
0 commit comments