File tree Expand file tree Collapse file tree 1 file changed +22
-33
lines changed
site/src/components/Alert Expand file tree Collapse file tree 1 file changed +22
-33
lines changed Original file line number Diff line number Diff line change @@ -15,41 +15,30 @@ export const ErrorAlert: FC<
15
15
// not make sense in the FE to showing them duplicated
16
16
const shouldDisplayDetail = message !== detail ;
17
17
18
- const body = ( ) => {
19
- // When the error is a Forbidden response we include a link for the user to
20
- // go back to a known viewable page.
21
- // Additionally since the error messages and details from the server can be
22
- // missing or confusing for an end user we render a friendlier message
23
- // regardless of the response from the server.
24
- if ( status === 403 ) {
25
- return (
26
- < >
27
- < AlertTitle > { message } </ AlertTitle >
28
- < AlertDetail >
29
- { detail } { " " }
30
- < Link href = "/workspaces" className = "w-fit" >
31
- Go to workspaces
32
- </ Link >
33
- </ AlertDetail >
34
- </ >
35
- ) ;
36
- }
37
-
38
- if ( detail ) {
39
- return (
40
- < >
41
- < AlertTitle > { message } </ AlertTitle >
42
- { shouldDisplayDetail && < AlertDetail > { detail } </ AlertDetail > }
43
- </ >
44
- ) ;
45
- }
46
-
47
- return message ;
48
- } ;
49
-
50
18
return (
51
19
< Alert severity = "error" { ...alertProps } >
52
- { body ( ) }
20
+ {
21
+ // When the error is a Forbidden response we include a link for the user to
22
+ // go back to a known viewable page.
23
+ status === 403 ? (
24
+ < >
25
+ < AlertTitle > { message } </ AlertTitle >
26
+ < AlertDetail >
27
+ { detail } { " " }
28
+ < Link href = "/workspaces" className = "w-fit" >
29
+ Go to workspaces
30
+ </ Link >
31
+ </ AlertDetail >
32
+ </ >
33
+ ) : detail ? (
34
+ < >
35
+ < AlertTitle > { message } </ AlertTitle >
36
+ { shouldDisplayDetail && < AlertDetail > { detail } </ AlertDetail > }
37
+ </ >
38
+ ) : (
39
+ message
40
+ )
41
+ }
53
42
</ Alert >
54
43
) ;
55
44
} ;
You can’t perform that action at this time.
0 commit comments