diff --git a/src/components/UserSettings.tsx b/src/components/UserSettings.tsx
index a0cff31d..e78d5a2e 100644
--- a/src/components/UserSettings.tsx
+++ b/src/components/UserSettings.tsx
@@ -249,7 +249,12 @@ const UserSettings = (props: PropsToUserSettings) => {
id="account-settings"
text="Account settings"
/>
-
+
;
+ onUserChange: (element: Partial) => void;
+ metadata: Metadata;
+ onRefresh: () => void;
}
// Generic data to pass to the Textbox adder
@@ -38,32 +45,21 @@ interface ElementData {
}
const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
- // TODO: This state variables should update the user data via the IPA API (`user_mod`)
- const [userLogin] = useState(props.user.uid);
+ // TODO: Handle the `has_password` variable (boolean) by another Ipa component
const [password] = useState("");
- const [passwordExpiration] = useState("");
- const [uid, setUid] = useState(props.user.uidnumber);
- const [gid, setGid] = useState("");
+
+ // Get 'ipaObject' and 'recordOnChange' to use in 'IpaTextInput'
+ const { ipaObject, recordOnChange } = asRecord(
+ props.user,
+ props.onUserChange
+ );
+
const [principalAliasList, setPrincipalAliasList] = useState([
{
id: 0,
element: props.user.uid + "@IPAEXAMPLE.TEST",
},
]);
- const [homeDirectory, setHomeDirectory] = useState("/home/" + userLogin);
- const [loginShell, setLoginShell] = useState("/bin/sh");
- const [radiusUsername, setRadiusUsername] = useState("");
- const [idpIdentifier, setIdpIdentifier] = useState("");
-
- // UID
- const uidInputHandler = (value: string) => {
- setUid(value);
- };
-
- // GID
- const gidInputHandler = (value: string) => {
- setGid(value);
- };
// Principal alias
// - 'Add principal alias' handler
@@ -96,16 +92,6 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
setPrincipalAliasList(principalAliasListCopy);
};
- // Home directory
- const homeDirectoryInputHandler = (value: string) => {
- setHomeDirectory(value);
- };
-
- // Login shell
- const loginShellInputHandler = (value: string) => {
- setLoginShell(value);
- };
-
// SSH public keys
// -Text area
const [textAreaSshPublicKeysValue, setTextAreaSshPublicKeysValue] =
@@ -347,16 +333,6 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
,
];
- // RADIUS username
- const radiusUsernameInputHandler = (value: string) => {
- setRadiusUsername(value);
- };
-
- // Track changes on External IdP user identifier textbox field
- const idpIdentifierInputHandler = (value: string) => {
- setIdpIdentifier(value);
- };
-
// Checkboxes
const [passwordCheckbox] = useState(false);
const [radiusCheckbox] = useState(false);
@@ -503,13 +479,12 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
@@ -634,13 +605,12 @@ const UsersAccountSettings = (props: PropsToUsersAccountSettings) => {
diff --git a/src/hooks/useUserSettingsData.tsx b/src/hooks/useUserSettingsData.tsx
index 7247e478..1ae89e34 100644
--- a/src/hooks/useUserSettingsData.tsx
+++ b/src/hooks/useUserSettingsData.tsx
@@ -84,9 +84,17 @@ const useUserSettingsData = (userId: string): UserSettingsData => {
}
let modified = false;
for (const [key, value] of Object.entries(user)) {
- if (userFullData.user[key] !== value) {
- modified = true;
- break;
+ if (Array.isArray(value)) {
+ // Using 'JSON.stringify' when comparing arrays (to prevent data type false positives)
+ if (JSON.stringify(userFullData.user[key]) !== JSON.stringify(value)) {
+ modified = true;
+ break;
+ }
+ } else {
+ if (userFullData.user[key] !== value) {
+ modified = true;
+ break;
+ }
}
}
setModified(modified);