Skip to content

Commit 7e300ae

Browse files
matifaliclaude
andcommitted
feat: show popup notification on successful template build
This change adds a success notification when a template build completes successfully, making it more obvious to users when the build has finished. Fixes #18364 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c1341cc commit 7e300ae

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

site/src/pages/TemplateVersionEditorPage/TemplateVersionEditorPage.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import type {
1212
PatchTemplateVersionRequest,
1313
TemplateVersion,
1414
} from "api/typesGenerated";
15-
import { displayError } from "components/GlobalSnackbar/utils";
15+
import { displayError, displaySuccess } from "components/GlobalSnackbar/utils";
1616
import { Loader } from "components/Loader/Loader";
1717
import { linkToTemplate, useLinks } from "modules/navigation";
1818
import { useWatchVersionLogs } from "modules/templates/useWatchVersionLogs";
19-
import { type FC, useEffect, useState } from "react";
19+
import { type FC, useEffect, useRef, useState } from "react";
2020
import { Helmet } from "react-helmet-async";
2121
import {
2222
keepPreviousData,
@@ -122,11 +122,31 @@ const TemplateVersionEditorPage: FC = () => {
122122
const [provisionerTags, setProvisionerTags] = useState<
123123
Record<string, string>
124124
>({});
125+
// Track previous job status to detect when a build completes successfully
126+
const previousJobStatus = useRef<string | undefined>(undefined);
125127
useEffect(() => {
126128
if (activeTemplateVersion?.job.tags) {
127129
setProvisionerTags(activeTemplateVersion.job.tags);
128130
}
129131
}, [activeTemplateVersion?.job.tags]);
132+
133+
// Show notification when build succeeds
134+
useEffect(() => {
135+
if (!activeTemplateVersion || !templateQuery.data) {
136+
return;
137+
}
138+
139+
// Only show notification when status changes from running/pending to succeeded
140+
if (previousJobStatus.current &&
141+
["running", "pending"].includes(previousJobStatus.current) &&
142+
activeTemplateVersion.job.status === "succeeded") {
143+
const templateName = templateQuery.data.display_name || templateQuery.data.name;
144+
displaySuccess(`Template ${templateName} (${activeTemplateVersion.name}) built successfully`);
145+
}
146+
147+
// Update the previous status for next comparison
148+
previousJobStatus.current = activeTemplateVersion.job.status;
149+
}, [activeTemplateVersion?.job.status, templateQuery.data]);
130150

131151
return (
132152
<>

0 commit comments

Comments
 (0)