Skip to content

Commit

Permalink
replace reset reapply type select with checkbox (#1675)
Browse files Browse the repository at this point in the history
and add more descriptive label
default the checkbox to checked, which applies signals
after the reset point
also add description to RadioGroup
  • Loading branch information
rossedfort authored Oct 12, 2023
1 parent a36ef54 commit 63fa1f0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/lib/components/workflow-actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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 @@ -79,7 +79,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

1 comment on commit 63fa1f0

@vercel
Copy link

@vercel vercel bot commented on 63fa1f0 Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

holocene – ./

holocene-git-main.preview.thundergun.io
holocene.preview.thundergun.io

Please sign in to comment.