8000 Only query workflow metadata for running workflows by Alex-Tideman · Pull Request #2560 · temporalio/ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Only query workflow metadata for running workflows #2560

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

Merged
merged 7 commits into from
Feb 19, 2025
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
132 changes: 132 additions & 0 deletions server/server/route/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,138 @@ func SetRenderRoute(e *echo.Echo, publicPath string) {
Content: template.HTML(renderedHTML),
Nonce: nonce,
Theme: theme,
CSS: `*,
body {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
vertical-align: baseline;
}

body {
overscroll-behavior: none;
position: relative;
padding: 1rem;
white-space: pre-line;
font-family: sans-serif;
}

h1 {
font-size: 2em;
}

h2 {
font-size: 1.5em;
}

h3 {
font-size: 1.17em;
}

h4 {
font-size: 1em;
}

h5 {
font-size: 0.83em;
}

h6 {
font-size: 0.67em;
}

blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}

table {
border-collapse: collapse;
border-spacing: 0;
}

ul,
ol {
white-space: normal;
}

li {
list-style-position: inside;
}

li * {
display: inline;
}

a {
gap: 0.5rem;
align-items: center;
border-radius: 0.25rem;
max-width: fit-content;
text-decoration: underline;
text-underline-offset: 2px;
cursor: pointer;
}

blockquote {
padding-top: 0;
padding-bottom: 0;
padding-left: 0.5rem;
border-left: 4px solid;
border-left-color: #92a4c3;
background: #e8efff;
color: #121416;
p {
font-size: 1.25rem;
line-height: 1.75rem;
}
}

code {
font-family: monospace;
padding-top: 0.125rem;
padding-bottom: 0.125rem;
padding-left: 0.25rem;
padding-right: 0.25rem;
border-radius: 0.25rem;
background: #e8efff;
color: #121416;
}

pre {
font-family: monospace;
padding: 0.25rem;
border-radius: 0.25rem;
background: #e8efff;
color: #121416;
code {
padding: 0;
}
}

body[data-theme='light'] {
background-color: #fff;
color: #121416;
a {
color: #444ce7;
}
}

body[data-theme='dark'] {
background-color: #141414;
color: #f8fafc;
a {
color: #8098f9;
}
}`,
}

// Set headers
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<script lang="ts">
import { page } from '$app/stores';

import AccordionLight from '$lib/holocene/accordion/accordion-light.svelte';
import Button from '$lib/holocene/button.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
import Markdown from '$lib/holocene/monaco/markdown.svelte';
import Tooltip from '$lib/holocene/tooltip.svelte';
import { translate } from '$lib/i18n/translate';
import { getWorkflowMetadata } from '$lib/services/query-service';
import { authUser } from '$lib/stores/auth-user';
import { workflowRun } from '$lib/stores/workflow-run';

$: ({ namespace } = $page.params);
$: ({ workflow } = $workflowRun);
$: currentDetails = $workflowRun?.metadata?.currentDetails || '';
$: closedWithoutDetails = !workflow.isRunning && !currentDetails;

let loading = false;

const fetchCurrentDetails = async () => {
if (loading) return;
loading = true;
try {
const { settings } = $page.data;
const metadata = await getWorkflowMetadata(
{
namespace,
workflow: {
id: workflow.id,
runId: workflow.runId,
},
},
settings,
$authUser?.accessToken,
);
$workflowRun.metadata = metadata;
} catch (error) {
console.error('Error fetching current details:', error);
} finally {
loading = false;
}
};
</script>

