mattermost-mobile/app/screens/edit_profile/index.ts
Guillermo Vayá 0addf49021
[MM-62701] [MM-62176]Edit custom profile attributes in user profile (#8557)
* feat: Add support for custom profile attributes in edit profile form

feat: Add support for custom profile attributes in edit profile

refactor: Normalize whitespace in CustomAttribute type definition

fix: Resolve type mismatch for customAttributes in UserInfo interface

test: Add test for udpateCustomProfileAttributeValues method

fix typing, submit changes to server

missing files

test: Add tests for CustomProfileField component

fix naming

fix imports

fix

feat: Add field_refs hook for managing field references

feat: Make `setRef` ref parameter optional with default no-op implementation

refactor: Replace CustomProfileField with useFieldRefs for profile form

refactor: Optimize edit profile screen imports and custom attributes handling

refactor: Move custom attributes logic to remote actions in user.ts

address PR reviews

test: Add tests for custom attributes in edit profile

test: Add tests for EditProfile component with custom attributes

fix: Add UserModel type assertion to currentUser in edit profile tests

test: Add tests for ProfileForm custom attributes functionality

test: Add comprehensive tests for useFieldRefs hook

test: Add tests for fetchCustomAttributes and updateCustomAttributes

add tests

remove unneeded files

review changes

remove counter from hook

remove package.resolved

create interface for reuse of record

* fix signature type
2025-02-19 15:51:59 +01:00

45 lines
2.4 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
import {of as of$, combineLatest} from 'rxjs';
import {switchMap} from 'rxjs/operators';
import {observeConfigBooleanValue} from '@queries/servers/system';
import {observeCurrentUser} from '@queries/servers/user';
import EditProfile from './edit_profile';
import type {WithDatabaseArgs} from '@typings/database/database';
const enhanced = withObservables([], ({database}: WithDatabaseArgs) => {
const ldapFirstNameAttributeSet = observeConfigBooleanValue(database, 'LdapFirstNameAttributeSet');
const ldapLastNameAttributeSet = observeConfigBooleanValue(database, 'LdapLastNameAttributeSet');
const ldapNicknameAttributeSet = observeConfigBooleanValue(database, 'LdapNicknameAttributeSet');
const ldapPositionAttributeSet = observeConfigBooleanValue(database, 'LdapPositionAttributeSet');
const samlFirstNameAttributeSet = observeConfigBooleanValue(database, 'SamlFirstNameAttributeSet');
const samlLastNameAttributeSet = observeConfigBooleanValue(database, 'SamlLastNameAttributeSet');
const samlNicknameAttributeSet = observeConfigBooleanValue(database, 'SamlNicknameAttributeSet');
const samlPositionAttributeSet = observeConfigBooleanValue(database, 'SamlPositionAttributeSet');
return {
currentUser: observeCurrentUser(database),
lockedFirstName: combineLatest([ldapFirstNameAttributeSet, samlFirstNameAttributeSet]).pipe(
switchMap(([ldap, saml]) => of$(ldap || saml)),
),
lockedLastName: combineLatest([ldapLastNameAttributeSet, samlLastNameAttributeSet]).pipe(
switchMap(([ldap, saml]) => of$(ldap || saml)),
),
lockedNickname: combineLatest([ldapNicknameAttributeSet, samlNicknameAttributeSet]).pipe(
switchMap(([ldap, saml]) => of$(ldap || saml)),
),
lockedPosition: combineLatest([ldapPositionAttributeSet, samlPositionAttributeSet]).pipe(
switchMap(([ldap, saml]) => of$(ldap || saml)),
),
lockedPicture: observeConfigBooleanValue(database, 'LdapPictureAttributeSet'),
enableCustomAttributes: observeConfigBooleanValue(database, 'FeatureFlagCustomProfileAttributes'),
};
});
export default withDatabase(enhanced(EditProfile));