Skip to content

Commit 948244b

Browse files
Fix logic for config updates (#204)
* add logs * Update release version to dev-testing * changes * changes * changes * minor changes --------- Co-authored-by: actions-user <[email protected]>
1 parent 1ad3a8c commit 948244b

File tree

3 files changed

+62
-30
lines changed

3 files changed

+62
-30
lines changed

scripts/release_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export RELEASE_TAG=1.18.0-beta
1+
export RELEASE_TAG=dev-testing

ui/src/pages/Settings/RestartAppModal.tsx

Lines changed: 60 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,51 @@ const PROGRESS_STATES = {
6767
},
6868
};
6969

70+
const ProgressIndicator = ({
71+
hasSeenRestarting,
72+
config,
73+
isRestarting,
74+
waitingToRestart,
75+
}: {
76+
hasSeenRestarting: boolean;
77+
config?: ProjectConfig | null;
78+
isRestarting: boolean;
79+
waitingToRestart: boolean;
80+
}) => {
81+
const currentProgress = useMemo(() => {
82+
if (hasSeenRestarting && config) {
83+
return PROGRESS_STATES.READY;
84+
}
85+
86+
if (isRestarting) {
87+
return PROGRESS_STATES.RESTARTING;
88+
}
89+
90+
if (waitingToRestart) {
91+
return PROGRESS_STATES.WAITING;
92+
}
93+
94+
return PROGRESS_STATES.READY;
95+
}, [waitingToRestart, isRestarting]);
96+
97+
return (
98+
<Progress
99+
type="circle"
100+
percent={currentProgress.percent}
101+
steps={3}
102+
trailColor={cdlGray200}
103+
strokeColor={currentProgress.color}
104+
strokeWidth={10}
105+
format={() => (
106+
<Flex align="center" justify="center">
107+
<Typography.Text style={{ fontSize: 10, textWrap: "wrap" }}>
108+
{currentProgress.text}
109+
</Typography.Text>
110+
</Flex>
111+
)}
112+
/>
113+
);
114+
};
70115
const RestartAppModal = ({
71116
confirmationModal,
72117
form,
@@ -99,15 +144,22 @@ const RestartAppModal = ({
99144
restartApplication.mutate({});
100145
},
101146
});
102-
const { isError: isProjectConfigError } = useGetAmpConfig(polling);
147+
const { data: config } = useGetAmpConfig(polling);
148+
149+
const isRestarting = !config && polling;
103150

104-
const isRestarting = isProjectConfigError && polling;
105151
useEffect(() => {
106152
if (isRestarting) {
107153
setHasSeenRestarting(true);
108154
}
109155
}, [isRestarting, setHasSeenRestarting]);
110156

157+
useEffect(() => {
158+
if (config && polling && hasSeenRestarting) {
159+
setPolling(false);
160+
}
161+
}, [setPolling, config, polling, hasSeenRestarting]);
162+
111163
const handleSubmit = () => {
112164
form
113165
.validateFields()
@@ -134,17 +186,6 @@ const RestartAppModal = ({
134186
};
135187

136188
const waitingToRestart = polling && !hasSeenRestarting;
137-
138-
const currentProgress = useMemo(() => {
139-
if (waitingToRestart) {
140-
return PROGRESS_STATES.WAITING;
141-
}
142-
if (isRestarting) {
143-
return PROGRESS_STATES.RESTARTING;
144-
}
145-
return PROGRESS_STATES.READY;
146-
}, [waitingToRestart, isRestarting]);
147-
148189
const updateInProgress = updateAmpConfig.isSuccess && polling;
149190

150191
return (
@@ -175,21 +216,12 @@ const RestartAppModal = ({
175216
>
176217
Update Settings
177218
</Button>
178-
{updateInProgress ? (
179-
<Progress
180-
type="circle"
181-
percent={currentProgress.percent}
182-
steps={3}
183-
trailColor={cdlGray200}
184-
strokeColor={currentProgress.color}
185-
strokeWidth={10}
186-
format={() => (
187-
<Flex align="center" justify="center">
188-
<Typography.Text style={{ fontSize: 10, textWrap: "wrap" }}>
189-
{currentProgress.text}
190-
</Typography.Text>
191-
</Flex>
192-
)}
219+
{updateAmpConfig.isSuccess ? (
220+
<ProgressIndicator
221+
hasSeenRestarting={hasSeenRestarting}
222+
isRestarting={isRestarting}
223+
waitingToRestart={waitingToRestart}
224+
config={config}
193225
/>
194226
) : null}
195227
{updateAmpConfig.isSuccess && !waitingToRestart && !isRestarting ? (

ui/src/pages/Settings/SettingsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const SettingsPage = () => {
8282

8383
return (
8484
<Flex style={{ marginLeft: 60 }} vertical>
85-
{!projectConfig?.is_valid_config && (
85+
{!projectConfig?.is_valid_config && !confirmationModal.isModalOpen && (
8686
<Alert
8787
message={
8888
<div>

0 commit comments

Comments
 (0)