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

Commitc04cd37

Browse files
committed
support optional external auth providers in the frontend
1 parent4ee3bad commitc04cd37

File tree

5 files changed

+106
-15
lines changed

5 files changed

+106
-15
lines changed

‎site/src/pages/CreateWorkspacePage/CreateWorkspacePage.test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@ describe("CreateWorkspacePage", () => {
241241
renderCreateWorkspacePage();
242242
awaitwaitForLoaderToBeRemoved();
243243

244-
awaitscreen.findByText(
245-
"To create a workspace using the selected template, please ensure you are authenticated with all the external providers listed below.",
246-
);
244+
awaitscreen.findByText(/connecttoallrequired/i);
247245
});
248246

249247
it("auto create a workspace if uses mode=auto",async()=>{
@@ -312,7 +310,7 @@ describe("CreateWorkspacePage", () => {
312310
route:`/templates/${MockWorkspace.name}/workspace?${params.toString()}`,
313311
});
314312

315-
constwarningMessage=awaitscreen.findByRole("alert");
313+
constwarningMessage=awaitscreen.findByTestId("duplication-warning");
316314
constnameInput=awaitscreen.findByRole("textbox",{
317315
name:"Workspace Name",
318316
});

‎site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.stories.tsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,80 @@ export const ExternalAuth: Story = {
126126
authenticate_url:"",
127127
display_icon:"/icon/gitlab.svg",
128128
display_name:"GitLab",
129+
optional:true,
130+
},
131+
],
132+
},
133+
};
134+
135+
exportconstExternalAuthError:Story={
136+
args:{
137+
error:true,
138+
externalAuth:[
139+
{
140+
id:"github",
141+
type:"github",
142+
authenticated:false,
143+
authenticate_url:"",
144+
display_icon:"/icon/github.svg",
145+
display_name:"GitHub",
146+
},
147+
{
148+
id:"gitlab",
149+
type:"gitlab",
150+
authenticated:false,
151+
authenticate_url:"",
152+
display_icon:"/icon/gitlab.svg",
153+
display_name:"GitLab",
154+
optional:true,
155+
},
156+
],
157+
},
158+
};
159+
160+
exportconstExternalAuthAllRequiredConnected:Story={
161+
args:{
162+
externalAuth:[
163+
{
164+
id:"github",
165+
type:"github",
166+
authenticated:true,
167+
authenticate_url:"",
168+
display_icon:"/icon/github.svg",
169+
display_name:"GitHub",
170+
},
171+
{
172+
id:"gitlab",
173+
type:"gitlab",
174+
authenticated:false,
175+
authenticate_url:"",
176+
display_icon:"/icon/gitlab.svg",
177+
display_name:"GitLab",
178+
optional:true,
179+
},
180+
],
181+
},
182+
};
183+
184+
exportconstExternalAuthAllConnected:Story={
185+
args:{
186+
externalAuth:[
187+
{
188+
id:"github",
189+
type:"github",
190+
authenticated:true,
191+
authenticate_url:"",
192+
display_icon:"/icon/github.svg",
193+
display_name:"GitHub",
194+
},
195+
{
196+
id:"gitlab",
197+
type:"gitlab",
198+
authenticated:true,
199+
authenticate_url:"",
200+
display_icon:"/icon/gitlab.svg",
201+
display_name:"GitLab",
202+
optional:true,
129203
},
130204
],
131205
},

‎site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
183183
{Boolean(error)&&<ErrorAlerterror={error}/>}
184184

185185
{mode==="duplicate"&&(
186-
<Alertseverity="info"dismissible>
186+
<Alertseverity="info"dismissibledata-testid="duplication-warning">
187187
{Language.duplicationWarning}
188188
</Alert>
189189
)}
@@ -252,7 +252,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
252252
{externalAuth&&externalAuth.length>0&&(
253253
<FormSection
254254
title="External Authentication"
255-
description="This templaterequires authentication toexternal services."
255+
description="This templateusesexternal services for authentication."
256256
>
257257
<FormFields>
258258
{hasAllRequiredExternalAuth ?(
@@ -261,14 +261,15 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
261261
providers listed below.
262262
</Alert>
263263
) :(
264-
<Alertseverity="error">
264+
<Alertseverity={error ?"error" :"info"}>
265265
To create a workspace using this template, please connect to
266266
all required external authentication providers listed below.
267267
</Alert>
268268
)}
269269
{externalAuth.map((auth)=>(
270270
<ExternalAuthButton
271271
key={auth.id}
272+
error={error}
272273
auth={auth}
273274
isLoading={externalAuthPollingState==="polling"}
274275
onStartPolling={startPollingExternalAuth}

‎site/src/pages/CreateWorkspacePage/ExternalAuthButton.stories.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const MockExternalAuth: TemplateVersionExternalAuth = {
1212
};
1313

1414
constmeta:Meta<typeofExternalAuthButton>={
15-
title:"pages/CreateWorkspacePage/ExternalAuth",
15+
title:"pages/CreateWorkspacePage/ExternalAuthButton",
1616
component:ExternalAuthButton,
1717
};
1818

@@ -25,6 +25,15 @@ export const Github: Story = {
2525
},
2626
};
2727

28+
exportconstGithubOptional:Story={
29+
args:{
30+
auth:{
31+
...MockExternalAuth,
32+
optional:true,
33+
},
34+
},
35+
};
36+
2837
exportconstGithubWithRetry:Story={
2938
args:{
3039
auth:MockExternalAuth,
@@ -48,6 +57,7 @@ export const Gitlab: Story = {
4857
display_icon:"/icon/gitlab.svg",
4958
display_name:"GitLab",
5059
authenticated:false,
60+
optional:true,
5161
},
5262
},
5363
};
@@ -70,6 +80,7 @@ export const AzureDevOps: Story = {
7080
display_icon:"/icon/azure-devops.svg",
7181
display_name:"Azure DevOps",
7282
authenticated:false,
83+
optional:true,
7384
},
7485
},
7586
};
@@ -92,6 +103,7 @@ export const Bitbucket: Story = {
92103
display_icon:"/icon/bitbucket.svg",
93104
display_name:"Bitbucket",
94105
authenticated:false,
106+
optional:true,
95107
},
96108
},
97109
};

‎site/src/pages/CreateWorkspacePage/ExternalAuthButton.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ export interface ExternalAuthButtonProps {
1313
displayRetry:boolean;
1414
isLoading:boolean;
1515
onStartPolling:()=>void;
16+
error?:unknown;
1617
}
1718

1819
exportconstExternalAuthButton:FC<ExternalAuthButtonProps>=({
1920
auth,
2021
displayRetry,
2122
isLoading,
2223
onStartPolling,
24+
error,
2325
})=>{
2426
return(
2527
<>
@@ -49,13 +51,17 @@ export const ExternalAuthButton: FC<ExternalAuthButtonProps> = ({
4951
onStartPolling();
5052
}}
5153
>
52-
{auth.authenticated
53-
?`Authenticated with${auth.display_name}`
54-
:`Login with${auth.display_name}`}
55-
{!auth.optional&&!auth.authenticated&&(
56-
<Pilltype="error"css={{marginLeft:8}}>
57-
Required
58-
</Pill>
54+
{auth.authenticated ?(
55+
`Authenticated with${auth.display_name}`
56+
) :(
57+
<>
58+
Login with{auth.display_name}
59+
{!auth.optional&&(
60+
<Pilltype={error ?"error" :"info"}css={{marginLeft:8}}>
61+
Required
62+
</Pill>
63+
)}
64+
</>
5965
)}
6066
</LoadingButton>
6167

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp