Skip to content

Commit

Permalink
Merge pull request #434 from mareklibra/MGMT-10892.safeCallOfPersist
Browse files Browse the repository at this point in the history
MGMT-10892 Safe navigation to the /wizard/persist page for no change
  • Loading branch information
mareklibra authored Jun 22, 2022
2 parents 288c4b6 + 8e99b41 commit 68cc219
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ui/frontend/src/components/K8SStateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const K8SStateContextProvider: React.FC<{
const fieldValues = React.useRef<K8SStateContextDataFields>(_fv);
fieldValues.current = _fv;

const [snapshot, setSnapshot] = React.useState<K8SStateContextDataFields>();
const [snapshot, setSnapshot] = React.useState<K8SStateContextDataFields>(_fv);
const setClean = React.useCallback(() => {
setSnapshot(fieldValues.current);
}, [fieldValues]);
Expand Down
6 changes: 5 additions & 1 deletion ui/frontend/src/components/PersistPage/PersistPageBottom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export const PersistPageBottom: React.FC = () => {
navigateToNewDomain(state.domain, '/wizard/final'),
);
} else {
console.warn('No change to persist on the PersistPage');
console.warn(
'No change to persist on the PersistPage. The reconcilliation might be still running if the user got here after page refresh.',
);
// TODO: Find out what's going on and resume the progress bar for the user
navigateToNewDomain(state.domain, '/wizard/welcome');
}
}, [retry, setError, progress.setProgress, state]);

Expand Down
9 changes: 8 additions & 1 deletion ui/frontend/src/components/PersistPage/persist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@ export const navigateToNewDomain = async (domain: string, contextPath: string) =
// We can not check livenessProbe on the new domain due to CORS
// We can not use pod serving old domain either since it will be terminated and the route changed
// So just wait...
const ztpfwUrl = `https://${ZTPFW_UI_ROUTE_PREFIX}.apps.${domain}${contextPath}`;
let ztpfwUrl: string;
if (!domain) {
// fallback
ztpfwUrl = `${window.location.origin}${contextPath}`;
} else {
ztpfwUrl = `https://${ZTPFW_UI_ROUTE_PREFIX}.apps.${domain}${contextPath}`;
}

console.info('Changes are persisted, about to navigate to the new domain: ', ztpfwUrl);
// We should go with following:
window.location.replace(ztpfwUrl);
Expand Down

0 comments on commit 68cc219

Please sign in to comment.