Skip to content

Commit c0134e5

Browse files
feat(a11y): inline errors ChangePassword (#6489)
* feat: removed changePassword input and added a button * feat: created ChangePasswordView * chore: remove unused ProfileView * feat: onSetNewPassword * fix: passwordView error * fix: tests e2e * chore: remove action sheet content * fix: onboarding test * fix: e2e tests * fix: title color * action: organized translations * fix: background and password policies * fix: color and a11y experience * chore: format code with Prettier [skip ci] * fix: lint * fix: conflicts * chore: code improvements * fix: code improvements * fix: code improvements * chore: code improvements * fix: password validation * feat: translation * fix: lint --------- Co-authored-by: OtavioStasiak <[email protected]>
1 parent 064e3aa commit c0134e5

File tree

40 files changed

+545
-111
lines changed

40 files changed

+545
-111
lines changed

app/containers/ChangePasswordRequired.tsx

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,27 @@
1-
import React, { useState } from 'react';
1+
import React from 'react';
22
import { StyleSheet, Text, View } from 'react-native';
33
import { useDispatch } from 'react-redux';
4+
import { NavigationProp, NavigationState } from '@react-navigation/native';
45

5-
import { logout, setUser } from '../actions/login';
6+
import { logout } from '../actions/login';
67
import I18n from '../i18n';
7-
import { useSetting } from '../lib/hooks/useSetting';
8-
import { showErrorAlert } from '../lib/methods/helpers';
9-
import { Services } from '../lib/services';
108
import { useTheme } from '../theme';
119
import sharedStyles from '../views/Styles';
12-
import { useActionSheet } from './ActionSheet';
13-
import ActionSheetContentWithInputAndSubmit from './ActionSheet/ActionSheetContentWithInputAndSubmit';
1410
import Button from './Button';
1511
import { CustomIcon } from './CustomIcon';
1612

17-
export const ChangePasswordRequired = () => {
18-
const [loading, setLoading] = useState(false);
13+
interface IChangePasswordRequired {
14+
navigation: Omit<NavigationProp<any>, 'getState'> & {
15+
getState(): NavigationState | undefined;
16+
};
17+
}
18+
19+
export const ChangePasswordRequired = ({ navigation }: IChangePasswordRequired) => {
1920
const { colors } = useTheme();
2021
const dispatch = useDispatch();
21-
const { showActionSheet, hideActionSheet } = useActionSheet();
22-
23-
const requiresPasswordConfirmation = useSetting('Accounts_RequirePasswordConfirmation');
24-
const passwordPlaceholder = useSetting('Accounts_PasswordPlaceholder') as string;
25-
const passwordConfirmationPlaceholder = useSetting('Accounts_ConfirmPasswordPlaceholder') as string;
26-
27-
const changePassword = async (password: string) => {
28-
setLoading(true);
29-
try {
30-
await Services.setUserPassword(password);
31-
dispatch(setUser({ requirePasswordChange: false }));
32-
hideActionSheet();
33-
} catch (error: any) {
34-
showErrorAlert(error?.reason || error?.message, I18n.t('Oops'));
35-
}
36-
setLoading(false);
37-
};
3822

39-
const showActionSheetPassword = () => {
40-
const inputs = [{ placeholder: passwordPlaceholder || I18n.t('Password'), secureTextEntry: true, key: 'password' }];
41-
if (requiresPasswordConfirmation) {
42-
inputs.push({
43-
placeholder: passwordConfirmationPlaceholder || I18n.t('Confirm_your_password'),
44-
secureTextEntry: true,
45-
key: 'confirm-password'
46-
});
47-
}
48-
showActionSheet({
49-
children: (
50-
<ActionSheetContentWithInputAndSubmit
51-
title={I18n.t('Please_Enter_your_new_password')}
52-
testID='change-password-required-sheet'
53-
inputs={inputs}
54-
onSubmit={input => changePassword(input[0])}
55-
isDisabled={input => (loading || input[0] === '' || requiresPasswordConfirmation ? input[0] !== input[1] : false)}
56-
/>
57-
)
58-
});
23+
const handleChangePassword = () => {
24+
navigation.navigate('ProfileStackNavigator', { screen: 'ChangePasswordView', params: { fromProfileView: false } });
5925
};
6026

6127
return (
@@ -69,7 +35,7 @@ export const ChangePasswordRequired = () => {
6935
testID='change-password-required-button'
7036
title={I18n.t('Change_password')}
7137
type='primary'
72-
onPress={showActionSheetPassword}
38+
onPress={handleChangePassword}
7339
/>
7440
<Button
7541
testID='change-password-required-logout'

app/containers/PasswordPolicies/components/Tip.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ const Tip = ({ iconType, description }: ITipProps) => {
4141
}
4242

4343
return (
44-
<View style={styles.container}>
44+
<View accessible accessibilityLabel={`${accessibilityLabel}${description}`} style={styles.container}>
4545
<CustomIcon color={color} name={icon} size={16} />
46-
<Text style={{ ...styles.text, color }} accessible accessibilityLabel={`${accessibilityLabel}${description}`}>
47-
{description}
48-
</Text>
46+
<Text style={{ ...styles.text, color }}>{description}</Text>
4947
</View>
5048
);
5149
};

app/containers/PasswordPolicies/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const PasswordPolicies = ({ isDirty, password, policies }: IPasswordTips) => {
3232
};
3333

3434
return (
35-
<View accessible>
35+
<View>
3636
<Text
3737
accessibilityLabel={i18n.t('Your_Password_Must_Have')}
3838
accessible

app/containers/TextInput/FormTextInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface IRCTextInputProps extends TextInputProps {
7070
label?: string;
7171
required?: boolean;
7272
error?: any;
73+
showErrorMessage?: boolean;
7374
loading?: boolean;
7475
containerStyle?: StyleProp<ViewStyle>;
7576
inputStyle?: StyleProp<TextStyle>;
@@ -79,7 +80,6 @@ export interface IRCTextInputProps extends TextInputProps {
7980
left?: JSX.Element;
8081
bottomSheet?: boolean;
8182
onClearInput?: () => void;
82-
showErrorMessage?: boolean;
8383
}
8484

8585
const getInputError = (error: unknown): string => {

app/i18n/locales/ar.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"Certificate_password": "الرقم السري للشهادة",
6868
"Change_Language": "تغيير اللغة",
6969
"Change_language_loading": "تغيير اللغة",
70+
"Change_my_password": "غير كلمة المرور الخاصة بي",
7071
"changing_avatar": "تغيير الصورة الرمزية",
7172
"Channel_hint_private": "لا يمكن للناس الانضمام إلا من خلال دعوتهم",
7273
"Channel_Name": "اسم القناة",
@@ -117,6 +118,7 @@
117118
"Created_snippet": "إنشاء مقتطف",
118119
"creating_channel": "إنشاء قناة",
119120
"creating_invite": "إنشاء دعوة",
121+
"Current_password": "كلمة المرور الحالية",
120122
"Current_Status": "الحالة الحالية",
121123
"Custom": "مخصص",
122124
"Dark": "داكن",
@@ -490,6 +492,7 @@
490492
"Sending_to": "يتم الإرسال إلى",
491493
"Server": "سرفر",
492494
"Server_version": "سرفر: {{version}}",
495+
"Set_new_password": "تعيين كلمة مرور جديدة",
493496
"Set_username_subtitle": "يتم استخدام اسم المستخدم للسماح للآخرين بذكرك في الرسائل",
494497
"Settings": "الإعدادات",
495498
"Settings_succesfully_changed": "تم تعديل الإعدادات بنجاح!",

app/i18n/locales/bn-IN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
"Certificate_password": "সার্টিফিকেট পাসওয়ার্ড",
106106
"Change_Language": "ভাষা পরিবর্তন",
107107
"Change_language_loading": "ভাষা পরিবর্তন করা হচ্ছে।",
108+
"Change_my_password": "আমার পাসওয়ার্ড পরিবর্তন করুন।",
108109
"changed_room_announcement": "রুম ঘোষণা পরিবর্তন করেছে: {{announcement}}",
109110
"changed_room_description": "রুম বিবরণ পরিবর্তন করেছে: {{description}}",
110111
"changing_avatar": "অবতার পরিবর্তন হচ্ছে",
@@ -182,6 +183,7 @@
182183
"creating_discussion": "আলোচনা তৈরি হচ্ছে",
183184
"creating_invite": "ইনভাইট তৈরি হচ্ছে",
184185
"creating_team": "দল তৈরি হচ্ছে",
186+
"Current_password": "বর্তমান পাসওয়ার্ড",
185187
"Current_Status": "বর্তমান অবস্থা",
186188
"Custom": "কাস্টম",
187189
"Dark": "অন্ধকার",
@@ -700,6 +702,7 @@
700702
"Sending_to": "পাঠাচ্ছি",
701703
"Server": "ওয়ার্কস্পেস",
702704
"Server_version": "ওয়ার্কস্পেস: {{version}}",
705+
"Set_new_password": "নতুন পাসওয়ার্ড সেট করুন",
703706
"Set_username_subtitle": "ব্যবহারকারীর নামটি আপনাকে বার্তাগুলিতে উল্লেখ করতে অনুমতি দেওয়ার জন্য ব্যবহৃত হয়",
704707
"Settings": "সেটিংস",
705708
"Settings_succesfully_changed": "সেটিংস সফলভাবে পরিবর্তন হয়েছে!",

app/i18n/locales/cs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"Certificate_password": "Heslo k certifikátu",
112112
"Change_Language": "Změnit jazyk",
113113
"Change_language_loading": "Změna jazyka.",
114+
"Change_my_password": "Změnit moje heslo",
114115
"changed_room_announcement": "změnilo oznámení místnosti na: {{announcement}}",
115116
"changed_room_description": "změnil popis pokoje na: {{description}}",
116117
"changing_avatar": "měnící se avatar",
@@ -192,6 +193,7 @@
192193
"creating_discussion": "vytvoření diskuse",
193194
"creating_invite": "vytváření pozvánky",
194195
"creating_team": "vytváření týmu",
196+
"Current_password": "Aktuální heslo",
195197
"Current_Status": "Aktuální stav",
196198
"Custom": "Vlastní",
197199
"Custom_push_gateway_connected_description": "Váš pracovní prostor používá vlastní bránu pro oznámení push. Případné problémy si ověřte u správce pracovního prostoru.",
@@ -748,6 +750,7 @@
748750
"Sending_to": "Odesílání do",
749751
"Server": "Pracovní prostor",
750752
"Server_version": "Pracovní prostor: {{version}}",
753+
"Set_new_password": "Nastavit nové heslo",
751754
"Set_username_subtitle": "Uživatelské jméno se používá k tomu, aby se o vás ostatní mohli zmínit ve zprávách",
752755
"Settings": "Nastavení",
753756
"Settings_succesfully_changed": "Nastavení úspěšně změněno!",

app/i18n/locales/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"Certificate_password": "Zertifikats-Passwort",
101101
"Change_Language": "Sprache ändern",
102102
"Change_language_loading": "Ändere Sprache.",
103+
"Change_my_password": "Ändere mein Passwort",
103104
"changed_room_announcement": "hat die Ankündigung des Raumes geändert zu: {{announcement}}",
104105
"changed_room_description": "hat die Raumbeschreibung geändert zu: {{description}}",
105106
"changing_avatar": "Avatar wechseln",
@@ -176,6 +177,7 @@
176177
"creating_discussion": "Erzeuge Diskussion",
177178
"creating_invite": "Einladung erstellen",
178179
"creating_team": "Team erstellen",
180+
"Current_password": "Aktuelles Passwort",
179181
"Current_Status": "Aktueller Status",
180182
"Custom": "Benutzerdefiniert",
181183
"Dark": "Dunkel",
@@ -686,6 +688,7 @@
686688
"Sending_to": "Sende an",
687689
"Server": "Server",
688690
"Server_version": "Server: {{version}}",
691+
"Set_new_password": "Neues Passwort festlegen",
689692
"Set_username_subtitle": "Der Benutzername wird verwendet, damit andere Personen Sie in Nachrichten erwähnen können",
690693
"Settings": "Einstellungen",
691694
"Settings_succesfully_changed": "Einstellungen erfolgreich geändert!",

app/i18n/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"Certificate_password": "Certificate password",
112112
"Change_Language": "Change language",
113113
"Change_language_loading": "Changing language.",
114+
"Change_my_password": "Change my password",
114115
"Change_password": "Change password",
115116
"changed_room_announcement": "changed room announcement to: {{announcement}}",
116117
"changed_room_description": "changed room description to: {{description}}",
@@ -195,6 +196,7 @@
195196
"creating_discussion": "creating discussion",
196197
"creating_invite": "creating invite",
197198
"creating_team": "creating team",
199+
"Current_password": "Current password",
198200
"Current_Status": "Current Status",
199201
"Custom": "Custom",
200202
"Custom_push_gateway_connected_description": "Your workspace uses a custom push notification gateway. Check with your workspace administrator for any issues.",
@@ -777,6 +779,7 @@
777779
"Sending_to": "Sending to",
778780
"Server": "Workspace",
779781
"Server_version": "Workspace: {{version}}",
782+
"Set_new_password": "Set new password",
780783
"Set_username_subtitle": "The username is used to allow others to mention you in messages",
781784
"Settings": "Settings",
782785
"Settings_succesfully_changed": "Settings succesfully changed!",

app/i18n/locales/es.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"Cancel_upload": "Cancelar carga",
6262
"Certificate_password": "Contraseña del certificado",
6363
"Change_Language": "Cambiar idioma",
64+
"Change_my_password": "Cambiar mi contraseña",
6465
"changing_avatar": "cambiando avatar",
6566
"Channel_hint_private": "La gente solo puede unirse al ser invitado",
6667
"Channel_Name": "Nombre sala",
@@ -97,6 +98,7 @@
9798
"Create_new_channel_team_dm_discussion": "Crear nuevo canal, equipo, mensaje directo o discusión.",
9899
"Created_snippet": "crear mensaje en bloque",
99100
"creating_channel": "creando channel",
101+
"Current_password": "Contraseña actual",
100102
"Current_Status": "Estado Actual",
101103
"Custom": "Personalizado",
102104
"Dark": "Oscuro",
@@ -335,6 +337,7 @@
335337
"Send_to": "Enviar a..",
336338
"Server": "Servidor",
337339
"Server_version": "Servidor: {{version}}",
340+
"Set_new_password": "Establecer nueva contraseña",
338341
"Set_username_subtitle": "El nombre de usuario se utiliza para permitir que otros le mencionen en los mensajes",
339342
"Settings": "Configuración",
340343
"Settings_succesfully_changed": "¡Configuración cambiada correctamente!",

0 commit comments

Comments
 (0)