Skip to content

Commit 6492276

Browse files
BrunoQuaresmaammario
authored andcommitted
fix(site): Fix retry on debug mode alert (coder#7686)
1 parent e8223af commit 6492276

File tree

7 files changed

+43
-47
lines changed

7 files changed

+43
-47
lines changed

site/src/components/Alert/Alert.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ import Collapse from "@mui/material/Collapse"
33
// eslint-disable-next-line no-restricted-imports -- It is the base component
44
import MuiAlert, { AlertProps as MuiAlertProps } from "@mui/material/Alert"
55
import Button from "@mui/material/Button"
6+
import Box from "@mui/material/Box"
67

78
export interface AlertProps extends PropsWithChildren {
89
severity: MuiAlertProps["severity"]
9-
actions?: ReactNode[]
10+
actions?: ReactNode
1011
dismissible?: boolean
1112
onRetry?: () => void
1213
onDismiss?: () => void
1314
}
1415

1516
export const Alert: FC<AlertProps> = ({
1617
children,
17-
actions = [],
18+
actions,
1819
onRetry,
1920
dismissible,
2021
severity,
@@ -29,8 +30,7 @@ export const Alert: FC<AlertProps> = ({
2930
action={
3031
<>
3132
{/* CTAs passed in by the consumer */}
32-
{actions.length > 0 &&
33-
actions.map((action) => <div key={String(action)}>{action}</div>)}
33+
{actions}
3434

3535
{/* retry CTA */}
3636
{onRetry && (
@@ -61,3 +61,16 @@ export const Alert: FC<AlertProps> = ({
6161
</Collapse>
6262
)
6363
}
64+
65+
export const AlertDetail = ({ children }: { children: ReactNode }) => {
66+
return (
67+
<Box
68+
component="span"
69+
color={(theme) => theme.palette.text.secondary}
70+
fontSize={13}
71+
data-chromatic="ignore"
72+
>
73+
{children}
74+
</Box>
75+
)
76+
}

site/src/components/Alert/ErrorAlert.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { AlertProps, Alert } from "./Alert"
1+
import { AlertProps, Alert, AlertDetail } from "./Alert"
22
import AlertTitle from "@mui/material/AlertTitle"
3-
import Box from "@mui/material/Box"
43
import { getErrorMessage, getErrorDetail } from "api/errors"
54
import { FC } from "react"
65

@@ -15,14 +14,7 @@ export const ErrorAlert: FC<
1514
{detail ? (
1615
<>
1716
<AlertTitle>{message}</AlertTitle>
18-
<Box
19-
component="span"
20-
color={(theme) => theme.palette.text.secondary}
21-
fontSize={13}
22-
data-chromatic="ignore"
23-
>
24-
{detail}
25-
</Box>
17+
<AlertDetail>{detail}</AlertDetail>
2618
</>
2719
) : (
2820
message

site/src/components/Workspace/Workspace.tsx

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Button from "@mui/material/Button"
22
import { makeStyles } from "@mui/styles"
3-
import RefreshOutlined from "@mui/icons-material/RefreshOutlined"
43
import { Avatar } from "components/Avatar/Avatar"
54
import { AgentRow } from "components/Resources/AgentRow"
65
import { WorkspaceBuildLogs } from "components/WorkspaceBuildLogs/WorkspaceBuildLogs"
@@ -12,7 +11,7 @@ import { FC } from "react"
1211
import { useTranslation } from "react-i18next"
1312
import { useNavigate } from "react-router-dom"
1413
import * as TypesGen from "../../api/typesGenerated"
15-
import { Alert } from "../Alert/Alert"
14+
import { Alert, AlertDetail } from "../Alert/Alert"
1615
import { BuildsTable } from "../BuildsTable/BuildsTable"
1716
import { Margins } from "../Margins/Margins"
1817
import { Resources } from "../Resources/Resources"
@@ -31,6 +30,7 @@ import { ErrorAlert } from "components/Alert/ErrorAlert"
3130
import { ImpendingDeletionBanner } from "components/WorkspaceDeletion"
3231
import { useLocalStorage } from "hooks"
3332
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"
33+
import AlertTitle from "@mui/material/AlertTitle"
3434

3535
export enum WorkspaceErrors {
3636
GET_BUILDS_ERROR = "getBuildsError",
@@ -209,32 +209,23 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
209209

210210
{failedBuildLogs && (
211211
<Stack>
212-
<Alert severity="error">
213-
<Stack
214-
className={styles.fullWidth}
215-
direction="row"
216-
alignItems="center"
217-
justifyContent="space-between"
218-
>
219-
<Stack spacing={0}>
220-
<span>Workspace build failed</span>
221-
<span className={styles.errorDetails}>
222-
{workspace.latest_build.job.error}
223-
</span>
224-
</Stack>
225-
226-
{canUpdateTemplate && (
227-
<div>
228-
<Button
229-
onClick={handleBuildRetry}
230-
startIcon={<RefreshOutlined />}
231-
size="small"
232-
>
233-
{t("actionButton.retryDebugMode")}
234-
</Button>
235-
</div>
236-
)}
237-
</Stack>
212+
<Alert
213+
severity="error"
214+
actions={
215+
canUpdateTemplate && (
216+
<Button
217+
key={0}
218+
onClick={handleBuildRetry}
219+
variant="text"
220+
size="small"
221+
>
222+
{t("actionButton.retryDebugMode")}
223+
</Button>
224+
)
225+
}
226+
>
227+
<AlertTitle>Workspace build failed</AlertTitle>
228+
<AlertDetail>{workspace.latest_build.job.error}</AlertDetail>
238229
</Alert>
239230
<WorkspaceBuildLogs logs={failedBuildLogs} />
240231
</Stack>

site/src/components/WorkspaceDeletedBanner/WorkspaceDeletedBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const WorkspaceDeletedBanner: FC<
1919
)
2020

2121
return (
22-
<Alert severity="warning" actions={[NewWorkspaceButton]}>
22+
<Alert severity="warning" actions={NewWorkspaceButton}>
2323
{t("warningsAndErrors.workspaceDeletedWarning")}
2424
</Alert>
2525
)

site/src/i18n/en/common.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"stopped": "Stopped",
99
"deleting": "Deleting",
1010
"deleted": "Deleted",
11-
"canceling": "Canceling action",
12-
"canceled": "Canceled action",
11+
"canceling": "Canceling",
12+
"canceled": "Canceled",
1313
"failed": "Failed",
1414
"pending": "Pending"
1515
},

site/src/i18n/en/workspacePage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"stopping": "Stopping...",
3131
"deleting": "Deleting...",
3232
"settings": "Settings",
33-
"retryDebugMode": "Try again in debug mode"
33+
"retryDebugMode": "Try in debug mode"
3434
},
3535
"disabledButton": {
3636
"canceling": "Canceling",

site/src/pages/DeploySettingsPage/GitAuthSettingsPage/GitAuthSettingsPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const GitAuthSettingsPageView = ({
4040
/>
4141

4242
<div className={styles.description}>
43-
<Alert severity="info" actions={[<EnterpriseBadge key="enterprise" />]}>
43+
<Alert severity="info" actions={<EnterpriseBadge key="enterprise" />}>
4444
Integrating with multiple Git providers is an Enterprise feature.
4545
</Alert>
4646
</div>

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