-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Add error boundary to message component (#25223)
- Loading branch information
1 parent
9e2bb3c
commit f6cac21
Showing
4 changed files
with
98 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
apps/meteor/client/views/room/MessageList/MessageListErrorBoundary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { States, StatesIcon, StatesTitle, StatesSubtitle, StatesActions, StatesAction, Icon } from '@rocket.chat/fuselage'; | ||
import React, { ReactElement, ReactNode } from 'react'; | ||
|
||
import { ErrorBoundary } from '../../../components/ErrorBoundary'; | ||
import { useTranslation } from '../../../contexts/TranslationContext'; | ||
|
||
const MessageListErrorBoundary = ({ children }: { children: ReactNode }): ReactElement => { | ||
const t = useTranslation(); | ||
return ( | ||
<ErrorBoundary | ||
children={children} | ||
fallback={ | ||
<States> | ||
<StatesIcon name='circle-exclamation' variation='danger' /> | ||
<StatesTitle>{t('Error')}</StatesTitle> | ||
<StatesSubtitle>{t('Error_something_went_wrong')}</StatesSubtitle> | ||
<StatesActions> | ||
<StatesAction | ||
onClick={(): void => { | ||
location.reload(); | ||
}} | ||
> | ||
<Icon name='reload' /> {t('Reload')} | ||
</StatesAction> | ||
</StatesActions> | ||
</States> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default MessageListErrorBoundary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters