SSO LDAP - Address pending PR review comments (#92368)

* Address pending PR review comments

* Update i18n
This commit is contained in:
linoman 2024-08-23 16:35:00 +02:00 committed by GitHub
parent 494376c5a9
commit ca66133636
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 23 deletions

View File

@ -1,4 +1,5 @@
import { css } from '@emotion/css'; import { css } from '@emotion/css';
import { useId } from 'react';
import { useFormContext } from 'react-hook-form'; import { useFormContext } from 'react-hook-form';
import { GrafanaTheme2, SelectableValue } from '@grafana/data'; import { GrafanaTheme2, SelectableValue } from '@grafana/data';
@ -31,6 +32,12 @@ export const LdapDrawerComponent = ({ onClose }: Props) => {
const styles = useStyles2(getStyles); const styles = useStyles2(getStyles);
const { register, setValue, watch } = useFormContext<LdapPayload>(); const { register, setValue, watch } = useFormContext<LdapPayload>();
const nameId = useId();
const surnameId = useId();
const usernameId = useId();
const memberOfId = useId();
const emailId = useId();
const groupMappingsLabel = ( const groupMappingsLabel = (
<Label <Label
className={styles.sectionLabel} className={styles.sectionLabel}
@ -52,7 +59,7 @@ export const LdapDrawerComponent = ({ onClose }: Props) => {
); );
return ( return (
<Drawer title={t('ldap-drawer.title', 'Advanced Settings')} onClose={onClose}> <Drawer title={t('ldap-drawer.title', 'Advanced settings')} onClose={onClose}>
<CollapsableSection label={t('ldap-drawer.misc-section.label', 'Misc')} isOpen={true}> <CollapsableSection label={t('ldap-drawer.misc-section.label', 'Misc')} isOpen={true}>
<Field <Field
label={t('ldap-drawer.misc-section.allow-sign-up.label', 'Allow sign up')} label={t('ldap-drawer.misc-section.allow-sign-up.label', 'Allow sign up')}
@ -72,7 +79,7 @@ export const LdapDrawerComponent = ({ onClose }: Props) => {
> >
<Input <Input
id="port" id="port"
placeholder={t('ldap-drawer.misc-section.port.placeholder', '389')} placeholder="389"
type="number" type="number"
{...register('settings.config.servers.0.port', { valueAsNumber: true })} {...register('settings.config.servers.0.port', { valueAsNumber: true })}
/> />
@ -86,7 +93,7 @@ export const LdapDrawerComponent = ({ onClose }: Props) => {
> >
<Input <Input
id="timeout" id="timeout"
placeholder={t('ldap-drawer.misc-section.timeout.placeholder', '389')} placeholder="10"
type="number" type="number"
{...register('settings.config.servers.0.timeout', { valueAsNumber: true })} {...register('settings.config.servers.0.timeout', { valueAsNumber: true })}
/> />
@ -99,20 +106,20 @@ export const LdapDrawerComponent = ({ onClose }: Props) => {
the application correctly retrieves and displays user information. the application correctly retrieves and displays user information.
</Trans> </Trans>
</Text> </Text>
<Field htmlFor="name" label={t('ldap-drawer.attributes-section.name.label', 'Name')}> <Field label={t('ldap-drawer.attributes-section.name.label', 'Name')}>
<Input id="name" {...register('settings.config.servers.0.attributes.name')} /> <Input id={nameId} {...register('settings.config.servers.0.attributes.name')} />
</Field> </Field>
<Field htmlFor="surname" label={t('ldap-drawer.attributes-section.surname.label', 'Surname')}> <Field label={t('ldap-drawer.attributes-section.surname.label', 'Surname')}>
<Input id="surname" {...register('settings.config.servers.0.attributes.surname')} /> <Input id={surnameId} {...register('settings.config.servers.0.attributes.surname')} />
</Field> </Field>
<Field htmlFor="username" label={t('ldap-drawer.attributes-section.username.label', 'Username')}> <Field label={t('ldap-drawer.attributes-section.username.label', 'Username')}>
<Input id="username" {...register('settings.config.servers.0.attributes.username')} /> <Input id={usernameId} {...register('settings.config.servers.0.attributes.username')} />
</Field> </Field>
<Field htmlFor="member-of" label={t('ldap-drawer.attributes-section.member-of.label', 'Member Of')}> <Field label={t('ldap-drawer.attributes-section.member-of.label', 'Member Of')}>
<Input id="member-of" {...register('settings.config.servers.0.attributes.member_of')} /> <Input id={memberOfId} {...register('settings.config.servers.0.attributes.member_of')} />
</Field> </Field>
<Field htmlFor="email" label={t('ldap-drawer.attributes-section.email.label', 'Email')}> <Field label={t('ldap-drawer.attributes-section.email.label', 'Email')}>
<Input id="email" {...register('settings.config.servers.0.attributes.email')} /> <Input id={emailId} {...register('settings.config.servers.0.attributes.email')} />
</Field> </Field>
</CollapsableSection> </CollapsableSection>
<CollapsableSection label={groupMappingsLabel} isOpen={true}> <CollapsableSection label={groupMappingsLabel} isOpen={true}>

View File

@ -1053,16 +1053,14 @@
"label": "Misc", "label": "Misc",
"port": { "port": {
"description": "Default port is 389 without SSL or 636 with SSL", "description": "Default port is 389 without SSL or 636 with SSL",
"label": "Port", "label": "Port"
"placeholder": "389"
}, },
"timeout": { "timeout": {
"description": "Timeout in seconds for the connection to the LDAP server", "description": "Timeout in seconds for the connection to the LDAP server",
"label": "Timeout", "label": "Timeout"
"placeholder": "389"
} }
}, },
"title": "Advanced Settings" "title": "Advanced settings"
}, },
"ldap-settings-page": { "ldap-settings-page": {
"advanced-settings-section": { "advanced-settings-section": {

View File

@ -1053,16 +1053,14 @@
"label": "Mįşč", "label": "Mįşč",
"port": { "port": {
"description": "Đęƒäūľŧ pőřŧ įş 389 ŵįŧĥőūŧ ŜŜĿ őř 636 ŵįŧĥ ŜŜĿ", "description": "Đęƒäūľŧ pőřŧ įş 389 ŵįŧĥőūŧ ŜŜĿ őř 636 ŵįŧĥ ŜŜĿ",
"label": "Pőřŧ", "label": "Pőřŧ"
"placeholder": "389"
}, },
"timeout": { "timeout": {
"description": "Ŧįmęőūŧ įʼn şęčőʼnđş ƒőř ŧĥę čőʼnʼnęčŧįőʼn ŧő ŧĥę ĿĐÅP şęřvęř", "description": "Ŧįmęőūŧ įʼn şęčőʼnđş ƒőř ŧĥę čőʼnʼnęčŧįőʼn ŧő ŧĥę ĿĐÅP şęřvęř",
"label": "Ŧįmęőūŧ", "label": "Ŧįmęőūŧ"
"placeholder": "389"
} }
}, },
"title": "Åđväʼnčęđ Ŝęŧŧįʼnģş" "title": "Åđväʼnčęđ şęŧŧįʼnģş"
}, },
"ldap-settings-page": { "ldap-settings-page": {
"advanced-settings-section": { "advanced-settings-section": {