* feat: add synchronization configuration for multiple providers in authentication adapter * implement check_sync_enabled method to determine if sync is enabled for Google, GitHub, GitLab, Gitea, OIDC, and SAML providers * update user data synchronization logic to utilize the new method * add configuration variables for enabling sync for each provider in instance configuration files * feat: add sync toggle for OAuth providers in configuration forms * refactor: simplify sync check logic in Adapter class * refactor: improve toggle switch logic for better readability and performance --------- Co-authored-by: b-saikrishnakanth <[email protected]>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import type { Control, FieldPath, FieldValues } from "react-hook-form";
|
|
import { Controller } from "react-hook-form";
|
|
// plane internal packages
|
|
import { ToggleSwitch } from "@plane/ui";
|
|
|
|
type Props<T extends FieldValues = FieldValues> = {
|
|
control: Control<T>;
|
|
field: TControllerSwitchFormField<T>;
|
|
};
|
|
|
|
export type TControllerSwitchFormField<T extends FieldValues = FieldValues> = {
|
|
name: FieldPath<T>;
|
|
label: string;
|
|
};
|
|
|
|
export function ControllerSwitch<T extends FieldValues>(props: Props<T>) {
|
|
const {
|
|
control,
|
|
field: { name, label },
|
|
} = props;
|
|
|
|
return (
|
|
<div className="flex items-center justify-between gap-1">
|
|
<h4 className="text-sm text-custom-text-300">Refresh user attributes from {label} during sign in</h4>
|
|
<div className="relative">
|
|
<Controller
|
|
control={control}
|
|
name={name as FieldPath<T>}
|
|
render={({ field: { value, onChange } }) => {
|
|
const parsedValue = Number.parseInt(typeof value === "string" ? value : String(value ?? "0"), 10);
|
|
const isOn = !Number.isNaN(parsedValue) && parsedValue !== 0;
|
|
return <ToggleSwitch value={isOn} onChange={() => onChange(isOn ? "0" : "1")} size="sm" />;
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|