2023-04-09 14:06:08 +00:00
import type ComponentRepresentation from "@keycloak/keycloak-admin-client/lib/defs/componentRepresentation" ;
2020-12-15 22:50:09 +00:00
import {
Button ,
Wizard ,
WizardContextConsumer ,
WizardFooter ,
} from "@patternfly/react-core" ;
2023-04-09 14:06:08 +00:00
import { useForm } from "react-hook-form" ;
import { useTranslation } from "react-i18next" ;
2022-08-03 12:12:07 +00:00
2023-04-09 14:06:08 +00:00
import useIsFeatureEnabled , { Feature } from "../utils/useIsFeatureEnabled" ;
import { LdapSettingsAdvanced } from "./ldap/LdapSettingsAdvanced" ;
2021-01-04 21:33:18 +00:00
import { LdapSettingsConnection } from "./ldap/LdapSettingsConnection" ;
2023-04-09 14:06:08 +00:00
import { LdapSettingsGeneral } from "./ldap/LdapSettingsGeneral" ;
import { LdapSettingsKerberosIntegration } from "./ldap/LdapSettingsKerberosIntegration" ;
2021-01-04 21:33:18 +00:00
import { LdapSettingsSearching } from "./ldap/LdapSettingsSearching" ;
import { LdapSettingsSynchronization } from "./ldap/LdapSettingsSynchronization" ;
2021-02-11 20:51:51 +00:00
import { SettingsCache } from "./shared/SettingsCache" ;
2020-12-15 22:50:09 +00:00
export const UserFederationLdapWizard = ( ) = > {
2021-01-26 01:41:14 +00:00
const form = useForm < ComponentRepresentation > ( ) ;
2020-12-15 22:50:09 +00:00
const { t } = useTranslation ( "user-federation" ) ;
2023-04-09 14:06:08 +00:00
const isFeatureEnabled = useIsFeatureEnabled ( ) ;
2020-12-15 22:50:09 +00:00
const steps = [
{
2021-01-04 21:33:18 +00:00
name : t ( "requiredSettings" ) ,
2020-12-15 22:50:09 +00:00
id : "ldapRequiredSettingsStep" ,
2021-01-04 21:33:18 +00:00
component : (
2021-01-26 01:41:14 +00:00
< LdapSettingsGeneral
form = { form }
showSectionHeading
showSectionDescription
/ >
2021-01-04 21:33:18 +00:00
) ,
2020-12-15 22:50:09 +00:00
} ,
{
2021-01-04 21:33:18 +00:00
name : t ( "connectionAndAuthenticationSettings" ) ,
2020-12-15 22:50:09 +00:00
id : "ldapConnectionSettingsStep" ,
2021-01-04 21:33:18 +00:00
component : (
2021-01-26 01:41:14 +00:00
< LdapSettingsConnection
form = { form }
showSectionHeading
showSectionDescription
/ >
2021-01-04 21:33:18 +00:00
) ,
2020-12-15 22:50:09 +00:00
} ,
{
2021-01-04 21:33:18 +00:00
name : t ( "ldapSearchingAndUpdatingSettings" ) ,
2020-12-15 22:50:09 +00:00
id : "ldapSearchingSettingsStep" ,
2021-01-04 21:33:18 +00:00
component : (
2021-01-26 01:41:14 +00:00
< LdapSettingsSearching
form = { form }
showSectionHeading
showSectionDescription
/ >
2021-01-04 21:33:18 +00:00
) ,
2020-12-15 22:50:09 +00:00
} ,
{
2021-01-04 21:33:18 +00:00
name : t ( "synchronizationSettings" ) ,
2020-12-15 22:50:09 +00:00
id : "ldapSynchronizationSettingsStep" ,
2021-01-04 21:33:18 +00:00
component : (
< LdapSettingsSynchronization
2021-01-26 01:41:14 +00:00
form = { form }
2021-01-04 21:33:18 +00:00
showSectionHeading
showSectionDescription
/ >
) ,
2020-12-15 22:50:09 +00:00
} ,
{
2021-01-04 21:33:18 +00:00
name : t ( "kerberosIntegration" ) ,
2020-12-15 22:50:09 +00:00
id : "ldapKerberosIntegrationSettingsStep" ,
2021-01-04 21:33:18 +00:00
component : (
< LdapSettingsKerberosIntegration
2021-01-26 01:41:14 +00:00
form = { form }
2021-01-04 21:33:18 +00:00
showSectionHeading
showSectionDescription
/ >
) ,
2023-04-09 14:06:08 +00:00
isDisabled : ! isFeatureEnabled ( Feature . Kerberos ) ,
2020-12-15 22:50:09 +00:00
} ,
{
2021-01-04 21:33:18 +00:00
name : t ( "cacheSettings" ) ,
2020-12-15 22:50:09 +00:00
id : "ldapCacheSettingsStep" ,
2021-01-04 21:33:18 +00:00
component : (
2021-02-11 20:51:51 +00:00
< SettingsCache form = { form } showSectionHeading showSectionDescription / >
2021-01-04 21:33:18 +00:00
) ,
2020-12-15 22:50:09 +00:00
} ,
{
2021-01-04 21:33:18 +00:00
name : t ( "advancedSettings" ) ,
2020-12-15 22:50:09 +00:00
id : "ldapAdvancedSettingsStep" ,
2021-01-04 21:33:18 +00:00
component : (
2021-01-26 01:41:14 +00:00
< LdapSettingsAdvanced
form = { form }
showSectionHeading
showSectionDescription
/ >
2021-01-04 21:33:18 +00:00
) ,
2020-12-15 22:50:09 +00:00
} ,
] ;
const footer = (
< WizardFooter >
< WizardContextConsumer >
2021-01-04 21:33:18 +00:00
{ ( { activeStep , onNext , onBack , onClose } ) = > {
2020-12-15 22:50:09 +00:00
// First step buttons
2021-03-12 06:42:54 +00:00
if ( activeStep . id === "ldapRequiredSettingsStep" ) {
2020-12-15 22:50:09 +00:00
return (
< >
< Button variant = "primary" type = "submit" onClick = { onNext } >
2021-01-04 21:33:18 +00:00
{ t ( "common:next" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< Button
variant = "secondary"
onClick = { onBack }
className = "pf-m-disabled"
>
2021-01-04 21:33:18 +00:00
{ t ( "common:back" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< Button variant = "link" onClick = { onClose } >
2021-01-04 21:33:18 +00:00
{ t ( "common:cancel" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< / >
) ;
}
// Other required step buttons
else if (
2021-03-12 06:42:54 +00:00
activeStep . id === "ldapConnectionSettingsStep" ||
activeStep . id === "ldapSearchingSettingsStep"
2020-12-15 22:50:09 +00:00
) {
return (
< >
< Button variant = "primary" type = "submit" onClick = { onNext } >
2021-01-04 21:33:18 +00:00
{ t ( "common:next" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< Button variant = "secondary" onClick = { onBack } >
2021-01-04 21:33:18 +00:00
{ t ( "common:back" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< Button variant = "link" onClick = { onClose } >
2021-01-04 21:33:18 +00:00
{ t ( "common:cancel" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< / >
) ;
}
// Last step buttons
2021-03-12 06:42:54 +00:00
else if ( activeStep . id === "ldapAdvancedSettingsStep" ) {
2020-12-15 22:50:09 +00:00
return (
< >
2021-07-27 20:56:16 +00:00
{ /* TODO: close the wizard and finish */ }
< Button > { t ( "common:finish" ) } < / Button >
2020-12-15 22:50:09 +00:00
< Button variant = "secondary" onClick = { onBack } >
2021-01-04 21:33:18 +00:00
{ t ( "common:back" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< Button variant = "link" onClick = { onClose } >
2021-01-04 21:33:18 +00:00
{ t ( "common:cancel" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< / >
) ;
}
// All the other steps buttons
return (
< >
< Button onClick = { onNext } > Next < / Button >
< Button variant = "secondary" onClick = { onBack } >
Back
< / Button >
2021-07-27 20:56:16 +00:00
{ /* TODO: validate last step and finish */ }
< Button variant = "link" >
2021-01-04 21:33:18 +00:00
{ t ( "common:skipCustomizationAndFinish" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< Button variant = "link" onClick = { onClose } >
2021-01-04 21:33:18 +00:00
{ t ( "common:cancel" ) }
2020-12-15 22:50:09 +00:00
< / Button >
< / >
) ;
} }
< / WizardContextConsumer >
< / WizardFooter >
) ;
return (
< Wizard
2021-01-05 16:08:43 +00:00
// Because this is an inline wizard, this title and description should be put into the page. Specifying them here causes the wizard component to make a header that would be used on a modal.
// title={t("addLdapWizardTitle")}
// description={helpText("addLdapWizardDescription")}
2020-12-15 22:50:09 +00:00
height = "100%"
steps = { steps }
footer = { footer }
/ >
) ;
} ;