mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-31 15:09:39 +02:00
hide whitelist section if no email configured
This commit is contained in:
parent
19d87c2393
commit
e97a9b9b3d
1 changed files with 99 additions and 104 deletions
|
@ -637,111 +637,106 @@ export default function ResourceAuthenticationPage() {
|
||||||
</SettingsSectionBody>
|
</SettingsSectionBody>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|
||||||
<SettingsSection>
|
{env.email.emailEnabled && (
|
||||||
<SettingsSectionHeader>
|
<SettingsSection>
|
||||||
<SettingsSectionTitle>
|
<SettingsSectionHeader>
|
||||||
One-time Passwords
|
<SettingsSectionTitle>
|
||||||
</SettingsSectionTitle>
|
One-time Passwords
|
||||||
<SettingsSectionDescription>
|
</SettingsSectionTitle>
|
||||||
Require email-based authentication for resource
|
<SettingsSectionDescription>
|
||||||
access
|
Require email-based authentication for resource
|
||||||
</SettingsSectionDescription>
|
access
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionDescription>
|
||||||
<SettingsSectionBody>
|
</SettingsSectionHeader>
|
||||||
{env.email.emailEnabled && (
|
<SettingsSectionBody>
|
||||||
<>
|
<SwitchInput
|
||||||
<SwitchInput
|
id="whitelist-toggle"
|
||||||
id="whitelist-toggle"
|
label="Email Whitelist"
|
||||||
label="Email Whitelist"
|
defaultChecked={resource.emailWhitelistEnabled}
|
||||||
defaultChecked={
|
onCheckedChange={setWhitelistEnabled}
|
||||||
resource.emailWhitelistEnabled
|
/>
|
||||||
}
|
|
||||||
onCheckedChange={setWhitelistEnabled}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{whitelistEnabled && (
|
{whitelistEnabled && (
|
||||||
<Form {...whitelistForm}>
|
<Form {...whitelistForm}>
|
||||||
<form id="whitelist-form">
|
<form id="whitelist-form">
|
||||||
<FormField
|
<FormField
|
||||||
control={whitelistForm.control}
|
control={whitelistForm.control}
|
||||||
name="emails"
|
name="emails"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
Whitelisted Emails
|
Whitelisted Emails
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
{/* @ts-ignore */}
|
{/* @ts-ignore */}
|
||||||
{/* @ts-ignore */}
|
{/* @ts-ignore */}
|
||||||
<TagInput
|
<TagInput
|
||||||
{...field}
|
{...field}
|
||||||
activeTagIndex={
|
activeTagIndex={
|
||||||
activeEmailTagIndex
|
activeEmailTagIndex
|
||||||
}
|
}
|
||||||
validateTag={(
|
validateTag={(
|
||||||
tag
|
tag
|
||||||
) => {
|
) => {
|
||||||
return z
|
return z
|
||||||
.string()
|
.string()
|
||||||
.email()
|
.email()
|
||||||
.safeParse(
|
.safeParse(
|
||||||
tag
|
tag
|
||||||
)
|
).success;
|
||||||
.success;
|
}}
|
||||||
}}
|
setActiveTagIndex={
|
||||||
setActiveTagIndex={
|
setActiveEmailTagIndex
|
||||||
setActiveEmailTagIndex
|
}
|
||||||
}
|
placeholder="Enter an email"
|
||||||
placeholder="Enter an email"
|
tags={
|
||||||
tags={
|
whitelistForm.getValues()
|
||||||
whitelistForm.getValues()
|
.emails
|
||||||
.emails
|
}
|
||||||
}
|
setTags={(
|
||||||
setTags={(
|
newRoles
|
||||||
newRoles
|
) => {
|
||||||
) => {
|
whitelistForm.setValue(
|
||||||
whitelistForm.setValue(
|
"emails",
|
||||||
"emails",
|
newRoles as [
|
||||||
newRoles as [
|
Tag,
|
||||||
Tag,
|
...Tag[]
|
||||||
...Tag[]
|
]
|
||||||
]
|
);
|
||||||
);
|
}}
|
||||||
}}
|
allowDuplicates={
|
||||||
allowDuplicates={
|
false
|
||||||
false
|
}
|
||||||
}
|
sortTags={true}
|
||||||
sortTags={true}
|
styleClasses={{
|
||||||
styleClasses={{
|
tag: {
|
||||||
tag: {
|
body: "bg-muted hover:bg-accent text-foreground py-2 px-3 rounded-full"
|
||||||
body: "bg-muted hover:bg-accent text-foreground py-2 px-3 rounded-full"
|
},
|
||||||
},
|
input: "text-base md:text-sm border-none bg-transparent text-inherit placeholder:text-inherit shadow-none",
|
||||||
input: "text-base md:text-sm border-none bg-transparent text-inherit placeholder:text-inherit shadow-none",
|
inlineTagsContainer:
|
||||||
inlineTagsContainer:
|
"bg-transparent p-2"
|
||||||
"bg-transparent p-2"
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
</FormControl>
|
||||||
</FormControl>
|
</FormItem>
|
||||||
</FormItem>
|
)}
|
||||||
)}
|
/>
|
||||||
/>
|
</form>
|
||||||
</form>
|
</Form>
|
||||||
</Form>
|
)}
|
||||||
)}
|
</SettingsSectionBody>
|
||||||
</>
|
<SettingsSectionFooter>
|
||||||
)}
|
<Button
|
||||||
</SettingsSectionBody>
|
onClick={saveWhitelist}
|
||||||
<SettingsSectionFooter>
|
form="whitelist-form"
|
||||||
<Button
|
loading={loadingSaveWhitelist}
|
||||||
onClick={saveWhitelist}
|
disabled={loadingSaveWhitelist}
|
||||||
form="whitelist-form"
|
>
|
||||||
loading={loadingSaveWhitelist}
|
Save Whitelist
|
||||||
disabled={loadingSaveWhitelist}
|
</Button>
|
||||||
>
|
</SettingsSectionFooter>
|
||||||
Save Whitelist
|
</SettingsSection>
|
||||||
</Button>
|
)}
|
||||||
</SettingsSectionFooter>
|
|
||||||
</SettingsSection>
|
|
||||||
</SettingsContainer>
|
</SettingsContainer>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue