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

feat(site): allow creating a workspace without connecting optional external auth providers#12251

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aslilac merged 5 commits intomainfromoptional-external-auth-frontend
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -233,19 +233,6 @@ describe("CreateWorkspacePage", () => {
);
});

it("external auth errors if unauthenticated",async()=>{
jest
.spyOn(API,"getTemplateVersionExternalAuth")
.mockResolvedValueOnce([MockTemplateVersionExternalAuthGithub]);

renderCreateWorkspacePage();
awaitwaitForLoaderToBeRemoved();

awaitscreen.findByText(
"To create a workspace using the selected template, please ensure you are authenticated with all the external providers listed below.",
);
});

it("auto create a workspace if uses mode=auto",async()=>{
constparam="first_parameter";
constparamValue="It works!";
Expand DownExpand Up@@ -312,7 +299,7 @@ describe("CreateWorkspacePage", () => {
route:`/templates/${MockWorkspace.name}/workspace?${params.toString()}`,
});

constwarningMessage=awaitscreen.findByRole("alert");
constwarningMessage=awaitscreen.findByTestId("duplication-warning");
constnameInput=awaitscreen.findByRole("textbox",{
name:"Workspace Name",
});
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,6 +126,80 @@ export const ExternalAuth: Story = {
authenticate_url:"",
display_icon:"/icon/gitlab.svg",
display_name:"GitLab",
optional:true,
},
],
},
};

exportconstExternalAuthError:Story={
args:{
error:true,
externalAuth:[
{
id:"github",
type:"github",
authenticated:false,
authenticate_url:"",
display_icon:"/icon/github.svg",
display_name:"GitHub",
},
{
id:"gitlab",
type:"gitlab",
authenticated:false,
authenticate_url:"",
display_icon:"/icon/gitlab.svg",
display_name:"GitLab",
optional:true,
},
],
},
};

exportconstExternalAuthAllRequiredConnected:Story={
args:{
externalAuth:[
{
id:"github",
type:"github",
authenticated:true,
authenticate_url:"",
display_icon:"/icon/github.svg",
display_name:"GitHub",
},
{
id:"gitlab",
type:"gitlab",
authenticated:false,
authenticate_url:"",
display_icon:"/icon/gitlab.svg",
display_name:"GitLab",
optional:true,
},
],
},
};

exportconstExternalAuthAllConnected:Story={
args:{
externalAuth:[
{
id:"github",
type:"github",
authenticated:true,
authenticate_url:"",
display_icon:"/icon/github.svg",
display_name:"GitHub",
},
{
id:"gitlab",
type:"gitlab",
authenticated:true,
authenticate_url:"",
display_icon:"/icon/gitlab.svg",
display_name:"GitLab",
optional:true,
},
],
},
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,6 +147,10 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
);
},[autofillParameters]);

consthasAllRequiredExternalAuth=externalAuth.every(
(auth)=>auth.optional||auth.authenticated,
);

return(
<Marginssize="medium">
<PageHeaderactions={<ButtononClick={onCancel}>Cancel</Button>}>
Expand DownExpand Up@@ -179,7 +183,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
{Boolean(error)&&<ErrorAlerterror={error}/>}

{mode==="duplicate"&&(
<Alertseverity="info"dismissible>
<Alertseverity="info"dismissibledata-testid="duplication-warning">
{Language.duplicationWarning}
</Alert>
)}
Expand DownExpand Up@@ -248,21 +252,19 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
{externalAuth&&externalAuth.length>0&&(
<FormSection
title="External Authentication"
description="This templaterequires authentication toexternal services."
description="This templateusesexternal services for authentication."
>
<FormFields>
{requiresExternalAuth&&(
// This should really be a `notice` but `severity` is a MUI prop, and we'd need
// to basically make our own `Alert` component.
<Alertseverity="info">
To create a workspace using the selected template, please
ensure you are authenticated with all the external providers
listed below.
{Boolean(error)&&!hasAllRequiredExternalAuth&&(
<Alertseverity="error">
To create a workspace using this template, please connect to
all required external authentication providers listed below.
</Alert>
)}
{externalAuth.map((auth)=>(
<ExternalAuthButton
key={auth.id}
error={error}
auth={auth}
isLoading={externalAuthPollingState==="polling"}
onStartPolling={startPollingExternalAuth}
Expand DownExpand Up@@ -313,6 +315,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
<FormFooter
onCancel={onCancel}
isLoading={creatingWorkspace}
submitDisabled={!hasAllRequiredExternalAuth}
submitLabel="Create Workspace"
/>
</HorizontalForm>
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@ const MockExternalAuth: TemplateVersionExternalAuth = {
};

constmeta:Meta<typeofExternalAuthButton>={
title:"pages/CreateWorkspacePage/ExternalAuth",
title:"pages/CreateWorkspacePage/ExternalAuthButton",
component:ExternalAuthButton,
};

Expand All@@ -25,6 +25,15 @@ export const Github: Story = {
},
};

exportconstGithubOptional:Story={
args:{
auth:{
...MockExternalAuth,
optional:true,
},
},
};

exportconstGithubWithRetry:Story={
args:{
auth:MockExternalAuth,
Expand All@@ -48,6 +57,7 @@ export const Gitlab: Story = {
display_icon:"/icon/gitlab.svg",
display_name:"GitLab",
authenticated:false,
optional:true,
},
},
};
Expand All@@ -70,6 +80,7 @@ export const AzureDevOps: Story = {
display_icon:"/icon/azure-devops.svg",
display_name:"Azure DevOps",
authenticated:false,
optional:true,
},
},
};
Expand All@@ -92,6 +103,7 @@ export const Bitbucket: Story = {
display_icon:"/icon/bitbucket.svg",
display_name:"Bitbucket",
authenticated:false,
optional:true,
},
},
};
Expand Down
22 changes: 17 additions & 5 deletionssite/src/pages/CreateWorkspacePage/ExternalAuthButton.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
importReplayIconfrom"@mui/icons-material/Replay";
importButtonfrom"@mui/material/Button";
importTooltipfrom"@mui/material/Tooltip";
import{typeFC}from"react";
importLoadingButtonfrom"@mui/lab/LoadingButton";
import{visuallyHidden}from"@mui/utils";
import{typeFC}from"react";
importtype{TemplateVersionExternalAuth}from"api/typesGenerated";
import{ExternalImage}from"components/ExternalImage/ExternalImage";
import{TemplateVersionExternalAuth}from"api/typesGenerated";
import{Pill}from"components/Pill/Pill";

exportinterfaceExternalAuthButtonProps{
auth:TemplateVersionExternalAuth;
displayRetry:boolean;
isLoading:boolean;
onStartPolling:()=>void;
error?:unknown;
}

exportconstExternalAuthButton:FC<ExternalAuthButtonProps>=({
auth,
displayRetry,
isLoading,
onStartPolling,
error,
})=>{
return(
<>
Expand DownExpand Up@@ -48,9 +51,18 @@ export const ExternalAuthButton: FC<ExternalAuthButtonProps> = ({
onStartPolling();
}}
>
{auth.authenticated
?`Authenticated with${auth.display_name}`
:`Login with${auth.display_name}`}
{auth.authenticated ?(
`Authenticated with${auth.display_name}`
) :(
<>
Login with{auth.display_name}
{!auth.optional&&(
<Pilltype={error ?"error" :"info"}css={{marginLeft:12}}>
Required
</Pill>
)}
</>
)}
</LoadingButton>

{displayRetry&&(
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp