Skip to content

Commit 2e889c3

Browse files
fix(schedules): surface API errors on schedule mutations and preserve form edits (#4045)
* fix(schedules): surface API errors on schedule mutations and preserve form edits Closes #4044 * fix(schedules): unify mutation error handling and strengthen regression coverage - Propagate create and edit failures to submitters consistently - Extract shared error formatting with HTTP status and translated fallbacks - Add translated context to create and edit error messages - Cover HTTP, transport, parsing, and encoding failures - Verify form preservation, successful retries, and modal error isolation * Use 'message' in error instead of has * Close confirmation modals on component cleanup --------- Co-authored-by: Tegan Churchill <tegan.churchill@temporal.io>
1 parent db23112 commit 2e889c3

14 files changed

Lines changed: 1210 additions & 76 deletions

‎src/lib/components/schedule/schedule-action-modals/backfill-schedule-modal.svelte‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@
7474
const invalidEndTime = $derived(endTimestamp <= startTimestamp);
7575
7676
$effect(() => {
77-
return () => clearConfirmationModalActionTimeout('backfill');
77+
return () => {
78+
clearConfirmationModalActionTimeout('backfill');
79+
closeConfirmationModal('backfill');
80+
};
7881
});
7982
</script>
8083

‎src/lib/components/schedule/schedule-action-modals/delete-schedule-modal.svelte‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
let { scheduleId, namespace }: Props = $props();
2222
2323
$effect(() => {
24-
return () => clearConfirmationModalActionTimeout('delete');
24+
return () => {
25+
clearConfirmationModalActionTimeout('delete');
26+
closeConfirmationModal('delete');
27+
};
2528
});
2629
</script>
2730

‎src/lib/components/schedule/schedule-action-modals/pause-schedule-modal.svelte‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
let reason = $state('');
2626
2727
$effect(() => {
28-
return () => clearConfirmationModalActionTimeout('pause');
28+
return () => {
29+
clearConfirmationModalActionTimeout('pause');
30+
closeConfirmationModal('pause');
31+
};
2932
});
3033
</script>
3134

‎src/lib/components/schedule/schedule-action-modals/trigger-schedule-modal.svelte‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
let selectedOverlapPolicy = writable<OverlapPolicy>(scheduleOverlapPolicy);
3434
3535
$effect(() => {
36-
return () => clearConfirmationModalActionTimeout('trigger');
36+
return () => {
37+
clearConfirmationModalActionTimeout('trigger');
38+
closeConfirmationModal('trigger');
39+
};
3740
});
3841
</script>
3942

‎src/lib/components/schedule/schedule-form/form.svelte‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import { translate } from '$lib/i18n/translate';
1414
import { IconChevronLeft, IconTrash } from '$lib/io/icon';
1515
import {
16+
confirmationModal,
1617
loading,
1718
openConfirmationModal,
1819
serverError,
@@ -77,6 +78,7 @@
7778
dataType: 'json',
7879
validators: zodClient(formScheduleSchema),
7980
resetForm: false,
81+
invalidateAll: false,
8082
onUpdate: async ({ form }) => {
8183
if (!form.valid) return;
8284
await onSubmit(form.data);
@@ -172,6 +174,7 @@
172174
>
173175
<Button
174176
disabled={$submitting || !writeActionsAreAllowed()}
177+
loading={$submitting}
175178
type="submit"
176179
class="max-sm:w-full"
177180
data-testid="create-schedule-button">{confirmText}</Button
@@ -202,7 +205,11 @@
202205
</div>
203206
</form>
204207

205-
<Alert intent="error" title={$serverError} hidden={!$serverError} />
208+
<Alert
209+
intent="error"
210+
title={$serverError}
211+
hidden={!$serverError || $confirmationModal !== 'none'}
212+
/>
206213
<CodecServerErrorBanner />
207214
{/if}
208215
</div>

‎src/lib/i18n/locales/en/schedules.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export const Strings = {
77
'fix-form-errors': 'Please fix the following errors:',
88
editing: 'Editing Schedule...',
99
creating: 'Creating Schedule...',
10+
'create-schedule-error': 'Error creating schedule: {{error}}',
11+
'edit-schedule-error': 'Error editing schedule: {{error}}',
1012
'back-to-schedule': 'Back to Schedule',
1113
'back-to-schedules': 'Back to Schedules',
1214
id: 'Schedule ID',

0 commit comments

Comments
 (0)