<AccordionLight
let:open
? fetchCurrentDetails : undefined}
icon={closedWithoutDetails ? 'retry' : undefined}
>
<div slot="title" class="flex w-full items-center gap-2 p-2 text-xl">
<Icon name="flag" class="text-brand" width={32} height={32} />
{translate('workflows.current-details')}
{#if loading}{translate('common.loading')}{/if}
</div>
{#if open}
{#key currentDetails}
<Markdown content={currentDetails} />
{/key}
{/if}
<svelte:fragment slot="action">
{#if workflow.isRunning}
<Tooltip text={translate('workflows.update-details')} left>
<Button
variant="ghost"
on:click={fetchCurrentDetails}
disabled={loading}
>
<Icon name="retry" />
</Button>
</Tooltip>
{/if}
</svelte:fragment>
</AccordionLight>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script lang="ts">
import AccordionLight from '$lib/holocene/accordion/accordion-light.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
import Markdown from '$lib/holocene/monaco/markdown.svelte';
import { translate } from '$lib/i18n/translate';
import { workflowRun } from '$lib/stores/workflow-run';

$: summary = $workflowRun?.userMetadata?.summary;
$: details = $workflowRun?.userMetadata?.details;
$: hasUserMetadata = summary || details;
</script>

{#if hasUserMetadata}
<AccordionLight let:open>
<div slot="title" class="flex w-full items-center gap-2 p-2 text-xl">
<Icon name="info" class="text-brand" width={32} height={32} />{translate(
'workflows.summary-and-details',
)}
</div>
{#if open && summary}
<h3>{translate('workflows.summary')}</h3>
<Markdown content={summary} />
{/if}
{#if open && details}
<h3>{translate('workflows.details')}</h3>
<Markdown content={details} />
{/if}
</AccordionLight>
{/if}
27 changes: 13 additions & 14 deletions src/lib/holocene/accordion/accordion-light.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { noop } from 'svelte/internal';
import { slide } from 'svelte/transition';

import { v4 } from 'uuid';
Expand All @@ -14,17 +13,22 @@
open?: boolean;
expandable?: boolean;
error?: string;
onToggle?: () => void;
onToggle?: () => Promise<void>;
'data-testid'?: string;
}

export let id: string = v4();
export let open = false;
export let >
export let >
export let icon: IconName | undefined = undefined;

const toggleAccordion = () => {
open = !open;
onToggle();
const toggleAccordion = async () => {
if (onToggle) {
await onToggle();
open = !open;
} else {
open = !open;
}
};
</script>

Expand All @@ -37,17 +41,12 @@
type="button"
on:click={toggleAccordion}
>
<div class="flex w-full flex-row items-center justify-between gap-2">
<div class="flex w-full flex-row items-center justify-between gap-2 pr-4">
<slot name="title" />
<slot name="description" />
<div
class="flex flex-row items-center gap-2 pr-2"
on:click|stopPropagation
on:keyup|stopPropagation
role="none"
>
<div class="flex items-center gap-4">
<slot name="action" />
<Icon class="m-2 shrink-0" name={open ? 'arrow-down' : 'arrow-right'} />
<Icon name={icon ? icon : open ? 'arrow-down' : 'arrow-right'} />
</div>
</div>
</button>
Expand Down
2 changes: 2 additions & 0 deletions src/lib/i18n/locales/en/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,6 @@ export const Strings = {
'Markdown is supported in the summary and details fields. You can use {namespace}, {workflowId} or {runId} syntax in link href to create dynamic links based on the page you are on. Images are not allowed.',
'update-id': 'Update ID (optional)',
'update-name-label': 'Update name',
'no-current-details': 'No Current Details',
'update-details': 'Update Details',
} as const;
46 changes: 4 additions & 42 deletions src/lib/layouts/workflow-header.svelte
9DF3
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import { page } from '$app/stores';

import WorkflowDetails from '$lib/components/lines-and-dots/workflow-details.svelte';
import WorkflowCurrentDetails from '$lib/components/workflow/metadata/workflow-current-details.svelte';
import WorkflowSummaryAndDetails from '$lib/components/workflow/metadata/workflow-summary-and-details.svelte';
import WorkflowActions from '$lib/components/workflow-actions.svelte';
import WorkflowStatus from '$lib/components/workflow-status.svelte';
import WorkflowVersioningHeader from '$lib/components/workflow-versioning-header.svelte';
import AccordionLight from '$lib/holocene/accordion/accordion-light.svelte';
import Alert from '$lib/holocene/alert.svelte';
import Badge from '$lib/holocene/badge.svelte';
import Copyable from '$lib/holocene/copyable/index.svelte';
import Icon from '$lib/holocene/icon/icon.svelte';
import Link from '$lib/holocene/link.svelte';
import Markdown from '$lib/holocene/monaco/markdown.svelte';
import TabList from '$lib/holocene/tab/tab-list.svelte';
import Tab from '$lib/holocene/tab/tab.svelte';
import Tabs from '$lib/holocene/tab/tabs.svelte';
Expand Down Expand Up @@ -64,11 +64,6 @@
$fullEventHistory,
$namespaces,
);

$: summary = $workflowRun?.userMetadata?.summary;
$: details = $workflowRun?.userMetadata?.details;
$: hasUserMetadata = summary || details;
$: currentDetails = $workflowRun?.metadata?.currentDetails;
</script>

<div class="flex items-center justify-between pb-4">
Expand Down Expand Up @@ -138,41 +133,8 @@
<WorkflowActions {isRunning} {cancelInProgress} {workflow} {namespace} />
</div>
</div>
{#if hasUserMetadata}
<AccordionLight let:open>
<div slot="title" class="flex w-full items-center gap-2 p-2 text-xl">
<Icon
name="info"
class="text-brand"
width={32}
height={32}
/>{translate('workflows.summary-and-details')}
</div>
{#if open && summary}
<h3>{translate('workflows.summary')}</h3>
<Markdown content={summary} />
{/if}
{#if open && details}
<h3>{translate('workflows.details')}</h3>
<Markdown content={details} />
{/if}
</AccordionLight>
{/if}
{#if currentDetails}
<AccordionLight let:open>
<div slot="title" class="flex w-full items-center gap-2 p-2 text-xl">
<Icon
name="flag"
class="text-brand"
width={32}
height={32}
/>{translate('workflows.current-details')}
</div>
{#if open}
<Markdown content={currentDetails} />
{/if}
</AccordionLight>
{/if}
<WorkflowSummaryAndDetails />
<WorkflowCurrentDetails />
<WorkflowDetails {workflow} />
{#if cancelInProgress}
<div in:fly={{ duration: 200, delay: 100 }}>
Expand Down
Loading
Loading
0