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

Commit503039f

Browse files
committed
fix: display trial errors in the dashboard
The error was essentially being ignored before!
1 parent3a1fa04 commit503039f

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

‎enterprise/trialer/trialer.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ func New(db database.Store, url string, keys map[string]ed25519.PublicKey) func(
3939
returnxerrors.Errorf("perform license request: %w",err)
4040
}
4141
deferres.Body.Close()
42+
ifres.StatusCode!=http.StatusOK {
43+
body,err:=io.ReadAll(res.Body)
44+
iferr!=nil {
45+
returnxerrors.Errorf("read license response: %w",err)
46+
}
47+
// This is the format of the error response from
48+
// the license server.
49+
varmsgstruct {
50+
Errorstring`json:"error"`
51+
}
52+
err=json.Unmarshal(body,&msg)
53+
iferr!=nil {
54+
returnxerrors.Errorf("unmarshal error: %w",err)
55+
}
56+
returnxerrors.New(msg.Error)
57+
}
4258
raw,err:=io.ReadAll(res.Body)
4359
iferr!=nil {
4460
returnxerrors.Errorf("read license: %w",err)

‎site/src/pages/SetupPage/SetupPageView.stories.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ export const FormError: Story = {
2222
},
2323
};
2424

25+
exportconstTrialError:Story={
26+
args:{
27+
error:mockApiError({
28+
message:"Couldn't generate trial!",
29+
detail:"It looks like your team is already trying Coder.",
30+
}),
31+
},
32+
}
33+
2534
exportconstLoading:Story={
2635
args:{
2736
isLoading:true,

‎site/src/pages/SetupPage/SetupPageView.tsx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
importLoadingButtonfrom"@mui/lab/LoadingButton";
2+
importAlertTitlefrom"@mui/material/AlertTitle";
23
importAutocompletefrom"@mui/material/Autocomplete";
34
importCheckboxfrom"@mui/material/Checkbox";
45
importLinkfrom"@mui/material/Link";
56
importMenuItemfrom"@mui/material/MenuItem";
67
importTextFieldfrom"@mui/material/TextField";
8+
import{isAxiosError}from"axios";
79
import{typeFormikContextType,useFormik}from"formik";
810
importtype{FC}from"react";
911
import*asYupfrom"yup";
1012
importtype*asTypesGenfrom"api/typesGenerated";
13+
import{Alert,AlertDetail}from"components/Alert/Alert";
1114
import{FormFields,VerticalForm}from"components/Form/Form";
1215
import{CoderIcon}from"components/Icons/CoderIcon";
1316
import{SignInLayout}from"components/SignInLayout/SignInLayout";
@@ -316,6 +319,21 @@ export const SetupPageView: FC<SetupPageViewProps> = ({
316319
</>
317320
)}
318321

322+
{isAxiosError(error)&&error.response?.data?.message&&(
323+
<Alertseverity="error">
324+
<AlertTitle>{error.response.data.message}</AlertTitle>
325+
{error.response.data.detail&&(
326+
<AlertDetail>
327+
{error.response.data.detail}
328+
<br/>
329+
<Linktarget="_blank"href="https://coder.com/contact/sales">
330+
Contact Sales
331+
</Link>
332+
</AlertDetail>
333+
)}
334+
</Alert>
335+
)}
336+
319337
<LoadingButton
320338
fullWidth
321339
loading={isLoading}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp