File tree Expand file tree Collapse file tree
src/frontend/apps/impress/src
features/docs/doc-versioning/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ and this project adheres to
1313### Changed
1414
1515- 💄(frontend) improve comments highlights #1961
16+ - ♿️(frontend) structure correctly 5xx error alerts #2128
1617
1718## [ v4.8.3] - 2026-03-23
1819
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
44import styled from 'styled-components' ;
55
66import { Box , Text , TextType } from '@/components' ;
7+ import { useHttpErrorMessages } from '@/hooks' ;
78
89const AlertStyled = styled ( Alert ) `
910 & .c__button--tertiary:hover {
@@ -16,13 +17,15 @@ interface TextErrorsProps extends TextType {
1617 defaultMessage ?: string ;
1718 icon ?: ReactNode ;
1819 canClose ?: boolean ;
20+ status ?: number ;
1921}
2022
2123export const TextErrors = ( {
2224 causes,
2325 defaultMessage,
2426 icon,
2527 canClose = false ,
28+ status,
2629 ...textProps
2730} : TextErrorsProps ) => {
2831 return (
@@ -35,6 +38,7 @@ export const TextErrors = ({
3538 < TextOnlyErrors
3639 causes = { causes }
3740 defaultMessage = { defaultMessage }
41+ status = { status }
3842 { ...textProps }
3943 />
4044 </ AlertStyled >
@@ -44,9 +48,39 @@ export const TextErrors = ({
4448export const TextOnlyErrors = ( {
4549 causes,
4650 defaultMessage,
51+ status,
4752 ...textProps
4853} : TextErrorsProps ) => {
4954 const { t } = useTranslation ( ) ;
55+ const httpError = useHttpErrorMessages ( status ) ;
56+
57+ if ( httpError ) {
58+ return (
59+ < Box $direction = "column" $gap = "0.2rem" >
60+ < Text
61+ as = "h1"
62+ $theme = "error"
63+ $textAlign = "center"
64+ $margin = "0"
65+ $size = "1rem"
66+ $weight = "unset"
67+ { ...textProps }
68+ >
69+ { httpError . title }
70+ </ Text >
71+ < Text
72+ as = "p"
73+ $theme = "error"
74+ $textAlign = "center"
75+ $margin = "0"
76+ $size = "0.875rem"
77+ { ...textProps }
78+ >
79+ { httpError . detail }
80+ </ Text >
81+ </ Box >
82+ ) ;
83+ }
5084
5185 return (
5286 < Box $direction = "column" $gap = "0.2rem" >
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export const DocVersionEditor = ({
5858 < Box $margin = "large" className = "--docs--doc-version-editor-error" >
5959 < TextErrors
6060 causes = { error . cause }
61+ status = { error . status }
6162 icon = {
6263 error . status === 502 ? (
6364 < Text
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ const VersionListState = ({
6262 >
6363 < TextErrors
6464 causes = { error . cause }
65+ status = { error . status }
6566 icon = {
6667 error . status === 502 ? (
6768 < Icon iconName = "wifi_off" $theme = "danger" />
Original file line number Diff line number Diff line change 11export * from './useClipboard' ;
22export * from './useCmdK' ;
33export * from './useDate' ;
4+ export * from './useHttpErrorMessages' ;
45export * from './useKeyboardAction' ;
Original file line number Diff line number Diff line change 1+ import { useTranslation } from 'react-i18next' ;
2+
3+ export const useHttpErrorMessages = ( status ?: number ) => {
4+ const { t } = useTranslation ( ) ;
5+
6+ const messages : Record < number , { title : string ; detail : string } > = {
7+ 500 : {
8+ title : t ( '500 - Internal Server Error' ) ,
9+ detail : t ( 'The server met an unexpected condition.' ) ,
10+ } ,
11+ 502 : {
12+ title : t ( '502 - Bad Gateway' ) ,
13+ detail : t (
14+ 'The server received an invalid response. Please check your connection and try again.' ,
15+ ) ,
16+ } ,
17+ 503 : {
18+ title : t ( '503 - Service Unavailable' ) ,
19+ detail : t (
20+ 'The service is temporarily unavailable. Please try again later.' ,
21+ ) ,
22+ } ,
23+ } ;
24+
25+ return status ? messages [ status ] : undefined ;
26+ } ;
Original file line number Diff line number Diff line change @@ -216,6 +216,7 @@ const DocPage = ({ id }: DocProps) => {
216216 < Box $margin = "large" >
217217 < TextErrors
218218 causes = { error . cause }
219+ status = { error . status }
219220 icon = {
220221 error . status === 502 ? (
221222 < Icon iconName = "wifi_off" $theme = "danger" $withThemeInherited />
You can’t perform that action at this time.
0 commit comments