[WEB-1521] chore: add configuration to enable/disable sign-ups. (#4697)

This commit is contained in:
Prateek Shourya 2024-06-04 15:35:20 +05:30 committed by GitHub
parent 188f8ff83f
commit e503c901ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 4 deletions

View File

@ -7,12 +7,12 @@ import { useTheme } from "next-themes";
import useSWR from "swr"; import useSWR from "swr";
import { Mails, KeyRound } from "lucide-react"; import { Mails, KeyRound } from "lucide-react";
import { TInstanceConfigurationKeys } from "@plane/types"; import { TInstanceConfigurationKeys } from "@plane/types";
import { Loader, setPromiseToast } from "@plane/ui"; import { Loader, ToggleSwitch, setPromiseToast } from "@plane/ui";
// components // components
import { PageHeader } from "@/components/core"; import { PageHeader } from "@/components/core";
// hooks // hooks
// helpers // helpers
import { resolveGeneralTheme } from "@/helpers/common.helper"; import { cn, resolveGeneralTheme } from "@/helpers/common.helper";
import { useInstance } from "@/hooks/store"; import { useInstance } from "@/hooks/store";
// images // images
import githubLightModeImage from "@/public/logos/github-black.png"; import githubLightModeImage from "@/public/logos/github-black.png";
@ -45,6 +45,8 @@ const InstanceAuthenticationPage = observer(() => {
const [isSubmitting, setIsSubmitting] = useState<boolean>(false); const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
// theme // theme
const { resolvedTheme } = useTheme(); const { resolvedTheme } = useTheme();
// derived values
const enableSignUpConfig = formattedConfig?.ENABLE_SIGNUP ?? "";
const updateConfig = async (key: TInstanceConfigurationKeys, value: string) => { const updateConfig = async (key: TInstanceConfigurationKeys, value: string) => {
setIsSubmitting(true); setIsSubmitting(true);
@ -129,7 +131,34 @@ const InstanceAuthenticationPage = observer(() => {
<div className="flex-grow overflow-hidden overflow-y-scroll vertical-scrollbar scrollbar-md px-4"> <div className="flex-grow overflow-hidden overflow-y-scroll vertical-scrollbar scrollbar-md px-4">
{formattedConfig ? ( {formattedConfig ? (
<div className="space-y-3"> <div className="space-y-3">
<div className="text-lg font-medium">Authentication modes</div> <div className="text-lg font-medium pb-1">Sign-up configuration</div>
<div className={cn("w-full flex items-center gap-14 rounded")}>
<div className="flex grow items-center gap-4">
<div className="grow">
<div className={cn("font-medium leading-5 text-custom-text-100 text-sm")}>
Allow anyone to sign up without invite
</div>
<div className={cn("font-normal leading-5 text-custom-text-300 text-xs")}>
Toggling this off will disable self sign ups.
</div>
</div>
</div>
<div className={`shrink-0 pr-4 ${isSubmitting && "opacity-70"}`}>
<div className="flex items-center gap-4">
<ToggleSwitch
value={Boolean(parseInt(enableSignUpConfig))}
onChange={() => {
Boolean(parseInt(enableSignUpConfig)) === true
? updateConfig("ENABLE_SIGNUP", "0")
: updateConfig("ENABLE_SIGNUP", "1");
}}
size="sm"
disabled={isSubmitting}
/>
</div>
</div>
</div>
<div className="text-lg font-medium pt-6">Authentication modes</div>
{authenticationMethodsCard.map((method) => ( {authenticationMethodsCard.map((method) => (
<AuthenticationMethodCard <AuthenticationMethodCard
key={method.key} key={method.key}

View File

@ -45,7 +45,7 @@ export const HelpSection: FC = observer(() => {
return ( return (
<div <div
className={cn( className={cn(
"flex w-full items-center justify-between gap-1 self-baseline border-t border-custom-border-200 bg-custom-sidebar-background-100 px-4 h-28", "flex w-full items-center justify-between gap-1 self-baseline border-t border-custom-border-200 bg-custom-sidebar-background-100 px-4 h-14 flex-shrink-0",
{ {
"flex-col h-auto py-1.5": isSidebarCollapsed, "flex-col h-auto py-1.5": isSidebarCollapsed,
} }