Disable sync when import users is off (#2599)

This commit is contained in:
Erik Jan de Wit 2022-05-11 10:32:58 +02:00 committed by GitHub
parent b8569db87c
commit 783396acb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ import { useAlerts } from "../../components/alert/Alerts";
import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog"; import { useConfirmDialog } from "../../components/confirm-dialog/ConfirmDialog";
import { useAdminClient } from "../../context/auth/AdminClient"; import { useAdminClient } from "../../context/auth/AdminClient";
import { Header } from "./Header"; import { Header } from "./Header";
import { useFormContext, useWatch } from "react-hook-form";
type ExtendedHeaderProps = { type ExtendedHeaderProps = {
provider: string; provider: string;
@ -30,6 +31,13 @@ export const ExtendedHeader = ({
const adminClient = useAdminClient(); const adminClient = useAdminClient();
const { addAlert, addError } = useAlerts(); const { addAlert, addError } = useAlerts();
const { control } = useFormContext();
const hasImportUsers = useWatch({
name: "config.importEnabled",
control,
defaultValue: ["true"],
})[0];
const [toggleUnlinkUsersDialog, UnlinkUsersDialog] = useConfirmDialog({ const [toggleUnlinkUsersDialog, UnlinkUsersDialog] = useConfirmDialog({
titleKey: "user-federation:userFedUnlinkUsersConfirmTitle", titleKey: "user-federation:userFedUnlinkUsersConfirmTitle",
messageKey: "user-federation:userFedUnlinkUsersConfirm", messageKey: "user-federation:userFedUnlinkUsersConfirm",
@ -126,10 +134,18 @@ export const ExtendedHeader = ({
noDivider={noDivider} noDivider={noDivider}
save={save} save={save}
dropdownItems={[ dropdownItems={[
<DropdownItem key="sync" onClick={syncChangedUsers}> <DropdownItem
key="sync"
onClick={syncChangedUsers}
isDisabled={hasImportUsers === "false"}
>
{t("syncChangedUsers")} {t("syncChangedUsers")}
</DropdownItem>, </DropdownItem>,
<DropdownItem key="syncall" onClick={syncAllUsers}> <DropdownItem
key="syncall"
onClick={syncAllUsers}
isDisabled={hasImportUsers === "false"}
>
{t("syncAllUsers")} {t("syncAllUsers")}
</DropdownItem>, </DropdownItem>,
<DropdownItem <DropdownItem