64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
/**
|
|
* SPDX-FileCopyrightText: 2023-present Plane Software, Inc.
|
|
* SPDX-License-Identifier: LicenseRef-Plane-Commercial
|
|
*
|
|
* Licensed under the Plane Commercial License (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* https://plane.so/legals/eula
|
|
*
|
|
* DO NOT remove or modify this notice.
|
|
* NOTICE: Proprietary and confidential. Unauthorized use or distribution is prohibited.
|
|
*/
|
|
|
|
import { observer } from "mobx-react";
|
|
import Link from "next/link";
|
|
// icons
|
|
import { Settings2 } from "lucide-react";
|
|
// plane internal packages
|
|
import { getButtonStyling } from "@plane/propel/button";
|
|
import { Switch } from "@plane/propel/switch";
|
|
import type { TInstanceAuthenticationMethodKeys } from "@plane/types";
|
|
import { cn } from "@plane/utils";
|
|
// hooks
|
|
import { useInstance } from "@/hooks/store";
|
|
|
|
type Props = {
|
|
disabled: boolean;
|
|
updateConfig: (key: TInstanceAuthenticationMethodKeys, value: string) => void;
|
|
};
|
|
|
|
export const GithubConfiguration = observer(function GithubConfiguration(props: Props) {
|
|
const { disabled, updateConfig } = props;
|
|
// store
|
|
const { formattedConfig } = useInstance();
|
|
// derived values
|
|
const enableGithubConfig = formattedConfig?.IS_GITHUB_ENABLED ?? "";
|
|
const isGithubConfigured = !!formattedConfig?.GITHUB_CLIENT_ID && !!formattedConfig?.GITHUB_CLIENT_SECRET;
|
|
|
|
return (
|
|
<>
|
|
{isGithubConfigured ? (
|
|
<div className="flex items-center gap-4">
|
|
<Link href="/authentication/github" className={cn(getButtonStyling("link", "base"), "font-medium")}>
|
|
Edit
|
|
</Link>
|
|
<Switch
|
|
value={Boolean(parseInt(enableGithubConfig))}
|
|
onChange={() => {
|
|
const newEnableGithubConfig = Boolean(parseInt(enableGithubConfig)) === true ? "0" : "1";
|
|
updateConfig("IS_GITHUB_ENABLED", newEnableGithubConfig);
|
|
}}
|
|
disabled={disabled}
|
|
/>
|
|
</div>
|
|
) : (
|
|
<Link href="/authentication/github" className={cn(getButtonStyling("secondary", "base"), "text-tertiary")}>
|
|
<Settings2 className="h-4 w-4 p-0.5 text-tertiary" />
|
|
Configure
|
|
</Link>
|
|
)}
|
|
</>
|
|
);
|
|
});
|