Skip to content

Commit 6b1c1bd

Browse files
committed
Add 'dismiss pipeline error' button
Improve detection of error message overflow in the case of long single-line message Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
1 parent abe856d commit 6b1c1bd

File tree

7 files changed

+357
-47
lines changed

7 files changed

+357
-47
lines changed

js-packages/web-console/src/lib/components/layout/pipelines/PipelineEditLayout.svelte

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
)
9393
9494
const { updatePipelines } = useUpdatePipelineList()
95+
const api = usePipelineManager()
9596
const pipelineAction = getPipelineAction()
9697
const pipelineActionCallbacks = usePipelineActionCallbacks()
9798
const handleActionSuccess = async (pipelineName: string, action: PipelineAction) => {
@@ -242,7 +243,8 @@ example = "1.0"`
242243
return {
243244
header: `The last execution of the pipeline failed with the error code: ${pipeline.current.deploymentError.error_code}`,
244245
message: pipeline.current.deploymentError.message,
245-
style: 'error' as const
246+
style: 'error' as const,
247+
onClose: () => api.dismissDeploymentError(pipeline.current.name)
246248
}
247249
} else if (pipeline.current.status === 'AwaitingApproval') {
248250
return {
@@ -435,12 +437,7 @@ example = "1.0"`
435437
<PaneGroup direction="vertical" class="!overflow-visible">
436438
{#if pipelineBannerMessage}
437439
<div class="pb-2 md:pb-4">
438-
<PipelineBanner
439-
header={pipelineBannerMessage.header}
440-
message={pipelineBannerMessage.message}
441-
actions={pipelineBannerMessage.actions ?? []}
442-
style={pipelineBannerMessage.style}
443-
></PipelineBanner>
440+
<PipelineBanner {...pipelineBannerMessage}></PipelineBanner>
444441
</div>
445442
{/if}
446443
<CodeEditor

js-packages/web-console/src/lib/components/pipelines/editor/PipelineBanner.svelte

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,44 @@
66
header,
77
message,
88
actions = [],
9-
style
9+
style,
10+
onClose
1011
}: {
1112
header: string
1213
message?: string
1314
actions?: {
1415
label: string
1516
onclick: () => void
1617
}[]
18+
onClose?: () => void
1719
style: 'info' | 'warning' | 'error'
1820
} = $props()
1921
let showMore = $state(false)
22+
let spanEl: HTMLElement | undefined = $state()
23+
let isTruncated = $state(false)
24+
25+
// Track whether the message overflows its single visible line (line-clamp-1).
26+
// Skipped while expanded (showMore) to preserve isTruncated=true for "Show less".
27+
// ResizeObserver keeps the check in sync as the viewport width changes.
28+
$effect(() => {
29+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
30+
message // re-run the effect when message changes
31+
32+
if (!spanEl || showMore) {
33+
return
34+
}
35+
36+
const checkTruncation = () => {
37+
isTruncated = spanEl!.scrollHeight > spanEl!.clientHeight
38+
}
39+
40+
const observer = new ResizeObserver(checkTruncation)
41+
observer.observe(spanEl)
42+
checkTruncation()
43+
44+
return () => observer.disconnect()
45+
})
46+
2047
const textClass = $derived(
2148
style === 'info'
2249
? 'text-surface-950-50'
@@ -45,18 +72,29 @@
4572
<div class=" flex w-full flex-col">
4673
<div class="flex justify-between pb-2 font-semibold">
4774
<span class={textClass}>{header}</span>
48-
{#if message}
49-
<ClipboardCopyButton value={message} class="-m-2"></ClipboardCopyButton>
50-
{/if}
75+
<div class="flex flex-nowrap gap-4">
76+
{#if message}
77+
<ClipboardCopyButton value={message} class="-m-2"></ClipboardCopyButton>
78+
{/if}
79+
{#if onClose}
80+
<button
81+
onclick={onClose}
82+
class="fd fd-x -m-2 btn-icon text-[24px]"
83+
aria-label="Dismiss pipeline deployment error"
84+
>
85+
</button>
86+
{/if}
87+
</div>
5188
</div>
5289
<span
90+
bind:this={spanEl}
5391
class="{textClass} break-all whitespace-pre-wrap {showMore
5492
? 'scrollbar max-h-[30vh] overflow-auto '
5593
: 'line-clamp-1'}"
5694
>
5795
{message}
5896
</span>
59-
{#if message && message.indexOf('\n') !== -1}
97+
{#if message && isTruncated}
6098
<button
6199
onclick={() => {
62100
showMore = !showMore

js-packages/web-console/src/lib/compositions/usePipelineManager.svelte.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
collectSamplyProfile,
77
deleteApiKey,
88
deletePipeline,
9+
dismissDeploymentError,
910
type FetchOptions,
1011
getApiKeys,
1112
getAuthConfig,
@@ -197,6 +198,10 @@ export const usePipelineManager = (options?: FetchOptions) => {
197198
return x
198199
},
199200
deleteApiKey: reportError(deleteApiKey, (keyName) => `Failed to delete ${keyName} API key`),
201+
dismissDeploymentError: reportError(
202+
dismissDeploymentError,
203+
(pipelineName) => `Failed to dismiss deployment error for ${pipelineName} pipeline`
204+
),
200205
getClusterEvents: reportError(getClusterEvents),
201206
getClusterEvent: reportError(getClusterEvent),
202207
getSamplyProfile: reportError(getSamplyProfile),

js-packages/web-console/src/lib/services/manager/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export {
4545
postPipelineActivate,
4646
postPipelineApprove,
4747
postPipelineClear,
48+
postPipelineDismissError,
4849
postPipelineInputConnectorAction,
4950
postPipelinePause,
5051
postPipelineRebalance,
@@ -90,6 +91,7 @@ export type {
9091
ColumnType,
9192
CombinedDesiredStatus,
9293
CombinedStatus,
94+
CommitProgressSummary,
9395
CommitTransactionData,
9496
CommitTransactionError,
9597
CommitTransactionErrors,
@@ -366,6 +368,7 @@ export type {
366368
PostApiKeyResponse,
367369
PostApiKeyResponses,
368370
PostgresReaderConfig,
371+
PostgresTlsConfig,
369372
PostgresWriteMode,
370373
PostgresWriterConfig,
371374
PostPipelineActivateData,
@@ -383,6 +386,10 @@ export type {
383386
PostPipelineClearErrors,
384387
PostPipelineClearResponses,
385388
PostPipelineData,
389+
PostPipelineDismissErrorData,
390+
PostPipelineDismissErrorError,
391+
PostPipelineDismissErrorErrors,
392+
PostPipelineDismissErrorResponses,
386393
PostPipelineError,
387394
PostPipelineErrors,
388395
PostPipelineInputConnectorActionData,

js-packages/web-console/src/lib/services/manager/sdk.gen.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ import type {
129129
PostPipelineClearErrors,
130130
PostPipelineClearResponses,
131131
PostPipelineData,
132+
PostPipelineDismissErrorData,
133+
PostPipelineDismissErrorErrors,
134+
PostPipelineDismissErrorResponses,
132135
PostPipelineErrors,
133136
PostPipelineInputConnectorActionData,
134137
PostPipelineInputConnectorActionErrors,
@@ -726,6 +729,27 @@ export const getPipelineDataflowGraph = <ThrowOnError extends boolean = false>(
726729
...options
727730
})
728731

732+
/**
733+
* Dismiss Pipeline Deployment Error
734+
*
735+
* Clears the `deployment_error` field of the pipeline, such that a subsequent call to
736+
* `/start?dismiss_error=false` succeeds. It will return an error if the pipeline is not fully
737+
* stopped (i.e., both current and desired status must be `Stopped`) AND a deployment error
738+
* is present.
739+
*/
740+
export const postPipelineDismissError = <ThrowOnError extends boolean = false>(
741+
options: Options<PostPipelineDismissErrorData, ThrowOnError>
742+
) =>
743+
(options.client ?? client).post<
744+
PostPipelineDismissErrorResponses,
745+
PostPipelineDismissErrorErrors,
746+
ThrowOnError
747+
>({
748+
security: [{ scheme: 'bearer', type: 'http' }],
749+
url: '/v0/pipelines/{pipeline_name}/dismiss_error',
750+
...options
751+
})
752+
729753
/**
730754
* Subscribe to View
731755
*

0 commit comments

Comments
 (0)