2022-05-30 11:07:33 +00:00
|
|
|
import { FormGroup } from "@patternfly/react-core";
|
2022-12-02 14:54:30 +00:00
|
|
|
import { useFormContext } from "react-hook-form-v7";
|
|
|
|
import { useTranslation } from "react-i18next";
|
2022-05-30 11:07:33 +00:00
|
|
|
|
|
|
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
|
|
|
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
|
|
|
|
import { useAccess } from "../../context/access/Access";
|
2022-12-02 14:54:30 +00:00
|
|
|
import { SaveReset } from "../advanced/SaveReset";
|
|
|
|
import { FormFields } from "../ClientDetails";
|
|
|
|
import type { ClientSettingsProps } from "../ClientSettings";
|
2023-01-17 14:29:42 +00:00
|
|
|
import { LoginSettings } from "./LoginSettings";
|
2022-05-30 11:07:33 +00:00
|
|
|
|
|
|
|
export const AccessSettings = ({
|
|
|
|
client,
|
|
|
|
save,
|
|
|
|
reset,
|
|
|
|
}: ClientSettingsProps) => {
|
|
|
|
const { t } = useTranslation("clients");
|
2022-12-02 14:54:30 +00:00
|
|
|
const { register, watch } = useFormContext<FormFields>();
|
2022-05-30 11:07:33 +00:00
|
|
|
|
|
|
|
const { hasAccess } = useAccess();
|
|
|
|
const isManager = hasAccess("manage-clients") || client.access?.configure;
|
|
|
|
|
|
|
|
const protocol = watch("protocol");
|
|
|
|
|
|
|
|
return (
|
|
|
|
<FormAccess
|
|
|
|
isHorizontal
|
|
|
|
fineGrainedAccess={client.access?.configure}
|
|
|
|
role="manage-clients"
|
|
|
|
>
|
2023-01-17 14:29:42 +00:00
|
|
|
{!client.bearerOnly && <LoginSettings protocol={protocol} />}
|
2022-05-30 11:07:33 +00:00
|
|
|
{protocol !== "saml" && (
|
|
|
|
<FormGroup
|
|
|
|
label={t("adminURL")}
|
|
|
|
fieldId="kc-admin-url"
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:adminURL"
|
|
|
|
fieldLabelId="clients:adminURL"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
2022-12-07 09:04:37 +00:00
|
|
|
<KeycloakTextInput
|
|
|
|
id="kc-admin-url"
|
|
|
|
type="url"
|
|
|
|
{...register("adminUrl")}
|
|
|
|
/>
|
2022-05-30 11:07:33 +00:00
|
|
|
</FormGroup>
|
|
|
|
)}
|
|
|
|
{client.bearerOnly && (
|
|
|
|
<SaveReset
|
|
|
|
className="keycloak__form_actions"
|
|
|
|
name="settings"
|
|
|
|
save={save}
|
|
|
|
reset={reset}
|
|
|
|
isActive={!isManager}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</FormAccess>
|
|
|
|
);
|
|
|
|
};
|