Skip to content

Commit e25b978

Browse files
committed
fix: display error when a build fails on template editor
1 parent 5762d8a commit e25b978

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

site/src/components/GlobalSnackbar/GlobalSnackbar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const GlobalSnackbar: FC = () => {
5151
<ErrorIcon css={styles.errorIcon} />
5252
)}
5353

54-
<div css={{ maxWidth: 670 }}>
54+
<div className="max-w-[670px] flex flex-col">
5555
<span css={styles.messageTitle}>{notificationMsg.msg}</span>
5656

5757
{notificationMsg.additionalMsgs?.map((msg, index) => (
@@ -104,7 +104,10 @@ const styles = {
104104
fontWeight: 600,
105105
},
106106
messageSubtitle: {
107-
marginTop: 12,
107+
marginTop: 4,
108+
"&:first-letter": {
109+
textTransform: "uppercase",
110+
},
108111
},
109112
errorIcon: (theme) => ({
110113
color: theme.palette.error.contrastText,

site/src/pages/TemplateVersionEditorPage/TemplateVersionEditor.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Button from "@mui/material/Button";
88
import ButtonGroup from "@mui/material/ButtonGroup";
99
import IconButton from "@mui/material/IconButton";
1010
import Tooltip from "@mui/material/Tooltip";
11+
import { getErrorDetail, getErrorMessage } from "api/errors";
1112
import type {
1213
ProvisionerJobLog,
1314
Template,
@@ -26,6 +27,7 @@ import {
2627
TopbarDivider,
2728
TopbarIconButton,
2829
} from "components/FullPageLayout/Topbar";
30+
import { displayError } from "components/GlobalSnackbar/utils";
2931
import { Loader } from "components/Loader/Loader";
3032
import { linkToTemplate, useLinks } from "modules/navigation";
3133
import { ProvisionerAlert } from "modules/provisioners/ProvisionerAlert";
@@ -132,8 +134,15 @@ export const TemplateVersionEditor: FC<TemplateVersionEditorProps> = ({
132134
const availableProvisioners = templateVersion.matched_provisioners?.available;
133135

134136
const triggerPreview = useCallback(async () => {
135-
await onPreview(fileTree);
136-
setSelectedTab("logs");
137+
try {
138+
await onPreview(fileTree);
139+
setSelectedTab("logs");
140+
} catch (error) {
141+
displayError(
142+
getErrorMessage(error, "Error on previewing the template"),
143+
getErrorDetail(error),
144+
);
145+
}
137146
}, [fileTree, onPreview]);
138147

139148
// Stop ctrl+s from saving files and make ctrl+enter trigger a preview.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy