Skip to content

Commit

Permalink
[IMPROVE] Rewrite Save Encryption Password Modal (#22447)
Browse files Browse the repository at this point in the history
* improve: rewrite modal

* fix: translation keys

* fix: review

* fix: lint

Co-authored-by: gabriellsh <[email protected]>
Co-authored-by: Tasso Evangelista <[email protected]>
  • Loading branch information
3 people authored Jul 6, 2021
1 parent 6357447 commit 22ffa7f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/e2e/client/EnterE2EPasswordModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const EnterE2EPasswordModal = ({
<GenericModal
variant='warning'
title={t('Enter_E2E_password')}
cancelText={t('I_ll_do_it_later')}
cancelText={t('Do_It_Later')}
confirmText={t('Decode_Key')}
onConfirm={handleConfirm}
onClose={onClose}
Expand Down
33 changes: 33 additions & 0 deletions app/e2e/client/SaveE2EPasswordModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Box } from '@rocket.chat/fuselage';
import React, { ReactElement } from 'react';

import GenericModal from '../../../client/components/GenericModal';
import { useTranslation } from '../../../client/contexts/TranslationContext';

const SaveE2EPasswordModal = ({
passwordRevealText,
onClose,
onCancel,
onConfirm,
}: {
passwordRevealText: string;
onClose: () => void;
onCancel: () => void;
onConfirm: () => void;
}): ReactElement => {
const t = useTranslation();

return (
<GenericModal
onClose={onClose}
onCancel={onCancel}
onConfirm={onConfirm}
cancelText={t('Do_It_Later')}
confirmText={t('I_Saved_My_Password')}
variant='warning'
title={t('Save_Your_Encryption_Password')}
><Box dangerouslySetInnerHTML={{ __html: passwordRevealText }} /></GenericModal>
);
};

export default SaveE2EPasswordModal;
33 changes: 17 additions & 16 deletions app/e2e/client/rocketchat.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import {
} from './helper';
import * as banners from '../../../client/lib/banners';
import { Rooms, Subscriptions, Messages } from '../../models';
import { call, modal } from '../../ui-utils';
import { call } from '../../ui-utils';
import './events.js';
import './tabbar';
import { log, logError } from './logger';
import { waitUntilFind } from './waitUntilFind';
import { imperativeModal } from '../../../client/lib/imperativeModal';
import SaveE2EPasswordModal from './SaveE2EPasswordModal';
import EnterE2EPasswordModal from './EnterE2EPasswordModal';

let failedToDecodeKey = false;
Expand Down Expand Up @@ -147,26 +148,26 @@ class E2E extends Emitter {
});

this.openAlert({
title: TAPi18n.__('Save_your_encryption_password'),
title: TAPi18n.__('Save_Your_Encryption_Password'),
html: TAPi18n.__('Click_here_to_view_and_copy_your_password'),
modifiers: ['large'],
closable: false,
icon: 'key',
action: () => {
modal.open({
title: TAPi18n.__('Save_your_encryption_password'),
html: true,
text: `<div>${ passwordRevealText }</div>`,
showConfirmButton: true,
showCancelButton: true,
confirmButtonText: TAPi18n.__('I_saved_my_password_close_this_message'),
cancelButtonText: TAPi18n.__('I_ll_do_it_later'),
}, (confirm) => {
if (!confirm) {
return;
}
Meteor._localStorage.removeItem('e2e.randomPassword');
this.closeAlert();
imperativeModal.open({ component: SaveE2EPasswordModal,
props: {
passwordRevealText,
onClose: imperativeModal.close,
onCancel: () => {
this.closeAlert();
imperativeModal.close();
},
onConfirm: () => {
Meteor._localStorage.removeItem('e2e.randomPassword');
this.closeAlert();
imperativeModal.close();
},
},
});
},
});
Expand Down
6 changes: 3 additions & 3 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,7 @@
"Display_setting_permissions": "Display permissions to change settings",
"Display_unread_counter": "Display number of unread messages",
"Displays_action_text": "Displays action text",
"Do_It_Later": "Do It Later",
"Do_not_display_unread_counter": "Do not display any counter of this channel",
"Do_not_provide_this_code_to_anyone": "Do not provide this code to anyone.",
"Do_Nothing": "Do Nothing",
Expand Down Expand Up @@ -2048,8 +2049,7 @@
"How_responsive_was_the_chat_agent": "How responsive was the chat agent?",
"How_satisfied_were_you_with_this_chat": "How satisfied were you with this chat?",
"How_to_handle_open_sessions_when_agent_goes_offline": "How to Handle Open Sessions When Agent Goes Offline",
"I_ll_do_it_later": "I'll do it later",
"I_saved_my_password_close_this_message": "I saved my password, close this message",
"I_Saved_My_Password": "I Saved My Password",
"Idle_Time_Limit": "Idle Time Limit",
"Idle_Time_Limit_Description": "Period of time until status changes to away. Value needs to be in seconds.",
"if_they_are_from": "(if they are from %s)",
Expand Down Expand Up @@ -3574,7 +3574,7 @@
"Save_Mobile_Bandwidth": "Save Mobile Bandwidth",
"Save_to_enable_this_action": "Save to enable this action",
"Save_To_Webdav": "Save to WebDAV",
"Save_your_encryption_password": "Save your encryption password",
"Save_Your_Encryption_Password": "Save Your Encryption Password",
"save-others-livechat-room-info": "Save Others Omnichannel Room Info",
"save-others-livechat-room-info_description": "Permission to save information from other omnichannel rooms",
"Saved": "Saved",
Expand Down

0 comments on commit 22ffa7f

Please sign in to comment.