Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT-1421 - improve workflow reset form #1675

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/components/workflow-actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
let resetConfirmationModalOpen = false;
let signalConfirmationModalOpen = false;
let error = '';
let resetReapplyType: ResetReapplyType = ResetReapplyType.Unspecified;
let resetReapplyType: ResetReapplyType = ResetReapplyType.Signal;
let resetId = writable<string>();
let resetReason: string;
let loading = false;
Expand All @@ -69,7 +69,7 @@
};

const hideResetModal = () => {
resetReapplyType = ResetReapplyType.Unspecified;
resetReapplyType = ResetReapplyType.Signal;
$resetId = undefined;
resetReason = undefined;
};
Expand Down
44 changes: 16 additions & 28 deletions src/lib/components/workflow/workflow-reset-form.svelte
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
<script lang="ts">
import type { Writable } from 'svelte/store';
import Checkbox from '$lib/holocene/checkbox.svelte';
import Input from '$lib/holocene/input/input.svelte';
import RadioGroup from '$lib/holocene/radio-input/radio-group.svelte';
import RadioInput from '$lib/holocene/radio-input/radio-input.svelte';
import Option from '$lib/holocene/select/option.svelte';
import Select from '$lib/holocene/select/select.svelte';
import { translate } from '$lib/i18n/translate';
import { ResetReapplyType } from '$lib/models/workflow-actions';
import { resetEvents } from '$lib/stores/events';
export let resetReapplyType: ResetReapplyType = ResetReapplyType.Unspecified;
export let resetReapplyType: ResetReapplyType = ResetReapplyType.Signal;
export let reason = '';
export let eventId: Writable<string>;
const resetReapplyTypes = [
{
value: ResetReapplyType.Unspecified,
label: translate('workflows', 'reset-reapply-all'),
},
{
value: ResetReapplyType.Signal,
label: translate('workflows', 'reset-reapply-signals-only'),
},
{
value: ResetReapplyType.None,
label: translate('workflows', 'reset-reapply-none'),
},
];
const handleResetReapplyTypeChange = (
event: CustomEvent<{ checked: boolean }>,
) => {
resetReapplyType = event.detail.checked
? ResetReapplyType.Signal
: ResetReapplyType.None;
};
</script>

<div class="flex w-full flex-col gap-4">
<RadioGroup
name="reset-event-id"
group={eventId}
class="max-h-40 overflow-auto"
description={translate('workflows', 'reset-event-radio-group-description')}
>
{#each $resetEvents as event}
<RadioInput
Expand All @@ -44,17 +37,12 @@
/>
{/each}
</RadioGroup>
<Select
<Checkbox
id="reset-reapply-type-checkbox"
checked={resetReapplyType === ResetReapplyType.Signal}
on:change={handleResetReapplyTypeChange}
label={translate('workflows', 'reset-reapply-type-label')}
id="reset-reapply-type-select"
bind:value={resetReapplyType}
data-testid="workflow-reset-reapply-type-select"
>
{#each resetReapplyTypes as { value, label }}
<Option {value}>
{label}
</Option>
{/each}
</Select>
/>

<Input id="reset-reason" bind:value={reason} label={translate('reason')} />
</div>
4 changes: 4 additions & 0 deletions src/lib/holocene/radio-input/radio-group.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
export { className as class };
export let name: string;
export let group: Writable<T>;
export let description = '';
setContext<RadioGroupContext<T>>(RADIO_GROUP_CONTEXT, {
name,
Expand All @@ -25,5 +26,8 @@
</script>

<div class="flex flex-col gap-2 {className}" {...$$restProps}>
{#if description}
<p class="font-secondary text-sm font-medium">{description}</p>
{/if}
<slot />
</div>
1 change: 1 addition & 0 deletions src/lib/holocene/radio-input/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface RadioInputProps<T> extends HTMLInputAttributes {
export interface RadioGroupProps<T> extends HTMLAttributes<HTMLDivElement> {
name: string;
group: Writable<T>;
description?: string;
}

export type RadioGroupContext<T> = {
Expand Down
7 changes: 3 additions & 4 deletions src/lib/i18n/locales/en/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ export const Strings = {
'cancel-success': 'Workflow canceled.',
'signal-success': 'Workflow signaled.',
'reset-modal-title': 'Reset Workflow',
'reset-reapply-type-label': 'Reapply Type',
'reset-reapply-all': 'All Events',
'reset-reapply-signals-only': 'Signals Only',
'reset-reapply-none': 'None',
'reset-event-radio-group-description': 'Choose an Event to reset to',
'reset-reapply-type-label':
'Reapply Signals that happened after the Reset point',
'cancel-modal-title': 'Cancel Workflow',
'cancel-modal-confirmation':
'Are you sure you want to cancel this workflow? This action cannot be undone.',
Expand Down
Loading