|
9 | 9 | <script lang="ts">
|
10 | 10 | import { type Writable } from 'svelte/store';
|
11 | 11 |
|
12 |
| - import { onDestroy } from 'svelte'; |
13 | 12 | import { v4 as uuid } from 'uuid';
|
14 | 13 |
|
15 | 14 | import Card from '$lib/holocene/card.svelte';
|
| 15 | + import Input from '$lib/holocene/input/input.svelte'; |
16 | 16 | import RadioGroup from '$lib/holocene/radio-input/radio-group.svelte';
|
17 | 17 | import RadioInput from '$lib/holocene/radio-input/radio-input.svelte';
|
18 | 18 | import { translate } from '$lib/i18n/translate';
|
|
22 | 22 | export let id = uuid();
|
23 | 23 | export let input: string;
|
24 | 24 | export let encoding: Writable<PayloadInputEncoding>;
|
| 25 | + export let messageType: string; |
25 | 26 | export let error = false;
|
26 | 27 | export let loading = false;
|
27 | 28 | export let label = translate('workflows.input');
|
28 | 29 | export let editing = true;
|
29 | 30 |
|
30 |
| - const clearValues = () => { |
31 |
| - $encoding = 'json/plain'; |
32 |
| - }; |
33 |
| -
|
34 |
| - onDestroy(clearValues); |
| 31 | + $: { |
| 32 | + if ($encoding === 'json/plain' && messageType) { |
| 33 | + messageType = ''; |
| 34 | + } |
| 35 | + } |
35 | 36 | </script>
|
36 | 37 |
|
37 | 38 | <div>
|
38 | 39 | <h5 class="pb-1 text-sm font-medium">{label}</h5>
|
39 | 40 | <Card class="flex flex-col gap-2">
|
40 | 41 | <PayloadInput bind:input bind:loading {error} {id} {editing} />
|
41 |
| - <div class="flex items-end {editing ? 'justify-between' : 'justify-end'}"> |
| 42 | + <div |
| 43 | + class="flex items-end gap-2 {editing ? 'justify-between' : 'justify-end'}" |
| 44 | + > |
42 | 45 | {#if editing}
|
43 |
| - <RadioGroup |
44 |
| - description={translate('workflows.encoding')} |
45 |
| - bind:group={encoding} |
46 |
| - name="encoding" |
47 |
| - > |
48 |
| - <RadioInput id="json/plain" value="json/plain" label="json/plain" /> |
49 |
| - <RadioInput |
50 |
| - id="json/protobuf" |
51 |
| - value="json/protobuf" |
52 |
| - label="json/protobuf" |
53 |
| - /> |
54 |
| - </RadioGroup> |
| 46 | + <div class="flex w-full flex-col gap-2"> |
| 47 | + <RadioGroup |
| 48 | + description={translate('workflows.encoding')} |
| 49 | + bind:group={encoding} |
| 50 | + name="encoding" |
| 51 | + > |
| 52 | + <RadioInput id="json/plain" value="json/plain" label="json/plain" /> |
| 53 | + <RadioInput |
| 54 | + id="json/protobuf" |
| 55 | + value="json/protobuf" |
| 56 | + label="json/protobuf" |
| 57 | + /> |
| 58 | + </RadioGroup> |
| 59 | + {#if $encoding === 'json/protobuf'} |
| 60 | + <Input |
| 61 | + label={translate('workflows.message-type')} |
| 62 | + bind:value={messageType} |
| 63 | + {error} |
| 64 | + id="messageType" |
| 65 | + /> |
| 66 | + {/if} |
| 67 | + </div> |
55 | 68 | {/if}
|
56 | 69 | <slot name="action" />
|
57 | 70 | </div>
|
|
0 commit comments