8000 Allow Terminate for closed workflows with newExecutionRunId by Alex-Tideman · Pull Request #2724 · temporalio/ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow Terminate for closed workflows with newExecutionRunId #2724

New issue

Have a question a 8000 bout 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
May 29, 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
28 changes: 28 additions & 0 deletions src/lib/components/lines-and-dots/workflow-details.svelte
8000
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { page } from '$app/stores';

import { translate } from '$lib/i18n/translate';
import { fetchWorkflow } from '$lib/services/workflow-service';
import { isCloud } from '$lib/stores/advanced-visibility';
import { relativeTime, timeFormat } from '$lib/stores/time-format';
import type { WorkflowExecution } from '$lib/types/workflows';
Expand All @@ -18,6 +19,8 @@
import WorkflowDetail from './workflow-detail.svelte';

export let workflow: WorkflowExecution;
export let next: string | undefined = undefined;
let latestRunId: string | undefined = undefined;

$: ({ namespace } = $page.params);

Expand All @@ -36,6 +39,20 @@
workflow?.searchAttributes?.indexedFields?.[
'TemporalWorkflowVersioningBehavior'
];

$: {
if (next && !latestRunId) {
fetchLatestRun();
}
}

const fetchLatestRun = async () => {
const result = await fetchWorkflow({
namespace,
workflowId: workflow.id,
});
latestRunId = result?.workflow?.runId;
};
</script>

