Skip to content

Commit

Permalink
Merge branch 'main' into DT-1440-accordion-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
laurakwhit committed Sep 10, 2024
2 parents c7b8afd + 7e73a9d commit f08a97a
Show file tree
Hide file tree
Showing 78 changed files with 1,585 additions and 981 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@temporalio/ui",
"version": "2.30.5",
"version": "2.30.6",
"engines": {
"pnpm": ">=8.6.0",
"node": ">=18.15.0"
Expand Down
2 changes: 1 addition & 1 deletion server/server/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ const (
clientNameHeaderName = "client-name"
clientNameHeaderValue = "temporal-ui"
clientVersionHeaderName = "client-version"
UIVersion = "2.30.2"
UIVersion = "2.30.3"
)
67 changes: 43 additions & 24 deletions src/lib/components/schedule/schedule-advanced-settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,47 @@

<ScheduleNotes {notes} />
<Accordion title={translate('schedules.advanced-settings')}>
<p>
{translate('schedules.start-time')}
{spec?.startTime ?? translate('common.none')}
</p>
<p>
{translate('schedules.end-time')}{spec?.endTime ?? translate('common.none')}
</p>
<p>
{translate('schedules.jitter')}{spec?.jitter ?? translate('common.none')}
</p>
<p>
{translate('schedules.exclusion-calendar')}{spec?.excludeCalendar?.[0] ??
translate('common.none')}
</p>
{#if state?.limitedActions}
<p>
{translate('schedules.remaining-actions')}{state?.remainingActions ??
translate('common.none')}
</p>
{/if}
<p>
{translate('schedules.overlap-policy')}{policies?.overlapPolicy ??
translate('common.none')}
</p>
<ul class="settings-list">
<li>
{translate('schedules.start-time')}
<span> {spec?.startTime ?? translate('common.none')}</span>
</li>
<li>
{translate('schedules.end-time')}
<span>{spec?.endTime ?? translate('common.none')} </span>
</li>
<li>
{translate('schedules.jitter')}
<span>{spec?.jitter ?? translate('common.none')} </span>
</li>

<li>
{translate('schedules.exclusion-calendar')}
<span> {spec?.excludeCalendar?.[0] ?? translate('common.none')}</span>
</li>
{#if state?.limitedActions}
<li>
{translate('schedules.remaining-actions')}
<span>{state?.remainingActions ?? translate('common.none')} </span>
</li>
{/if}
<li>
{translate('schedules.overlap-policy')}
<span>{policies?.overlapPolicy ?? translate('common.none')} </span>
</li>
</ul>
</Accordion>

<style lang="postcss">
.settings-list {
@apply w-full;
li {
@apply flex flex-wrap items-center gap-2 border-b py-2 last-of-type:border-b-0;
span {
@apply surface-subtle select-all rounded-sm p-1 leading-4;
}
}
}
</style>
38 changes: 31 additions & 7 deletions src/lib/components/schedule/schedule-form-view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@
import Loading from '$lib/holocene/loading.svelte';
import { translate } from '$lib/i18n/translate';
import { error, loading } from '$lib/stores/schedules';
import type { SearchAttributeInput } from '$lib/stores/search-attributes';
import type {
FullSchedule,
ScheduleParameters,
SchedulePreset,
} from '$lib/types/schedule';
import { decodePayloadAttributes } from '$lib/utilities/decode-payload';
import {
routeForSchedule,
routeForSchedules,
} from '$lib/utilities/route-for';
import { writeActionsAreAllowed } from '$lib/utilities/write-actions-are-allowed';
import AddSearchAttributes from '../workflow/add-search-attributes.svelte';
import ScheduleInputPayload from './schedule-input-payload.svelte';
import type { Schedule } from '$types';
import type { Schedule, SearchAttribute } from '$types';
export let schedule: FullSchedule | null = null;
export let searchAttributes: SearchAttribute = {};
export let onConfirm: (
preset: SchedulePreset,
args: Partial<ScheduleParameters>,
Expand All @@ -52,9 +58,17 @@
let errors = {};
let name = scheduleId ?? '';
let workflowType = schedule?.action?.startWorkflow?.workflowType?.name ?? '';
let workflowId = schedule?.action?.startWorkflow?.workflowId ?? '';
let taskQueue = schedule?.action?.startWorkflow?.taskQueue?.name ?? '';
const decodedWorkflow = decodePayloadAttributes(
schedule?.action?.startWorkflow,
);
const decodedSearchAttributes = decodePayloadAttributes({ searchAttributes });
const indexedFields =
decodedSearchAttributes?.searchAttributes.indexedFields ??
({} as { [k: string]: string });
let workflowType = decodedWorkflow?.workflowType?.name ?? '';
let workflowId = decodedWorkflow?.workflowId ?? '';
let taskQueue = decodedWorkflow?.taskQueue?.name ?? '';
let input = '';
let daysOfWeek: string[] = [];
let daysOfMonth: number[] = [];
Expand All @@ -65,6 +79,9 @@
let second = '';
let phase = '';
let cronString = '';
let searchAttributesInput: SearchAttributeInput[] = Object.entries(
indexedFields,
).map(([attribute, value]) => ({ attribute, value }));
const handleConfirm = (preset: SchedulePreset, schedule?: Schedule) => {
const args: Partial<ScheduleParameters> = {
Expand All @@ -82,6 +99,7 @@
daysOfMonth,
days,
months,
searchAttributes: searchAttributesInput,
};
onConfirm(preset, args, schedule);
Expand Down Expand Up @@ -145,9 +163,7 @@
<h1>{title}</h1>
</header>
<form class="mb-4 flex w-full flex-col gap-4 md:w-2/3 xl:w-1/2">
<Alert intent="error" title="" hidden={!$error}>
{$error}
</Alert>
<Alert intent="error" title={$error} hidden={!$error} />
<div class="w-full">
<Input
id="name"
Expand All @@ -158,6 +174,7 @@
disabled={Boolean(scheduleId)}
on:input={onInput}
on:blur={onBlur}
required
/>
</div>
<div class="w-full">
Expand All @@ -168,6 +185,7 @@
error={errors['workflowType']}
on:input={onInput}
on:blur={onBlur}
required
/>
</div>
<div class="w-full">
Expand All @@ -178,6 +196,7 @@
error={errors['workflowId']}
on:input={onInput}
on:blur={onBlur}
required
/>
</div>
<div class="w-full">
Expand All @@ -188,13 +207,18 @@
error={errors['taskQueue']}
on:input={onInput}
on:blur={onBlur}
required
/>
</div>
<ScheduleInputPayload
bind:input
payloads={schedule?.action?.startWorkflow?.input}
error={errors['input']}
/>
<AddSearchAttributes
bind:attributesToAdd={searchAttributesInput}
class="w-full"
/>
<SchedulesCalendarView
let:preset
{schedule}
Expand Down
37 changes: 37 additions & 0 deletions src/lib/components/schedule/schedule-search-attributes.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script lang="ts">
import Accordion from '$lib/holocene/accordion/accordion.svelte';
import { translate } from '$lib/i18n/translate';
import type { SearchAttribute } from '$lib/types';
import { decodePayloadAttributes } from '$lib/utilities/decode-payload';
import { pluralize } from '$lib/utilities/pluralize';
export let searchAttributes: SearchAttribute;
$: decodedSearchAttributes = decodePayloadAttributes({ searchAttributes });
$: indexedFields =
decodedSearchAttributes?.searchAttributes.indexedFields ?? {};
$: searchAttributeCount = Object.keys(indexedFields).length;
</script>

<Accordion
title={translate('events.custom-search-attributes')}
subtitle={`${searchAttributeCount} ${translate(
'events.custom-search',
)} ${pluralize(translate('events.attribute'), searchAttributeCount)}`}
expandable={searchAttributeCount > 0}
>
{#if searchAttributeCount}
<ul class="w-full">
{#each Object.entries(indexedFields) as [searchAttrName, searchAttrValue]}
<li
class="flex flex-wrap items-center gap-2 border-b py-2 last-of-type:border-b-0"
>
<span class="break-all">{searchAttrName}</span>
<span class="surface-subtle select-all rounded-sm p-1 leading-4"
>{searchAttrValue}</span
>
</li>
{/each}
</ul>
{/if}
</Accordion>
98 changes: 59 additions & 39 deletions src/lib/components/schedule/schedules-table-row.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import WorkflowStatus from '$lib/components/workflow-status.svelte';
import Link from '$lib/holocene/link.svelte';
import { translate } from '$lib/i18n/translate';
import type { ConfigurableTableHeader } from '$lib/stores/configurable-table-columns';
import { relativeTime, timeFormat } from '$lib/stores/time-format';
import { decodePayloadAttributes } from '$lib/utilities/decode-payload';
import { formatDate } from '$lib/utilities/format-date';
import {
routeForEventHistory,
Expand All @@ -18,11 +20,14 @@
let { namespace } = $page.params;
export let schedule: ScheduleListEntry;
export let columns: ConfigurableTableHeader[];
$: spec = schedule?.info?.spec;
$: calendar = spec?.structuredCalendar?.[0];
$: interval = spec?.interval?.[0];
$: timezoneName = spec?.timezoneName || 'UTC';
$: searchAttributes = schedule?.searchAttributes ?? {};
$: decodedAttributes = decodePayloadAttributes({ searchAttributes });
const sortRecentActions = (recentActions: ScheduleActionResult[]) => {
return (
Expand All @@ -43,45 +48,60 @@
</script>

<tr>
<td class="cell">
<WorkflowStatus status={schedule?.info?.paused ? 'Paused' : 'Running'} />
</td>
<td class="cell whitespace-pre-line break-words">
<Link href={route}>{schedule.scheduleId}</Link>
</td>
<td class="cell whitespace-pre-line break-words max-md:hidden">
{schedule?.info?.workflowType?.name ?? ''}
</td>
<td class="cell truncate">
{#each sortRecentActions(schedule?.info?.recentActions) as run}
<p>
<Link
href={routeForEventHistory({
namespace,
workflow: run?.startWorkflowResult?.workflowId,
run: run?.startWorkflowResult?.runId,
})}
>{formatDate(run?.actualTime, $timeFormat, {
relative: $relativeTime,
})}</Link
>
</p>
{/each}
</td>
<td class="cell truncate">
{#each schedule?.info?.futureActionTimes?.slice(0, 5) ?? [] as run}
<div>
{formatDate(run, $timeFormat, {
relative: $relativeTime,
relativeLabel: translate('common.from-now'),
})}
</div>
{/each}
</td>
<td class="cell">
<p>{@html translate('common.timezone', { timezone: timezoneName })}</p>
<ScheduleBasicFrequency {calendar} {interval} />
</td>
{#each columns as { label } (label)}
{#if label === translate('common.status')}
<td class="cell">
<WorkflowStatus
status={schedule?.info?.paused ? 'Paused' : 'Running'}
/>
</td>
{:else if label === translate('schedules.id')}
<td class="cell whitespace-pre-line break-words">
<Link href={route}>{schedule.scheduleId}</Link>
</td>
{:else if label === translate('common.workflow-type')}
<td class="cell whitespace-pre-line break-words">
{schedule?.info?.workflowType?.name ?? ''}
</td>
{:else if label === translate('schedules.recent-runs')}
<td class="cell truncate">
{#each sortRecentActions(schedule?.info?.recentActions) as run}
<p>
<Link
href={routeForEventHistory({
namespace,
workflow: run?.startWorkflowResult?.workflowId,
run: run?.startWorkflowResult?.runId,
})}
>{formatDate(run?.actualTime, $timeFormat, {
relative: $relativeTime,
})}</Link
>
</p>
{/each}
</td>
{:else if label === translate('schedules.upcoming-runs')}
<td class="cell truncate">
{#each schedule?.info?.futureActionTimes?.slice(0, 5) ?? [] as run}
<div>
{formatDate(run, $timeFormat, {
relative: $relativeTime,
relativeLabel: translate('common.from-now'),
})}
</div>
{/each}
</td>
{:else if label === translate('schedules.schedule-spec')}
<td class="cell">
<p>{@html translate('common.timezone', { timezone: timezoneName })}</p>
<ScheduleBasicFrequency {calendar} {interval} />
</td>
{:else}
<td class="cell">
{decodedAttributes?.searchAttributes?.indexedFields?.[label] ?? ''}
</td>
{/if}
{/each}
</tr>

<style lang="postcss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
};
</script>

<ConditionalMenu inputId="duration-filter-search" noBorderLeft>
<ConditionalMenu inputId="duration-filter" noBorderLeft>
<Input
label={$filter.attribute}
labelHidden
id="duration-filter-search"
id="duration-filter"
type="search"
placeholder={`${translate('common.enter')} ${
$filter.attribute
Expand Down
Loading

0 comments on commit f08a97a

Please sign in to comment.