@@ -4,7 +4,7 @@ import { useData, useItem } from '@patternfly-labs/react-form-wizard'
4
4
import { ArgoWizard } from '../../../wizards/Argo/ArgoWizard'
5
5
import { AcmToastContext } from '../../../ui-components'
6
6
import moment from 'moment-timezone'
7
- import { useContext } from 'react'
7
+ import { useContext , useEffect , useState } from 'react'
8
8
import { generatePath , useNavigate } from 'react-router-dom-v5-compat'
9
9
import { useRecoilValue , useSharedAtoms , useSharedSelectors } from '../../../shared-recoil'
10
10
import { SyncEditor } from '../../../components/SyncEditor/SyncEditor'
@@ -22,6 +22,7 @@ import {
22
22
import { argoAppSetQueryString } from './actions'
23
23
import schema from './pullmodelschema.json'
24
24
import { LostChangesContext } from '../../../components/LostChanges'
25
+ import { LoadingPage } from '../../../components/LoadingPage'
25
26
26
27
export default function CreateArgoApplicationSetPullModelPage ( ) {
27
28
return < CreateApplicationArgoPullModel />
@@ -94,8 +95,32 @@ export function CreateApplicationArgoPullModel() {
94
95
: moment . tz . names ( )
95
96
96
97
const { cancelForm, submitForm } = useContext ( LostChangesContext )
98
+ const [ createdResource , setCreatedResource ] = useState < any > ( )
97
99
98
- return (
100
+ // don't navigate to details page until application exists in recoil
101
+ useEffect ( ( ) => {
102
+ if ( createdResource ) {
103
+ if (
104
+ applicationSets . findIndex (
105
+ ( appset ) =>
106
+ appset . metadata . name === createdResource . metadata . name ! &&
107
+ appset . metadata . namespace === createdResource . metadata . namespace !
108
+ ) !== - 1
109
+ ) {
110
+ navigate ( {
111
+ pathname : generatePath ( NavigationPath . applicationOverview , {
112
+ namespace : createdResource ?. metadata ?. namespace ?? '' ,
113
+ name : createdResource ?. metadata ?. name ?? '' ,
114
+ } ) ,
115
+ search : argoAppSetQueryString ,
116
+ } )
117
+ }
118
+ }
119
+ } , [ applicationSets , createdResource , navigate ] )
120
+
121
+ return createdResource ? (
122
+ < LoadingPage />
123
+ ) : (
99
124
< ArgoWizard
100
125
createClusterSetCallback = { ( ) => open ( NavigationPath . clusterSets , '_blank' ) }
101
126
ansibleCredentials = { availableAnsibleCredentials }
@@ -131,14 +156,7 @@ export function CreateApplicationArgoPullModel() {
131
156
} )
132
157
}
133
158
submitForm ( )
134
-
135
- navigate ( {
136
- pathname : generatePath ( NavigationPath . applicationOverview , {
137
- namespace : applicationSet ?. metadata ?. namespace ?? '' ,
138
- name : applicationSet ?. metadata ?. name ?? '' ,
139
- } ) ,
140
- search : argoAppSetQueryString ,
141
- } )
159
+ setCreatedResource ( applicationSet )
142
160
} )
143
161
} }
144
162
timeZones = { timeZones }
0 commit comments