Skip to content

Commit

Permalink
Add support for new SMTP config schema (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke authored Dec 5, 2024
1 parent 931eafe commit dc71b06
Show file tree
Hide file tree
Showing 6 changed files with 1,227 additions and 281 deletions.
216 changes: 213 additions & 3 deletions shared/studio/tabs/auth/authAdmin.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@
}
}

.titleWrapper {
display: flex;
align-items: center;
min-height: 36px;

h2 {
margin-right: 24px;
}

button {
margin-left: auto;
}
}

.cardList {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -241,19 +255,32 @@

.grid {
display: grid;
grid-auto-flow: column;
grid-template-rows: repeat(calc(var(--itemCount) / var(--colCount)), auto);
gap: 4px;
grid-template-columns: repeat(var(--colCount), auto);
gap: 6px 24px;

> div {
display: flex;
flex-direction: column;
gap: 6px;
}

label {
font-family: "Roboto Mono Variable", monospace;
font-weight: 425;
font-size: 13px;
align-items: start;
height: auto;
line-height: 20px;
padding: 6px 0;
}
}

@media (max-width: 960px) {
--colCount: 2;

.grid > div:nth-child(2) {
grid-row: span 2;
}
}
@media (max-width: 512px) {
--colCount: 1;
Expand Down Expand Up @@ -457,6 +484,18 @@

.securitySelect {
font-family: "Roboto Mono Variable", monospace;

&[data-disabled="true"] {
background: #f7f7f7;
border-color: var(--Grey90);
box-shadow: none;
opacity: 1;

@include darkTheme {
background: #464646;
border-color: #4d4d4d;
}
}
}

.redirectUrlsLabel {
Expand All @@ -475,6 +514,177 @@
resize: vertical;
}

.newDraftSMTPProvider {
display: flex;
flex-direction: column;
width: 100%;

.configGrid {
margin-top: 0;
}

.buttons {
display: flex;
gap: 16px;
justify-content: flex-end;
margin-top: 24px;
flex-direction: row;
}
}

.emailProvidersUpdating {
opacity: 0.7;
pointer-events: none;
}

.emailProviderCard {
.details {
display: flex;
flex-direction: column;
color: var(--main_text_color);
line-height: 22px;

.name {
font-weight: 500;
}

.senderhost {
color: var(--tertiary_text_color);

span {
font-size: 11px;
margin: 0 6px;
opacity: 0.5;
}
}
}

.selectCurrentProvider {
width: 32px;
height: 32px;
stroke-width: 1px;
stroke: var(--Grey75);
cursor: pointer;
flex-shrink: 0;

&.selected {
fill: #a565cd;
stroke: #9c56b4 !important;
}

@include darkTheme {
stroke: var(--Grey40);
}
}

.updatingSpinner {
color: var(--Grey50);
width: 32px;
flex-shrink: 0;
}

.buttons {
display: flex;
gap: 16px;
justify-content: flex-end;
flex-direction: row;
padding: 4px 16px 16px 16px;
}
}

.expandedEmailProviderConfig {
margin: -2px 12px 12px 12px;
background: var(--Grey97);
border-radius: 8px;
border: 1px solid var(--Grey93);

@include darkTheme {
background: var(--Grey16);
border-color: var(--Grey25);
}

.configGrid {
margin-top: 20px;
margin-bottom: 12px;

@include isMobile {
margin: 16px;
}
}
}

.passwordWarning {
display: flex;
align-items: flex-start;
gap: 4px;
color: var(--secondary_text_color);
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 20px;
background: #f7e9c8;
border-radius: 8px;
border: 1px solid #c1a970;
color: #7b6226;
padding: 8px 12px 10px 12px;
margin: 0 12px;
margin-bottom: 0px;
margin-bottom: 12px;

> div {
margin-top: 2px;

> span {
font-weight: 500;
}
}

svg {
flex-shrink: 0;
}

@include darkTheme {
background: #453d2c;
border: 1px solid #72623b;
color: #d1bd8f;
}
}

.emailProviderWarning {
position: relative;
padding: 12px 20px;
padding-left: 48px;
background: #f7e9c8;
border-radius: 8px;
border: 1px solid #c1a970;
color: #7b6226;
font-weight: 450;
line-height: 20px;
margin-top: 16px;

& > svg {
position: absolute;
left: 16px;
top: 14px;
}

& > span {
font-weight: 500;
}

.link {
font-weight: inherit;
cursor: pointer;
text-decoration: underline;
}

@include darkTheme {
background: #453d2c;
border: 1px solid #72623b;
color: #d1bd8f;
}
}

.docsNote {
display: flex;
align-items: flex-start;
Expand Down
76 changes: 70 additions & 6 deletions shared/studio/tabs/auth/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from "@edgedb/common/newui";

import styles from "./authAdmin.module.scss";
import {StickyBottomBar} from "./shared";
import {EmailProviderWarning, StickyBottomBar} from "./shared";
import {Theme, useTheme} from "@edgedb/common/hooks/useTheme";
import {AppConfigForm} from "./config";
import {
Expand All @@ -50,11 +50,75 @@ export const ProvidersTab = observer(function ProvidersTab() {
{state.providers ? (
<>
{state.providers.length ? (
<div className={styles.cardList}>
{state.providers.map((provider) => (
<ProviderCard key={provider.name} provider={provider} />
))}
</div>
<>
{state.emailProviderWarnings.verificationNoSmtp ? (
<EmailProviderWarning>
You have auth providers requiring email verification enabled,
but no method for verifying emails is configured.
<br />
<span
className={styles.link}
onClick={() => state.setSelectedTab("smtp")}
>
Enable an SMTP provider
</span>{" "}
or{" "}
<span
className={styles.link}
onClick={() => state.setSelectedTab("webhooks")}
>
create a webhook
</span>{" "}
to handle email verification.
</EmailProviderWarning>
) : state.emailProviderWarnings.passwordNoReset ? (
<EmailProviderWarning>
You have the 'Email + Password' auth provider enabled, but no
method for sending password resets is configured.
<br />
<span
className={styles.link}
onClick={() => state.setSelectedTab("smtp")}
>
Enable an SMTP provider
</span>{" "}
or{" "}
<span
className={styles.link}
onClick={() => state.setSelectedTab("webhooks")}
>
create a webhook
</span>{" "}
to handle password resets.
</EmailProviderWarning>
) : state.emailProviderWarnings.magicLinkNoMethods ? (
<EmailProviderWarning>
You have the 'Magic Link' auth provider enabled, but no
method for sending magic links is configured.
<br />
<span
className={styles.link}
onClick={() => state.setSelectedTab("smtp")}
>
Enable an SMTP provider
</span>{" "}
or{" "}
<span
className={styles.link}
onClick={() => state.setSelectedTab("webhooks")}
>
create a webhook
</span>{" "}
to handle magic links.
</EmailProviderWarning>
) : null}

<div className={styles.cardList}>
{state.providers.map((provider) => (
<ProviderCard key={provider.name} provider={provider} />
))}
</div>
</>
) : null}

{state.draftProviderConfig ? (
Expand Down
11 changes: 10 additions & 1 deletion shared/studio/tabs/auth/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {observer} from "mobx-react-lite";

import cn from "@edgedb/common/utils/classNames";

import {Button} from "@edgedb/common/newui";
import {Button, WarningIcon} from "@edgedb/common/newui";

import {AbstractDraftConfig} from "./state";

Expand Down Expand Up @@ -53,3 +53,12 @@ export const StickyFormControls = observer(function StickyFormControls({
export const InputSkeleton = () => (
<LoadingSkeleton className={styles.inputSkeleton} />
);

export function EmailProviderWarning({children}: PropsWithChildren<{}>) {
return (
<div className={styles.emailProviderWarning}>
<WarningIcon />
<span>Warning:</span> {children}
</div>
);
}
Loading

0 comments on commit dc71b06

Please sign in to comment.