Skip to content

Commit

Permalink
Refactor IpaTextInput component
Browse files Browse the repository at this point in the history
IpaTextInput used its name attr as aria-label. Use ariaLabel if
available, fallback to name otherwise.

Refactor usages to use ariaLabel.

Fixes: freeipa#189

Signed-off-by: Michal Polovka <[email protected]>
  • Loading branch information
miskopo committed May 17, 2024
1 parent f38a76f commit 7dc3fd2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/Form/IpaTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const IpaTextInput = (props: IPAParamDefinition) => {
value={convertToString(value)}
onChange={(_event, value) => onChange(value)}
type="text"
aria-label={props.name}
aria-label={props.ariaLabel !== undefined ? props.ariaLabel : props.name}
isRequired={required}
readOnlyVariant={readOnly ? "plain" : undefined}
/>
Expand Down
5 changes: 5 additions & 0 deletions src/components/HostsSections/HostSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const HostSettings = (props: PropsToHostSettings) => {
<FormGroup label="Class" fieldId="userclass">
<IpaTextInput
name={"userclass"}
ariaLabel={"User class"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="host"
Expand All @@ -130,6 +131,7 @@ const HostSettings = (props: PropsToHostSettings) => {
<FormGroup label="Locality" fieldId="l">
<IpaTextInput
name={"l"}
ariaLabel={"Locality"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="host"
Expand All @@ -139,6 +141,7 @@ const HostSettings = (props: PropsToHostSettings) => {
<FormGroup label="Location" fieldId="nshostlocation">
<IpaTextInput
name={"nshostlocation"}
ariaLabel={"Location"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="host"
Expand All @@ -148,6 +151,7 @@ const HostSettings = (props: PropsToHostSettings) => {
<FormGroup label="Platform" fieldId="nshardwareplatform">
<IpaTextInput
name={"nshardwareplatform"}
ariaLabel={"Platform"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="host"
Expand All @@ -157,6 +161,7 @@ const HostSettings = (props: PropsToHostSettings) => {
<FormGroup label="Operating system" fieldId="nsosversion">
<IpaTextInput
name={"nsosversion"}
ariaLabel={"Operating system"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="host"
Expand Down
7 changes: 7 additions & 0 deletions src/components/UsersSections/UsersAccountSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
<FormGroup label="User login" fieldId="uid">
<IpaTextInput
name={"uid"}
ariaLabel={"User login"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down Expand Up @@ -163,6 +164,7 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
<FormGroup label="UID" fieldId="uidnumber">
<IpaTextInput
name={"uidnumber"}
ariaLabel={"UID number"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -172,6 +174,7 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
<FormGroup label="GID" fieldId="gidnumber">
<IpaTextInput
name={"gidnumber"}
ariaLabel={"GID number"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down Expand Up @@ -205,6 +208,7 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
<FormGroup label="Login shell" fieldId="loginshell">
<IpaTextInput
name={"loginshell"}
ariaLabel={"Login shell"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -218,6 +222,7 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
<FormGroup label="Home directory" fieldId="homedirectory">
<IpaTextInput
name={"homedirectory"}
ariaLabel={"Home directory"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down Expand Up @@ -326,6 +331,7 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
>
<IpaTextInput
name={"ipatokenradiususername"}
ariaLabel={"Radius proxy username"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -349,6 +355,7 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
<FormGroup label="External IdP user identifier" fieldId="ipaidpsub">
<IpaTextInput
name={"ipaidpsub"}
ariaLabel={"External IdP user identifier"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down
3 changes: 3 additions & 0 deletions src/components/UsersSections/UsersAttributesSMB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const UsersAttributesSMB = (props: PropsToSmbServices) => {
>
<IpaTextInput
name={"ipantlogonscript"}
ariaLabel={"SMB logon script path"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -97,6 +98,7 @@ const UsersAttributesSMB = (props: PropsToSmbServices) => {
>
<IpaTextInput
name={"ipantprofilepath"}
ariaLabel={"SMB profile path"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -119,6 +121,7 @@ const UsersAttributesSMB = (props: PropsToSmbServices) => {
>
<IpaTextInput
name={"ipanthomedirectory"}
ariaLabel={"SMB home directory"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down
4 changes: 4 additions & 0 deletions src/components/UsersSections/UsersEmployeeInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const UsersEmployeeInfo = (props: PropsToEmployeeInfo) => {
<FormGroup label="Org. unit" fieldId="ou">
<IpaTextInput
name={"ou"}
ariaLabel={"Org. unit"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down Expand Up @@ -68,6 +69,7 @@ const UsersEmployeeInfo = (props: PropsToEmployeeInfo) => {
<FormGroup label="Employee number" fieldId="employeenumber">
<IpaTextInput
name={"employeenumber"}
ariaLabel={"Employee number"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -77,6 +79,7 @@ const UsersEmployeeInfo = (props: PropsToEmployeeInfo) => {
<FormGroup label="Employee type" fieldId="employeetype">
<IpaTextInput
name={"employeetype"}
ariaLabel={"Employee type"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -86,6 +89,7 @@ const UsersEmployeeInfo = (props: PropsToEmployeeInfo) => {
<FormGroup label="Preferred language" fieldId="preferredlanguage">
<IpaTextInput
name={"preferredlanguage"}
ariaLabel={"Preferred language"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down
6 changes: 6 additions & 0 deletions src/components/UsersSections/UsersIdentity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const UsersIdentity = (props: PropsToUsersIdentity) => {
const firstNameTextInput = (
<IpaTextInput
name={"givenname"}
ariaLabel={"Given name"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -35,6 +36,7 @@ const UsersIdentity = (props: PropsToUsersIdentity) => {
const lastNameTextInput = (
<IpaTextInput
name={"sn"}
ariaLabel={"Last name"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -46,6 +48,7 @@ const UsersIdentity = (props: PropsToUsersIdentity) => {
const fullNameTextInput = (
<IpaTextInput
name={"cn"}
ariaLabel={"Full name"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -57,6 +60,7 @@ const UsersIdentity = (props: PropsToUsersIdentity) => {
const jobTitleTextInput = (
<IpaTextInput
name={"title"}
ariaLabel={"Job title"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -68,6 +72,7 @@ const UsersIdentity = (props: PropsToUsersIdentity) => {
const gecosTextInput = (
<IpaTextInput
name={"gecos"}
ariaLabel={"GECOS"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -79,6 +84,7 @@ const UsersIdentity = (props: PropsToUsersIdentity) => {
const userClassTextInput = (
<IpaTextInput
name={"userclass"}
ariaLabel={"User Class"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down
4 changes: 4 additions & 0 deletions src/components/UsersSections/UsersMailingAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const UsersMailingAddress = (props: PropsToUsersMailingAddress) => {
<FormGroup label="Street address" fieldId="street">
<IpaTextInput
name={"street"}
ariaLabel={"Street address"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -37,6 +38,7 @@ const UsersMailingAddress = (props: PropsToUsersMailingAddress) => {
<FormGroup label="City" fieldId="l">
<IpaTextInput
name={"l"}
ariaLabel={"City"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -50,6 +52,7 @@ const UsersMailingAddress = (props: PropsToUsersMailingAddress) => {
<FormGroup label="State/province" fieldId="st">
<IpaTextInput
name={"st"}
ariaLabel={"State/province"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand All @@ -59,6 +62,7 @@ const UsersMailingAddress = (props: PropsToUsersMailingAddress) => {
<FormGroup label="ZIP" fieldId="postalcode">
<IpaTextInput
name={"postalcode"}
ariaLabel={"Postal code"}
ipaObject={ipaObject}
onChange={recordOnChange}
objectName="user"
Expand Down

0 comments on commit 7dc3fd2

Please sign in to comment.