<div
Expand Down Expand Up @@ -145,6 +162,17 @@
})}
/>
{/if}
{#if latestRunId}
<WorkflowDetail
title={translate('workflows.latest-execution')}
content={latestRunId}
href={routeForWorkflow({
namespace,
workflow: workflow?.id,
run: latestRunId,
})}
/>
{/if}
<WorkflowDetail
title={translate('common.history-size-bytes')}
content={workflow?.historySizeBytes}
Expand Down
30 changes: 15 additions & 15 deletions src/lib/components/workflow-actions.svelte
Original file line number Diff line numbe 8000 r Diff line change
Expand Up @@ -7,10 +7,8 @@
import SignalConfirmationModal from '$lib/components/workflow/client-actions/signal-confirmation-modal.svelte';
import TerminateConfirmationModal from '$lib/components/workflow/client-actions/terminate-confirmation-modal.svelte';
import UpdateConfirmationModal from '$lib/components/workflow/client-actions/update-confirmation-modal.svelte';
import Button from '$lib/holocene/button.svelte';
import { MenuDivider, MenuItem } from '$lib/holocene/menu';
import SplitButton from '$lib/holocene/split-button.svelte';
import Tooltip from '$lib/holocene/tooltip.svelte';
import { translate } from '$lib/i18n/translate';
import { isCloud } from '$lib/stores/advanced-visibility';
import { coreUserStore } from '$lib/stores/core-user';
Expand All @@ -31,6 +29,8 @@
export let namespace: string;
export let cancelInProgress: boolean;
export let isRunning: boolean;
export let first: string | undefined = undefined;
export let next: string | undefined = undefined;

let cancelConfirmationModalOpen = false;
let terminateConfirmationModalOpen = false;
Expand Down Expand Up @@ -186,7 +186,7 @@
</MenuItem>
{/if}
</SplitButton>
{:else if !workflowCreateDisabled($page)}
{:else}
<SplitButton
id="workflow-actions"
menuClass="w-[16rem]"
Expand All @@ -206,23 +206,22 @@
workflowType: workflow.name,
}),
)}
disabled={workflowCreateDisabled($page)}
8000
data-testid="start-workflow-button"
>
{translate('workflows.start-workflow-like-this-one')}
</MenuItem>
{#if terminateEnabled && next}
<MenuDivider />
<MenuItem
on:click={() => (terminateConfirmationModalOpen = true)}
data-testid="terminate-button"
destructive
>
{translate('workflows.terminate-latest')}
</MenuItem>
{/if}
</SplitButton>
{:else}
<Tooltip bottomRight width={200} text={resetDescription} hide={resetEnabled}>
<Button
aria-label={translate('workflows.reset')}
disabled={!resetEnabled}
variant="primary"
on:click={() => (resetConfirmationModalOpen = true)}
data-testid="workflow-reset-button"
>
{translate('workflows.reset')}
</Button>
</Tooltip>
{/if}

{#if resetEnabled}
Expand Down Expand Up @@ -265,6 +264,7 @@
{refresh}
{workflow}
{namespace}
{first}
bind:open={terminateConfirmationModalOpen}
/>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
export let workflow: WorkflowExecution;
export let namespace: string;
export let refresh: Writable<number>;
export let first: string | undefined = undefined;

let reason: string = '';
let error: string = '';
Expand All @@ -31,6 +32,7 @@
workflow,
namespace,
reason,
first,
});
open = false;
reason = '';
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 @@ -11,6 +11,7 @@ export const Strings = {
'filtered-workflows-count':
'Results {{filtered, number}} of {{total, number}} workflows',
terminate: 'Terminate',
'terminate-latest': 'Terminate Latest Run',
'batch-terminate-modal-title': 'Terminate Workflows',
'batch-cancel-modal-title': 'Cancel Workflows',
'batch-reset-modal-title': 'Reset Workflows',
Expand Down Expand Up @@ -156,6 +157,7 @@ export const Strings = {
'first-execution': 'First Execution',
'previous-execution': 'Previous Execution',
'current-execution': 'Current Execution',
'latest-execution': 'Latest Execution',
'next-execution': 'Next Execution',
'child-id': 'Child Workflow ID',
'child-run-id': 'Child Run ID',
Expand Down
13 changes: 11 additions & 2 deletions src/lib/layouts/workflow-header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
{cancelInProgress}
{workflow}
{namespace}
first={workflowRelationships.first}
next={workflowRelationships.next}
/>
</div>
</div>
Expand All @@ -126,13 +128,20 @@
</div>
</div>
<div class="max-lg:hidden">
<WorkflowActions {isRunning} {cancelInProgress} {workflow} {namespace} />
<WorkflowActions
{isRunning}
{cancelInProgress}
{workflow}
{namespace}
first={workflowRelationships.first}
next={workflowRelationships.next}
/>
</div>
</div>
<CodecServerErrorBanner />
<WorkflowSummaryAndDetails />
<WorkflowCurrentDetails />
<WorkflowDetails {workflow} />
<WorkflowDetails {workflow} next={workflowRelationships.next} />
{#if cancelInProgress}
<div in:fly={{ duration: 200, delay: 100 }}>
<Alert
Expand Down
21 changes: 14 additions & 7 deletions src/lib/services/workflow-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import { fetchWorkflowCountByExecutionStatus } from './workflow-counts';

export type GetWorkflowExecutionRequest = NamespaceScopedRequest & {
workflowId: string;
runId: string;
runId?: string;
};

export type CombinedWorkflowExecutionsResponse = {
Expand Down Expand Up @@ -128,6 +128,7 @@ type TerminateWorkflowOptions = {
workflow: WorkflowExecution;
namespace: string;
reason: string;
first: string | undefined;
};

export type ResetWorkflowOptions = {
Expand Down Expand Up @@ -277,9 +278,11 @@ export async function fetchWorkflow(
return requestFromAPI(route, {
request,
notifyOnError: false,
params: {
'execution.runId': parameters.runId,
},
params: parameters.runId
? {
'execution.runId': parameters.runId,
}
: {},
})
.then((response) => {
return { workflow: toWorkflowExecution(response) };
Expand All @@ -293,6 +296,7 @@ export async function terminateWorkflow({
workflow,
namespace,
reason,
first,
}: TerminateWorkflowOptions): Promise<null> {
const route = routeForApi('workflow.terminate', {
namespace,
Expand All @@ -312,12 +316,15 @@ export async function terminateWorkflow({
body: stringifyWithBigInt({
reason: formattedReason,
...(email && { identity: email }),
firstExecutionRunId: first,
}),
},
notifyOnError: false,
params: {
'execution.runId': workflow.runId,
},
params: first
? {}
: {
'execution.runId': workflow.runId,
},
});
}

Expand Down
Loading
Loading
0