Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc465f8a

Browse files
authored
feat: add retry to ErrorSummary (#1690)
Summary:The ErrorSummary accepts a retry callback and received improvements tostyle and product copyImpact:This allows xstate-controlled pages to send re-fetch events
1 parentdd4bb07 commitc465f8a

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

‎site/src/components/ErrorSummary/ErrorSummary.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import{action}from"@storybook/addon-actions"
12
import{ComponentMeta,Story}from"@storybook/react"
23
importReactfrom"react"
34
import{ErrorSummary,ErrorSummaryProps}from"./ErrorSummary"
@@ -14,4 +15,12 @@ WithError.args = {
1415
error:newError("Something went wrong!"),
1516
}
1617

18+
exportconstWithRetry=Template.bind({})
19+
WithRetry.args={
20+
error:newError("Failed to fetch something!"),
21+
retry:()=>{
22+
action("retry")
23+
},
24+
}
25+
1726
exportconstWithUndefined=Template.bind({})
Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1+
importButtonfrom"@material-ui/core/Button"
2+
importRefreshIconfrom"@material-ui/icons/Refresh"
13
importReactfrom"react"
4+
import{Stack}from"../Stack/Stack"
25

36
constLanguage={
4-
unknownErrorMessage:"Unknown error",
7+
retryMessage:"Retry",
8+
unknownErrorMessage:"An unknown error has occurred",
59
}
610

711
exportinterfaceErrorSummaryProps{
812
error:Error|unknown
13+
retry?:()=>void
914
}
1015

11-
exportconstErrorSummary:React.FC<ErrorSummaryProps>=({ error})=>{
12-
// TODO: More interesting error page
16+
exportconstErrorSummary:React.FC<ErrorSummaryProps>=({ error, retry})=>(
17+
<Stack>
18+
{!(errorinstanceofError) ?<div>{Language.unknownErrorMessage}</div> :<div>{error.toString()}</div>}
1319

14-
if(!(errorinstanceofError)){
15-
return<div>{Language.unknownErrorMessage}</div>
16-
}else{
17-
return<div>{error.toString()}</div>
18-
}
19-
}
20+
{retry&&(
21+
<div>
22+
<ButtononClick={retry}startIcon={<RefreshIcon/>}variant="outlined">
23+
{Language.retryMessage}
24+
</Button>
25+
</div>
26+
)}
27+
</Stack>
28+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp