import { ReactElement, useState } from "react"; import useSWR from "swr"; import { observer } from "mobx-react-lite"; // layouts import { InstanceAdminHeader, InstanceAdminLayout } from "layouts/admin-layout"; // types import { NextPageWithLayout } from "types/app"; // store import { useMobxStore } from "lib/mobx/store-provider"; // hooks import useToast from "hooks/use-toast"; // icons import { ChevronDown, ChevronRight } from "lucide-react"; // ui import { Loader, ToggleSwitch } from "@plane/ui"; import { Disclosure, Transition } from "@headlessui/react"; // components import { InstanceGoogleConfigForm } from "components/instance/google-config-form"; import { InstanceGithubConfigForm } from "components/instance/github-config-form"; const InstanceAdminAuthorizationPage: NextPageWithLayout = observer(() => { // store const { instance: { fetchInstanceConfigurations, formattedConfig, updateInstanceConfigurations }, } = useMobxStore(); useSWR("INSTANCE_CONFIGURATIONS", () => fetchInstanceConfigurations()); // toast const { setToastAlert } = useToast(); // state const [isSubmitting, setIsSubmitting] = useState(false); const enableSignup = formattedConfig?.ENABLE_SIGNUP ?? "0"; const updateConfig = async (value: string) => { setIsSubmitting(true); const payload = { ENABLE_SIGNUP: value, }; await updateInstanceConfigurations(payload) .then(() => { setToastAlert({ title: "Success", type: "success", message: "Authorization Settings updated successfully", }); setIsSubmitting(false); }) .catch((err) => { console.error(err); setToastAlert({ title: "Error", type: "error", message: "Failed to update Authorization Settings", }); setIsSubmitting(false); }); }; return (
{formattedConfig ? (
Authorization
Make your teams life easy by letting them sign-up with their Google and GitHub accounts, and below are the settings.
Enable sign-up
Keep the doors open so people can join your workspaces.
{ Boolean(parseInt(enableSignup)) === true ? updateConfig("0") : updateConfig("1"); }} size="sm" disabled={isSubmitting} />
{({ open }) => (
Google {open ? : }
)}
{({ open }) => (
Github {open ? : }
)}
) : ( )}
); }); InstanceAdminAuthorizationPage.getLayout = function getLayout(page: ReactElement) { return }>{page}; }; export default InstanceAdminAuthorizationPage;