|
1 | 1 | import { useQuery } from '@tanstack/react-query'; |
2 | | -import { useCallback, useEffect, useState } from 'react'; |
| 2 | +import { useCallback, useEffect } from 'react'; |
3 | 3 | import { m } from '../../../../paraglide/messages'; |
4 | 4 | import api from '../../../../shared/api/api'; |
5 | 5 | import { Controls } from '../../../../shared/components/Controls/Controls'; |
@@ -61,7 +61,14 @@ export const AutoAdoptionExternalUrlSslConfigStep = () => { |
61 | 61 | const sslType = useAutoAdoptionSetupWizardStore((s) => s.external_ssl_type); |
62 | 62 | const certInfo = useAutoAdoptionSetupWizardStore((s) => s.external_ssl_cert_info); |
63 | 63 |
|
64 | | - const [acmeState, setAcmeState] = useState<AcmeStepState>(defaultAcmeState); |
| 64 | + // If ssl_type is not set (e.g. fresh browser session), redirect back so the |
| 65 | + // user can re-submit the settings step and repopulate the store. |
| 66 | + // biome-ignore lint/correctness/useExhaustiveDependencies: only run on mount |
| 67 | + useEffect(() => { |
| 68 | + if (sslType === null) { |
| 69 | + setActiveStep(AutoAdoptionSetupStep.ExternalUrlSettings); |
| 70 | + } |
| 71 | + }, []); |
65 | 72 |
|
66 | 73 | const { data: sslInfoData } = useQuery({ |
67 | 74 | queryKey: ['external_ssl_info'], |
@@ -99,33 +106,24 @@ export const AutoAdoptionExternalUrlSslConfigStep = () => { |
99 | 106 | }; |
100 | 107 | }, []); |
101 | 108 |
|
102 | | - const stepDone = useCallback( |
103 | | - (stepId: AcmeStepId): boolean => { |
104 | | - const stepIndex = ACME_STEP_IDS.indexOf(stepId); |
105 | | - const currentIndex = acmeState.currentStep |
106 | | - ? ACME_STEP_IDS.indexOf(acmeState.currentStep) |
107 | | - : -1; |
108 | | - return stepIndex < currentIndex || acmeState.isComplete; |
109 | | - }, |
110 | | - [acmeState.isComplete, acmeState.currentStep], |
111 | | - ); |
| 109 | + const stepDone = useCallback((stepId: AcmeStepId): boolean => { |
| 110 | + const stepIndex = ACME_STEP_IDS.indexOf(stepId); |
| 111 | + const currentIndex = acmeState.currentStep |
| 112 | + ? ACME_STEP_IDS.indexOf(acmeState.currentStep) |
| 113 | + : -1; |
| 114 | + return stepIndex < currentIndex || acmeState.isComplete; |
| 115 | + }, []); |
112 | 116 |
|
113 | | - const stepLoading = useCallback( |
114 | | - (stepId: AcmeStepId): boolean => { |
115 | | - return acmeState.isProcessing && acmeState.currentStep === stepId; |
116 | | - }, |
117 | | - [acmeState.isProcessing, acmeState.currentStep], |
118 | | - ); |
| 117 | + const stepLoading = useCallback((stepId: AcmeStepId): boolean => { |
| 118 | + return acmeState.isProcessing && acmeState.currentStep === stepId; |
| 119 | + }, []); |
119 | 120 |
|
120 | | - const stepError = useCallback( |
121 | | - (stepId: AcmeStepId): string | null => { |
122 | | - if (acmeState.errorMessage && acmeState.currentStep === stepId) { |
123 | | - return acmeState.errorMessage; |
124 | | - } |
125 | | - return null; |
126 | | - }, |
127 | | - [acmeState.errorMessage, acmeState.currentStep], |
128 | | - ); |
| 121 | + const stepError = useCallback((stepId: AcmeStepId): string | null => { |
| 122 | + if (acmeState.errorMessage && acmeState.currentStep === stepId) { |
| 123 | + return acmeState.errorMessage; |
| 124 | + } |
| 125 | + return null; |
| 126 | + }, []); |
129 | 127 |
|
130 | 128 | const handleDownloadCaCert = () => { |
131 | 129 | if (!sslInfoData?.ca_cert_pem) return; |
@@ -303,7 +301,7 @@ export const AutoAdoptionExternalUrlSslConfigStep = () => { |
303 | 301 | text={m.initial_setup_controls_back()} |
304 | 302 | variant="outlined" |
305 | 303 | onClick={() => setActiveStep(AutoAdoptionSetupStep.ExternalUrlSettings)} |
306 | | - disabled={isLetsEncryptProcessing || acmeState.isComplete} |
| 304 | + disabled={isLetsEncryptProcessing} |
307 | 305 | /> |
308 | 306 | <div className="right"> |
309 | 307 | <Button |
|
0 commit comments