Skip to content

Commit 05fbbe8

Browse files
committed
add required pill for non-optional external auth providers
1 parent 15b4dc9 commit 05fbbe8

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
147147
);
148148
}, [autofillParameters]);
149149

150+
const hasAllRequiredExternalAuth = externalAuth.every(
151+
(auth) => auth.optional || auth.authenticated,
152+
);
153+
150154
return (
151155
<Margins size="medium">
152156
<PageHeader actions={<Button onClick={onCancel}>Cancel</Button>}>
@@ -251,13 +255,15 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
251255
description="This template requires authentication to external services."
252256
>
253257
<FormFields>
254-
{requiresExternalAuth && (
255-
// This should really be a `notice` but `severity` is a MUI prop, and we'd need
256-
// to basically make our own `Alert` component.
258+
{hasAllRequiredExternalAuth ? (
257259
<Alert severity="info">
258-
To create a workspace using the selected template, please
259-
ensure you are authenticated with all the external providers
260-
listed below.
260+
This template can connect to the external authentication
261+
providers listed below.
262+
</Alert>
263+
) : (
264+
<Alert severity="error">
265+
To create a workspace using this template, please connect to
266+
all required external authentication providers listed below.
261267
</Alert>
262268
)}
263269
{externalAuth.map((auth) => (
@@ -313,6 +319,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
313319
<FormFooter
314320
onCancel={onCancel}
315321
isLoading={creatingWorkspace}
322+
submitDisabled={!hasAllRequiredExternalAuth}
316323
submitLabel="Create Workspace"
317324
/>
318325
</HorizontalForm>

site/src/pages/CreateWorkspacePage/ExternalAuthButton.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import ReplayIcon from "@mui/icons-material/Replay";
22
import Button from "@mui/material/Button";
33
import Tooltip from "@mui/material/Tooltip";
4-
import { type FC } from "react";
54
import LoadingButton from "@mui/lab/LoadingButton";
65
import { visuallyHidden } from "@mui/utils";
6+
import { type FC } from "react";
7+
import type { TemplateVersionExternalAuth } from "api/typesGenerated";
78
import { ExternalImage } from "components/ExternalImage/ExternalImage";
8-
import { TemplateVersionExternalAuth } from "api/typesGenerated";
9+
import { Pill } from "components/Pill/Pill";
910

1011
export interface ExternalAuthButtonProps {
1112
auth: TemplateVersionExternalAuth;
@@ -51,6 +52,11 @@ export const ExternalAuthButton: FC<ExternalAuthButtonProps> = ({
5152
{auth.authenticated
5253
? `Authenticated with ${auth.display_name}`
5354
: `Login with ${auth.display_name}`}
55+
{!auth.optional && !auth.authenticated && (
56+
<Pill type="error" css={{ marginLeft: 8 }}>
57+
Required
58+
</Pill>
59+
)}
5460
</LoadingButton>
5561

5662
{displayRetry && (

0 commit comments

Comments
 (0)