2021-05-04 08:11:58 +00:00
|
|
|
import { useTranslation } from "react-i18next";
|
2022-03-16 10:37:45 +00:00
|
|
|
import { useFormContext } from "react-hook-form";
|
2022-04-21 15:03:26 +00:00
|
|
|
import { FormGroup } from "@patternfly/react-core";
|
2021-05-04 08:11:58 +00:00
|
|
|
|
2022-03-16 10:37:45 +00:00
|
|
|
import type KeyStoreConfig from "@keycloak/keycloak-admin-client/lib/defs/keystoreConfig";
|
2021-05-04 08:11:58 +00:00
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
|
|
|
import { PasswordInput } from "../../components/password-input/PasswordInput";
|
2022-04-21 15:03:26 +00:00
|
|
|
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
|
2021-05-04 08:11:58 +00:00
|
|
|
|
|
|
|
export const StoreSettings = ({
|
|
|
|
hidePassword = false,
|
|
|
|
}: {
|
|
|
|
hidePassword?: boolean;
|
|
|
|
}) => {
|
|
|
|
const { t } = useTranslation("clients");
|
2022-03-16 10:37:45 +00:00
|
|
|
const { register } = useFormContext<KeyStoreConfig>();
|
2021-05-04 08:11:58 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<FormGroup
|
|
|
|
label={t("keyAlias")}
|
|
|
|
fieldId="keyAlias"
|
2022-03-16 10:37:45 +00:00
|
|
|
isRequired
|
2021-05-04 08:11:58 +00:00
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:keyAlias"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:keyAlias"
|
2021-05-04 08:11:58 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
2022-04-21 15:03:26 +00:00
|
|
|
<KeycloakTextInput
|
2021-05-04 08:11:58 +00:00
|
|
|
data-testid="keyAlias"
|
|
|
|
type="text"
|
|
|
|
id="keyAlias"
|
|
|
|
name="keyAlias"
|
2022-03-16 10:37:45 +00:00
|
|
|
ref={register({ required: true })}
|
2021-05-04 08:11:58 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
{!hidePassword && (
|
|
|
|
<FormGroup
|
|
|
|
label={t("keyPassword")}
|
|
|
|
fieldId="keyPassword"
|
2022-03-16 10:37:45 +00:00
|
|
|
isRequired
|
2021-05-04 08:11:58 +00:00
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:keyPassword"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:keyPassword"
|
2021-05-04 08:11:58 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<PasswordInput
|
|
|
|
data-testid="keyPassword"
|
|
|
|
id="keyPassword"
|
|
|
|
name="keyPassword"
|
2022-03-16 10:37:45 +00:00
|
|
|
ref={register({ required: true })}
|
2021-05-04 08:11:58 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
)}
|
|
|
|
<FormGroup
|
|
|
|
label={t("storePassword")}
|
|
|
|
fieldId="storePassword"
|
2022-03-16 10:37:45 +00:00
|
|
|
isRequired
|
2021-05-04 08:11:58 +00:00
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText="clients-help:storePassword"
|
2021-12-14 14:56:36 +00:00
|
|
|
fieldLabelId="clients:storePassword"
|
2021-05-04 08:11:58 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<PasswordInput
|
|
|
|
data-testid="storePassword"
|
|
|
|
id="storePassword"
|
|
|
|
name="storePassword"
|
2022-03-16 10:37:45 +00:00
|
|
|
ref={register({ required: true })}
|
2021-05-04 08:11:58 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|