Realm settings(Email): Adds email tab to realm settings section (#549)
* email tab wip * save username and pw info on auth toggle * add email tab * remove comments * remove log stmt * add help text * adjust styles * format * fix conflicts and address PR feedback * add back ref on reply to display name * rebase and fix conflicts * prevent save without sender email * add className prop to formpanel
This commit is contained in:
parent
78f843cdcc
commit
15677b6bfb
11 changed files with 603 additions and 230 deletions
|
@ -8,12 +8,6 @@ describe("Realm settings test", () => {
|
|||
const sidebarPage = new SidebarPage();
|
||||
const realmSettingsPage = new RealmSettingsPage();
|
||||
|
||||
const managedAccessSwitch = "user-managed-access-switch";
|
||||
const userRegSwitch = "user-reg-switch";
|
||||
const forgotPwdSwitch = "forgot-pw-switch";
|
||||
const rememberMeSwitch = "remember-me-switch";
|
||||
const verifyEmailSwitch = "verify-email-switch";
|
||||
|
||||
describe("Realm settings", function () {
|
||||
beforeEach(function () {
|
||||
keycloakBefore();
|
||||
|
@ -22,19 +16,33 @@ describe("Realm settings test", () => {
|
|||
|
||||
it("Go to general tab", function () {
|
||||
sidebarPage.goToRealmSettings();
|
||||
realmSettingsPage.toggleSwitch(managedAccessSwitch);
|
||||
realmSettingsPage.saveGeneral();
|
||||
realmSettingsPage.toggleSwitch(managedAccessSwitch);
|
||||
realmSettingsPage.saveGeneral();
|
||||
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
|
||||
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
||||
realmSettingsPage.toggleSwitch(realmSettingsPage.managedAccessSwitch);
|
||||
realmSettingsPage.save(realmSettingsPage.generalSaveBtn);
|
||||
});
|
||||
|
||||
it("Go to login tab", function () {
|
||||
sidebarPage.goToRealmSettings();
|
||||
cy.getId("rs-login-tab").click();
|
||||
realmSettingsPage.toggleSwitch(userRegSwitch);
|
||||
realmSettingsPage.toggleSwitch(forgotPwdSwitch);
|
||||
realmSettingsPage.toggleSwitch(rememberMeSwitch);
|
||||
realmSettingsPage.toggleSwitch(verifyEmailSwitch);
|
||||
realmSettingsPage.toggleSwitch(realmSettingsPage.userRegSwitch);
|
||||
realmSettingsPage.toggleSwitch(realmSettingsPage.forgotPwdSwitch);
|
||||
realmSettingsPage.toggleSwitch(realmSettingsPage.rememberMeSwitch);
|
||||
realmSettingsPage.toggleSwitch(realmSettingsPage.verifyEmailSwitch);
|
||||
});
|
||||
|
||||
it("Go to email tab", function () {
|
||||
sidebarPage.goToRealmSettings();
|
||||
cy.getId("rs-email-tab").click();
|
||||
|
||||
realmSettingsPage.addSenderEmail("example@example.com");
|
||||
|
||||
cy.wait(100);
|
||||
|
||||
realmSettingsPage.toggleCheck(realmSettingsPage.enableSslCheck);
|
||||
realmSettingsPage.toggleCheck(realmSettingsPage.enableStartTlsCheck);
|
||||
|
||||
realmSettingsPage.save(realmSettingsPage.emailSaveBtn);
|
||||
});
|
||||
|
||||
it("Go to themes tab", function () {
|
||||
|
@ -42,7 +50,7 @@ describe("Realm settings test", () => {
|
|||
cy.getId("rs-themes-tab").click();
|
||||
realmSettingsPage.selectLoginThemeType("keycloak");
|
||||
realmSettingsPage.selectAccountThemeType("keycloak");
|
||||
realmSettingsPage.selectAdminThemeType("keycloak.v2");
|
||||
realmSettingsPage.selectAdminThemeType("base");
|
||||
realmSettingsPage.selectEmailThemeType("base");
|
||||
|
||||
realmSettingsPage.saveThemes();
|
||||
|
|
|
@ -1,33 +1,30 @@
|
|||
export default class RealmSettingsPage {
|
||||
saveBtnGeneral: string;
|
||||
saveBtnThemes: string;
|
||||
loginTab: string;
|
||||
selectLoginTheme: string;
|
||||
loginThemeList: string;
|
||||
selectAccountTheme: string;
|
||||
accountThemeList: string;
|
||||
selectAdminTheme: string;
|
||||
adminThemeList: string;
|
||||
selectEmailTheme: string;
|
||||
emailThemeList: string;
|
||||
selectDefaultLocale: string;
|
||||
defaultLocaleList: string;
|
||||
|
||||
constructor() {
|
||||
this.saveBtnGeneral = "general-tab-save";
|
||||
this.saveBtnThemes = "themes-tab-save";
|
||||
this.loginTab = "rs-login-tab";
|
||||
this.selectLoginTheme = "#kc-login-theme";
|
||||
this.loginThemeList = "#kc-login-theme + ul";
|
||||
this.selectAccountTheme = "#kc-account-theme";
|
||||
this.accountThemeList = "#kc-account-theme + ul";
|
||||
this.selectAdminTheme = "#kc-admin-console-theme";
|
||||
this.adminThemeList = "#kc-admin-console-theme + ul";
|
||||
this.selectEmailTheme = "#kc-email-theme";
|
||||
this.emailThemeList = "#kc-email-theme + ul";
|
||||
this.selectDefaultLocale = "select-default-locale";
|
||||
this.defaultLocaleList = "select-default-locale + ul";
|
||||
}
|
||||
generalSaveBtn = "general-tab-save";
|
||||
themesSaveBtn = "themes-tab-save";
|
||||
loginTab = "rs-login-tab";
|
||||
selectLoginTheme = "#kc-login-theme";
|
||||
loginThemeList = "#kc-login-theme + ul";
|
||||
selectAccountTheme = "#kc-account-theme";
|
||||
accountThemeList = "#kc-account-theme + ul";
|
||||
selectAdminTheme = "#kc-admin-console-theme";
|
||||
adminThemeList = "#kc-admin-console-theme + ul";
|
||||
selectEmailTheme = "#kc-email-theme";
|
||||
emailThemeList = "#kc-email-theme + ul";
|
||||
selectDefaultLocale = "select-default-locale";
|
||||
defaultLocaleList = "select-default-locale + ul";
|
||||
emailSaveBtn = "email-tab-save";
|
||||
managedAccessSwitch = "user-managed-access-switch";
|
||||
userRegSwitch = "user-reg-switch";
|
||||
forgotPwdSwitch = "forgot-pw-switch";
|
||||
rememberMeSwitch = "remember-me-switch";
|
||||
emailAsUsernameSwitch = "email-as-username-switch";
|
||||
loginWithEmailSwitch = "login-with-email-switch";
|
||||
duplicateEmailsSwitch = "duplicate-emails-switch";
|
||||
verifyEmailSwitch = "verify-email-switch";
|
||||
authSwitch = "email-authentication-switch";
|
||||
fromInput = "sender-email-address";
|
||||
enableSslCheck = "enable-ssl";
|
||||
enableStartTlsCheck = "enable-start-tls";
|
||||
|
||||
selectLoginThemeType(themeType: string) {
|
||||
cy.get(this.selectLoginTheme).click();
|
||||
|
@ -59,20 +56,42 @@ export default class RealmSettingsPage {
|
|||
return this;
|
||||
}
|
||||
|
||||
saveGeneral() {
|
||||
cy.getId(this.generalSaveBtn).click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
saveThemes() {
|
||||
cy.getId(this.themesSaveBtn).click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
addSenderEmail(senderEmail: string) {
|
||||
cy.getId(this.fromInput).clear();
|
||||
|
||||
if (senderEmail) {
|
||||
cy.getId(this.fromInput).type(senderEmail);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toggleSwitch(switchName: string) {
|
||||
cy.getId(switchName).next().click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
saveGeneral() {
|
||||
cy.getId(this.saveBtnGeneral).click();
|
||||
toggleCheck(switchName: string) {
|
||||
cy.getId(switchName).click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
saveThemes() {
|
||||
cy.getId(this.saveBtnThemes).click();
|
||||
save(saveBtn: string) {
|
||||
cy.getId(saveBtn).click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -13,12 +13,18 @@ type FormPanelProps = {
|
|||
title: string;
|
||||
scrollId?: string;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export const FormPanel = ({ title, children, scrollId }: FormPanelProps) => {
|
||||
export const FormPanel = ({
|
||||
title,
|
||||
children,
|
||||
scrollId,
|
||||
className,
|
||||
}: FormPanelProps) => {
|
||||
return (
|
||||
<Card isFlat className="kc-form-panel__panel">
|
||||
<CardHeader>
|
||||
<Card className={className} isFlat>
|
||||
<CardHeader className="kc-form-panel__header">
|
||||
<CardTitle tabIndex={0}>
|
||||
<Title
|
||||
headingLevel="h4"
|
||||
|
@ -31,7 +37,7 @@ export const FormPanel = ({ title, children, scrollId }: FormPanelProps) => {
|
|||
</Title>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardBody>{children}</CardBody>
|
||||
<CardBody className="kc-form-panel__body">{children}</CardBody>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
|
295
src/realm-settings/EmailTab.tsx
Normal file
295
src/realm-settings/EmailTab.tsx
Normal file
|
@ -0,0 +1,295 @@
|
|||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Controller, useFormContext, UseFormMethods } from "react-hook-form";
|
||||
import {
|
||||
ActionGroup,
|
||||
Button,
|
||||
Checkbox,
|
||||
FormGroup,
|
||||
PageSection,
|
||||
Switch,
|
||||
TextInput,
|
||||
} from "@patternfly/react-core";
|
||||
|
||||
import RealmRepresentation from "keycloak-admin/lib/defs/realmRepresentation";
|
||||
import { FormAccess } from "../components/form-access/FormAccess";
|
||||
import { HelpItem } from "../components/help-enabler/HelpItem";
|
||||
import { FormPanel } from "../components/scroll-form/FormPanel";
|
||||
|
||||
import "./RealmSettingsSection.css";
|
||||
import { emailRegexPattern } from "../util";
|
||||
|
||||
export type UserFormProps = {
|
||||
form: UseFormMethods<RealmRepresentation>;
|
||||
};
|
||||
|
||||
type RealmSettingsEmailTabProps = {
|
||||
save: (realm: RealmRepresentation) => void;
|
||||
reset: () => void;
|
||||
};
|
||||
|
||||
export const RealmSettingsEmailTab = ({
|
||||
save,
|
||||
reset,
|
||||
}: RealmSettingsEmailTabProps) => {
|
||||
const { t } = useTranslation("realm-settings");
|
||||
const [isAuthenticationEnabled, setAuthenticationEnabled] = useState("");
|
||||
const { register, control, handleSubmit, errors } = useFormContext();
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageSection variant="light">
|
||||
<FormPanel title={t("template")} className="kc-email-template">
|
||||
<FormAccess
|
||||
isHorizontal
|
||||
role="manage-realm"
|
||||
className="pf-u-mt-lg"
|
||||
onSubmit={handleSubmit(save)}
|
||||
>
|
||||
<FormGroup
|
||||
label={t("from")}
|
||||
fieldId="kc-display-name"
|
||||
isRequired
|
||||
validated={
|
||||
errors.attributes?.from?.type === "pattern"
|
||||
? "error"
|
||||
: "default"
|
||||
}
|
||||
helperTextInvalid={t("users:emailInvalid")}
|
||||
>
|
||||
<TextInput
|
||||
type="email"
|
||||
id="kc-sender-email-address"
|
||||
data-testid="sender-email-address"
|
||||
name="attributes.from"
|
||||
ref={register({
|
||||
pattern: emailRegexPattern,
|
||||
required: true,
|
||||
})}
|
||||
placeholder="Sender email address"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("fromDisplayName")}
|
||||
fieldId="kc-from-display-name"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText="realm-settings-help:fromDisplayName"
|
||||
forLabel={t("authentication")}
|
||||
forID="kc-user-manged-access"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<TextInput
|
||||
type="text"
|
||||
id="kc-from-display-name"
|
||||
data-testid="from-display-name"
|
||||
name="attributes.fromDisplayName"
|
||||
ref={register}
|
||||
placeholder="Display name for Sender email address"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("replyTo")}
|
||||
fieldId="kc-reply-to"
|
||||
validated={
|
||||
errors.attributes?.replyTo?.type === "pattern"
|
||||
? "error"
|
||||
: "default"
|
||||
}
|
||||
helperTextInvalid={t("users:emailInvalid")}
|
||||
>
|
||||
<TextInput
|
||||
type="email"
|
||||
id="kc-reply-to"
|
||||
name="attributes.replyTo"
|
||||
ref={register({
|
||||
pattern: emailRegexPattern,
|
||||
})}
|
||||
placeholder="Reply to email address"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("replyToDisplayName")}
|
||||
fieldId="kc-reply-to-display-name"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText="realm-settings-help:replyToDisplayName"
|
||||
forLabel={t("replyToDisplayName")}
|
||||
forID="kc-user-manged-access"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<TextInput
|
||||
type="text"
|
||||
id="kc-reply-to-display-name"
|
||||
name="attributes.replyToDisplayName"
|
||||
ref={register}
|
||||
placeholder='Display name for "reply to" email address'
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("envelopeFrom")}
|
||||
fieldId="kc-envelope-from"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText="realm-settings-help:envelopeFrom"
|
||||
forLabel={t("envelopeFrom")}
|
||||
forID="kc-envelope-from"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<TextInput
|
||||
type="text"
|
||||
id="kc-envelope-from"
|
||||
name="attributes.envelopeFrom"
|
||||
ref={register}
|
||||
placeholder="Sender envelope email address"
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormAccess>
|
||||
</FormPanel>
|
||||
<FormPanel
|
||||
className="kc-email-connection"
|
||||
title={t("connectionAndAuthentication")}
|
||||
>
|
||||
<FormAccess
|
||||
isHorizontal
|
||||
role="manage-realm"
|
||||
className="pf-u-mt-lg"
|
||||
onSubmit={handleSubmit(save)}
|
||||
>
|
||||
<FormGroup label={t("host")} fieldId="kc-host" isRequired>
|
||||
<TextInput
|
||||
type="text"
|
||||
id="kc-host"
|
||||
name="attributes.host"
|
||||
ref={register({ required: true })}
|
||||
placeholder="SMTP host"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup label={t("port")} fieldId="kc-port">
|
||||
<TextInput
|
||||
type="text"
|
||||
id="kc-port"
|
||||
name="attributes.port"
|
||||
ref={register}
|
||||
placeholder="SMTP port (defaults to 25)"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup label={t("encryption")} fieldId="kc-html-display-name">
|
||||
<Controller
|
||||
name="attributes.enableSsl"
|
||||
control={control}
|
||||
defaultValue="false"
|
||||
render={({ onChange, value }) => (
|
||||
<Checkbox
|
||||
id="kc-enable-ssl"
|
||||
data-testid="enable-ssl"
|
||||
name="attributes.enableSsl"
|
||||
label={t("enableSSL")}
|
||||
ref={register}
|
||||
isChecked={value === "true"}
|
||||
onChange={(value) => onChange("" + value)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
name="attributes.enableStartTls"
|
||||
control={control}
|
||||
defaultValue="false"
|
||||
render={({ onChange, value }) => (
|
||||
<Checkbox
|
||||
id="kc-enable-start-tls"
|
||||
data-testid="enable-start-tls"
|
||||
name="attributes.startTls"
|
||||
label={t("enableStartTLS")}
|
||||
ref={register}
|
||||
isChecked={value === "true"}
|
||||
onChange={(value) => onChange("" + value)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
hasNoPaddingTop
|
||||
label={t("authentication")}
|
||||
fieldId="kc-authentication"
|
||||
>
|
||||
<Controller
|
||||
name="attributes.authentication"
|
||||
control={control}
|
||||
defaultValue="true"
|
||||
render={({ onChange, value }) => (
|
||||
<Switch
|
||||
id="kc-authentication"
|
||||
data-testid="email-authentication-switch"
|
||||
label={t("common:enabled")}
|
||||
labelOff={t("common:disabled")}
|
||||
isChecked={value === "true"}
|
||||
onChange={(value) => {
|
||||
onChange("" + value);
|
||||
setAuthenticationEnabled(String(value));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</FormGroup>
|
||||
{isAuthenticationEnabled === "true" && (
|
||||
<>
|
||||
<FormGroup
|
||||
label={t("username")}
|
||||
fieldId="kc-username"
|
||||
isRequired={isAuthenticationEnabled === "true"}
|
||||
>
|
||||
<TextInput
|
||||
type="text"
|
||||
id="kc-username"
|
||||
data-testid="username-input"
|
||||
name="attributes.loginUsername"
|
||||
ref={register({ required: true })}
|
||||
placeholder="Login username"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("password")}
|
||||
fieldId="kc-username"
|
||||
isRequired={isAuthenticationEnabled === "true"}
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText="realm-settings-help:frontendUrl"
|
||||
forLabel={t("password")}
|
||||
forID="kc-password"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<TextInput
|
||||
type="password"
|
||||
id="kc-password"
|
||||
data-testid="password-input"
|
||||
name="attributes.loginPassword"
|
||||
ref={register}
|
||||
placeholder="Login password"
|
||||
/>
|
||||
</FormGroup>
|
||||
</>
|
||||
)}
|
||||
|
||||
<ActionGroup>
|
||||
<Button
|
||||
variant="primary"
|
||||
type="submit"
|
||||
data-testid="email-tab-save"
|
||||
>
|
||||
{t("common:save")}
|
||||
</Button>
|
||||
<Button variant="link" onClick={reset}>
|
||||
{t("common:revert")}
|
||||
</Button>
|
||||
</ActionGroup>
|
||||
</FormAccess>
|
||||
</FormPanel>
|
||||
</PageSection>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -21,192 +21,188 @@ export const RealmSettingsLoginTab = ({
|
|||
<>
|
||||
<PageSection variant="light">
|
||||
<FormPanel title="Login screen customization">
|
||||
{
|
||||
<FormAccess isHorizontal role="manage-realm">
|
||||
<FormGroup
|
||||
label={t("userRegistration")}
|
||||
fieldId="kc-user-reg"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("userRegistrationHelpText")}
|
||||
forLabel={t("userRegistration")}
|
||||
forID="kc-user-reg"
|
||||
/>
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-user-reg"
|
||||
data-testid="user-reg-switch"
|
||||
name="registrationAllowed"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.registrationAllowed}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, registrationAllowed: value });
|
||||
}}
|
||||
<FormAccess isHorizontal role="manage-realm">
|
||||
<FormGroup
|
||||
label={t("userRegistration")}
|
||||
fieldId="kc-user-reg"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("userRegistrationHelpText")}
|
||||
forLabel={t("userRegistration")}
|
||||
forID="kc-user-reg"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("forgotPassword")}
|
||||
fieldId="kc-forgot-pw"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("forgotPasswordHelpText")}
|
||||
forLabel={t("forgotPassword")}
|
||||
forID="kc-forgot-pw"
|
||||
/>
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-forgot-pw"
|
||||
data-testid="forgot-pw-switch"
|
||||
name="resetPasswordAllowed"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.resetPasswordAllowed}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, resetPasswordAllowed: value });
|
||||
}}
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-user-reg"
|
||||
data-testid="user-reg-switch"
|
||||
name="registrationAllowed"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.registrationAllowed}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, registrationAllowed: value });
|
||||
}}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("forgotPassword")}
|
||||
fieldId="kc-forgot-pw"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("forgotPasswordHelpText")}
|
||||
forLabel={t("forgotPassword")}
|
||||
forID="kc-forgot-pw"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("rememberMe")}
|
||||
fieldId="kc-remember-me"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("rememberMeHelpText")}
|
||||
forLabel={t("rememberMe")}
|
||||
forID="kc-remember-me"
|
||||
/>
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-remember-me"
|
||||
data-testid="remember-me-switch"
|
||||
name="rememberMe"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.rememberMe}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, rememberMe: value });
|
||||
}}
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-forgot-pw"
|
||||
data-testid="forgot-pw-switch"
|
||||
name="resetPasswordAllowed"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.resetPasswordAllowed}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, resetPasswordAllowed: value });
|
||||
}}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("rememberMe")}
|
||||
fieldId="kc-remember-me"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("rememberMeHelpText")}
|
||||
forLabel={t("rememberMe")}
|
||||
forID="kc-remember-me"
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormAccess>
|
||||
}
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-remember-me"
|
||||
data-testid="remember-me-switch"
|
||||
name="rememberMe"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.rememberMe}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, rememberMe: value });
|
||||
}}
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormAccess>
|
||||
</FormPanel>
|
||||
<FormPanel title="Email settings">
|
||||
{
|
||||
<FormAccess isHorizontal role="manage-realm">
|
||||
<FormGroup
|
||||
label={t("emailAsUsername")}
|
||||
fieldId="kc-email-as-username"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("emailAsUsernameHelpText")}
|
||||
forLabel={t("emailAsUsername")}
|
||||
forID="kc-email-as-username"
|
||||
/>
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-email-as-username"
|
||||
data-testid="email-as-username-switch"
|
||||
name="registrationEmailAsUsername"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.registrationEmailAsUsername}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, registrationEmailAsUsername: value });
|
||||
}}
|
||||
<FormAccess isHorizontal role="manage-realm">
|
||||
<FormGroup
|
||||
label={t("emailAsUsername")}
|
||||
fieldId="kc-email-as-username"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("emailAsUsernameHelpText")}
|
||||
forLabel={t("emailAsUsername")}
|
||||
forID="kc-email-as-username"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("loginWithEmail")}
|
||||
fieldId="kc-login-with-email"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("loginWithEmailHelpText")}
|
||||
forLabel={t("loginWithEmail")}
|
||||
forID="kc-login-with-email"
|
||||
/>
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-login-with-email"
|
||||
data-testid="login-with-email-switch"
|
||||
name="loginWithEmailAllowed"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.loginWithEmailAllowed}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, loginWithEmailAllowed: value });
|
||||
}}
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-email-as-username"
|
||||
data-testid="email-as-username-switch"
|
||||
name="registrationEmailAsUsername"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.registrationEmailAsUsername}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, registrationEmailAsUsername: value });
|
||||
}}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("loginWithEmail")}
|
||||
fieldId="kc-login-with-email"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("loginWithEmailHelpText")}
|
||||
forLabel={t("loginWithEmail")}
|
||||
forID="kc-login-with-email"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("duplicateEmails")}
|
||||
fieldId="kc-duplicate-emails"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("duplicateEmailsHelpText")}
|
||||
forLabel={t("duplicateEmails")}
|
||||
forID="kc-duplicate-emails"
|
||||
/>
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-duplicate-emails"
|
||||
data-testid="duplicate-emails-switch"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
name="duplicateEmailsAllowed"
|
||||
isChecked={
|
||||
realm?.duplicateEmailsAllowed &&
|
||||
!realm?.loginWithEmailAllowed &&
|
||||
!realm?.registrationEmailAsUsername
|
||||
}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, duplicateEmailsAllowed: value });
|
||||
}}
|
||||
isDisabled={
|
||||
realm?.loginWithEmailAllowed ||
|
||||
realm?.registrationEmailAsUsername
|
||||
}
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-login-with-email"
|
||||
data-testid="login-with-email-switch"
|
||||
name="loginWithEmailAllowed"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.loginWithEmailAllowed}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, loginWithEmailAllowed: value });
|
||||
}}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("duplicateEmails")}
|
||||
fieldId="kc-duplicate-emails"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("duplicateEmailsHelpText")}
|
||||
forLabel={t("duplicateEmails")}
|
||||
forID="kc-duplicate-emails"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("verifyEmail")}
|
||||
fieldId="kc-verify-email"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("verifyEmailHelpText")}
|
||||
forLabel={t("verifyEmail")}
|
||||
forID="kc-verify-email"
|
||||
/>
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-duplicate-emails"
|
||||
data-testid="duplicate-emails-switch"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
name="duplicateEmailsAllowed"
|
||||
isChecked={
|
||||
realm?.duplicateEmailsAllowed &&
|
||||
!realm?.loginWithEmailAllowed &&
|
||||
!realm?.registrationEmailAsUsername
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-verify-email"
|
||||
data-testid="verify-email-switch"
|
||||
name="verifyEmail"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.verifyEmail}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, verifyEmail: value });
|
||||
}}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, duplicateEmailsAllowed: value });
|
||||
}}
|
||||
isDisabled={
|
||||
realm?.loginWithEmailAllowed ||
|
||||
realm?.registrationEmailAsUsername
|
||||
}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup
|
||||
label={t("verifyEmail")}
|
||||
fieldId="kc-verify-email"
|
||||
labelIcon={
|
||||
<HelpItem
|
||||
helpText={t("verifyEmailHelpText")}
|
||||
forLabel={t("verifyEmail")}
|
||||
forID="kc-verify-email"
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormAccess>
|
||||
}
|
||||
}
|
||||
hasNoPaddingTop
|
||||
>
|
||||
<Switch
|
||||
id="kc-verify-email"
|
||||
data-testid="verify-email-switch"
|
||||
name="verifyEmail"
|
||||
label={t("common:on")}
|
||||
labelOff={t("common:off")}
|
||||
isChecked={realm?.verifyEmail}
|
||||
onChange={(value) => {
|
||||
save({ ...realm, verifyEmail: value });
|
||||
}}
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormAccess>
|
||||
</FormPanel>
|
||||
</PageSection>
|
||||
</>
|
||||
|
|
18
src/realm-settings/RealmSettingsSection.css
Normal file
18
src/realm-settings/RealmSettingsSection.css
Normal file
|
@ -0,0 +1,18 @@
|
|||
.pf-c-card.pf-m-flat.kc-email-template,
|
||||
.pf-c-card.pf-m-flat.kc-email-connection {
|
||||
border: none;
|
||||
margin-top: 0px;
|
||||
margin-bottom: 0px;
|
||||
padding-bottom: var(--pf-global--spacer--sm);
|
||||
}
|
||||
|
||||
div.pf-c-card__header.kc-form-panel__header {
|
||||
padding-bottom: 0px;
|
||||
padding-left: 0px;
|
||||
padding-top: 0px;
|
||||
}
|
||||
|
||||
div.pf-c-card__body.kc-form-panel__body {
|
||||
padding-left: 0px;
|
||||
padding-bottom: var(--pf-global--spacer--2xl);
|
||||
}
|
|
@ -25,6 +25,7 @@ import { RealmSettingsLoginTab } from "./LoginTab";
|
|||
import { RealmSettingsGeneralTab } from "./GeneralTab";
|
||||
import { PartialImportDialog } from "./PartialImport";
|
||||
import { RealmSettingsThemesTab } from "./ThemesTab";
|
||||
import { RealmSettingsEmailTab } from "./EmailTab";
|
||||
|
||||
type RealmSettingsHeaderProps = {
|
||||
onChange: (value: boolean) => void;
|
||||
|
@ -186,6 +187,16 @@ export const RealmSettingsSection = () => {
|
|||
>
|
||||
<RealmSettingsLoginTab save={save} realm={realm!} />
|
||||
</Tab>
|
||||
<Tab
|
||||
eventKey="email"
|
||||
title={<TabTitleText>{t("realm-settings:email")}</TabTitleText>}
|
||||
data-testid="rs-email-tab"
|
||||
>
|
||||
<RealmSettingsEmailTab
|
||||
save={save}
|
||||
reset={() => setupForm(realm!)}
|
||||
/>
|
||||
</Tab>
|
||||
<Tab
|
||||
eventKey="themes"
|
||||
title={<TabTitleText>{t("realm-settings:themes")}</TabTitleText>}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"realm-settings-help": {
|
||||
"fromDisplayName": "A user-friendly name for the 'From' address (optional).",
|
||||
"replyToDisplayName": "A user-friendly name for the 'Reply-To' address (optional).",
|
||||
"envelopeFrom": "An email address used for bounces (optional).",
|
||||
"frontendUrl": "Set the frontend URL for the realm. Use in combination with the default hostname provider to override the base URL for frontend requests for a specific realm.",
|
||||
"requireSsl": "Is HTTPS required? 'None' means HTTPS is not required for any client IP address. 'External requests' means localhost and private IP addresses can access without HTTPS. 'All requests' means HTTPS is required for all IP addresses.",
|
||||
"userManagedAccess": "If enabled, users are allowed to manage their resources and permissions using the Account Management Console.",
|
||||
|
|
|
@ -14,6 +14,22 @@
|
|||
"general": "General",
|
||||
"login": "Login",
|
||||
"themes": "Themes",
|
||||
"email": "Email",
|
||||
"template": "Template",
|
||||
"connectionAndAuthentication": "Connection & Authentication",
|
||||
"from": "From",
|
||||
"fromDisplayName": "From display name",
|
||||
"replyTo": "Reply to",
|
||||
"replyToDisplayName": "Reply to display name",
|
||||
"envelopeFrom": "Envelope from",
|
||||
"host": "Host",
|
||||
"port": "Port",
|
||||
"encryption": "Encryption",
|
||||
"authentication": "Authentication",
|
||||
"enableSSL": "Enable SSL",
|
||||
"enableStartTLS": "Enable StartTLS",
|
||||
"username": "Username",
|
||||
"password": "Password",
|
||||
"userRegistration": "User registration",
|
||||
"userRegistrationHelpText": "Enable/disable the registration page. A link for registration will show on login page too.",
|
||||
"forgotPassword": "Forgot password",
|
||||
|
|
|
@ -25,6 +25,7 @@ import moment from "moment";
|
|||
import { JoinGroupDialog } from "./JoinGroupDialog";
|
||||
import GroupRepresentation from "keycloak-admin/lib/defs/groupRepresentation";
|
||||
import { useAlerts } from "../components/alert/Alerts";
|
||||
import { emailRegexPattern } from "../util";
|
||||
|
||||
export type UserFormProps = {
|
||||
form: UseFormMethods<UserRepresentation>;
|
||||
|
@ -86,8 +87,6 @@ export const UserForm = ({
|
|||
});
|
||||
};
|
||||
|
||||
const emailRegexPattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
|
||||
const requiredUserActionsOptions = [
|
||||
<SelectOption key={0} value="CONFIGURE_TOTP">
|
||||
{t("configureOTP")}
|
||||
|
|
|
@ -91,3 +91,5 @@ export const getBaseUrl = (adminClient: KeycloakAdminClient) => {
|
|||
? adminClient.keycloak.authServerUrl!
|
||||
: adminClient.baseUrl + "/";
|
||||
};
|
||||
|
||||
export const emailRegexPattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
|
|
Loading…
Reference in a new issue