-
Notifications
You must be signed in to change notification settings - Fork 148
fix(admin-form): show error state when webhook settings fetch fails #9524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LoneRifle
wants to merge
4
commits into
develop
Choose a base branch
from
fix/webhooks-settings-error-state
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+121
−2
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f98030a
fix(admin-form): show error state when webhook settings fetch fails (…
kimyungju b781fcb
fix(settings/webhooks): invoke `onRetry()` w/o args
LoneRifle 069ce24
chore(settings/webhooks): remove comments, code self-documenting
LoneRifle 3881d1f
feat(i18n): add webhook error text
LoneRifle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
34 changes: 34 additions & 0 deletions
34
apps/frontend/src/features/admin-form/settings/SettingsWebhooksPage.test.tsx
This file contains hidden or 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,34 @@ | ||
| import { composeStories } from '@storybook/react' | ||
| import { act, render, screen } from '@testing-library/react' | ||
|
|
||
| import * as stories from './SettingsWebhooksPage.stories' | ||
|
|
||
| const { Error: ErrorStory, UnsupportedEmailMode } = composeStories(stories) | ||
|
|
||
| const UNSUPPORTED_MSG = /webhooks are only available in storage mode/i | ||
| const ERROR_MSG = /couldn't load webhook settings/i | ||
|
|
||
| describe('SettingsWebhooksPage', () => { | ||
| it('shows an error state, not the unsupported-mode message, when the settings fetch fails', async () => { | ||
| await act(async () => { | ||
| render(<ErrorStory />) | ||
| }) | ||
|
|
||
| await screen.findByText(ERROR_MSG) | ||
| // The error is announced to assistive tech (it appears after an async failure). | ||
| expect(screen.getByRole('alert')).toBeInTheDocument() | ||
| expect( | ||
| screen.getByRole('button', { name: /try again/i }), | ||
| ).toBeInTheDocument() | ||
| expect(screen.queryByText(UNSUPPORTED_MSG)).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('still shows the unsupported-mode message for a form whose mode genuinely lacks webhook support', async () => { | ||
| await act(async () => { | ||
| render(<UnsupportedEmailMode />) | ||
| }) | ||
|
|
||
| await screen.findByText(UNSUPPORTED_MSG) | ||
| expect(screen.queryByText(ERROR_MSG)).not.toBeInTheDocument() | ||
| }) | ||
| }) |
This file contains hidden or 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
41 changes: 41 additions & 0 deletions
41
...frontend/src/features/admin-form/settings/components/WebhooksSection/WebhooksErrorMsg.tsx
This file contains hidden or 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,41 @@ | ||
| import { useTranslation } from 'react-i18next' | ||
| import { Flex, Text } from '@chakra-ui/react' | ||
|
|
||
| import Button from '~components/Button' | ||
|
|
||
| export interface WebhooksErrorMsgProps { | ||
| onRetry: () => void | ||
| isRetrying?: boolean | ||
| } | ||
|
|
||
| export const WebhooksErrorMsg = ({ | ||
| onRetry, | ||
| isRetrying = false, | ||
| }: WebhooksErrorMsgProps): JSX.Element => { | ||
| const { t } = useTranslation() | ||
| const { title, body, button } = t( | ||
| 'features.adminForm.settings.webhooks.error', | ||
| { | ||
| returnObjects: true, | ||
| }, | ||
| ) | ||
| return ( | ||
| <Flex justify="center" flexDir="column" textAlign="center" role="alert"> | ||
| <Text textStyle="h2" as="h2" color="primary.500" mb="1rem"> | ||
| {title} | ||
| </Text> | ||
| <Text textStyle="body-1" color="secondary.500" mb="2.5rem"> | ||
| {body} | ||
| </Text> | ||
| <Flex justify="center"> | ||
| <Button | ||
| isLoading={isRetrying} | ||
| loadingText={button.loadingText} | ||
| onClick={() => void onRetry()} | ||
| > | ||
|
LoneRifle marked this conversation as resolved.
|
||
| {button.label} | ||
| </Button> | ||
| </Flex> | ||
| </Flex> | ||
| ) | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.