From 7f11e25e63d9c3d62466bd966bcf4b9e2bcc77b7 Mon Sep 17 00:00:00 2001 From: VardanHakobyan Date: Mon, 7 Jun 2021 20:30:49 +0400 Subject: [PATCH] refactor: migrate `account-menu` to react - implement functionality - remove all Angular code related to `account-menu` - rename React component to AccountMenu so that many parts of old code remain unchanged - code cleanup --- app/assets/javascripts/app.ts | 6 +- .../{AccountMenuReact.tsx => AccountMenu.tsx} | 852 +++++++++--------- .../components/ConfirmSignoutModal.tsx | 8 +- .../components/NoAccountWarning.tsx | 1 - .../components/NoProtectionsNoteWarning.tsx | 1 - .../directives/views/accountMenu.ts | 608 ------------- .../javascripts/directives/views/index.ts | 1 - .../app_state/account_menu_react_state.ts | 33 - .../ui_models/app_state/app_state.ts | 8 +- .../views/editor_group/editor_group_view.ts | 2 +- .../javascripts/views/footer/footer-view.pug | 6 - .../javascripts/views/footer/footer_view.ts | 6 - app/assets/stylesheets/_footer.scss | 1 - .../templates/directives/account-menu.pug | 324 ------- 14 files changed, 430 insertions(+), 1427 deletions(-) rename app/assets/javascripts/components/{AccountMenuReact.tsx => AccountMenu.tsx} (53%) delete mode 100644 app/assets/javascripts/directives/views/accountMenu.ts delete mode 100644 app/assets/javascripts/ui_models/app_state/account_menu_react_state.ts delete mode 100644 app/assets/templates/directives/account-menu.pug diff --git a/app/assets/javascripts/app.ts b/app/assets/javascripts/app.ts index 38fd702e3..dd90872ca 100644 --- a/app/assets/javascripts/app.ts +++ b/app/assets/javascripts/app.ts @@ -34,7 +34,6 @@ import { } from './directives/functional'; import { - AccountMenu, ActionsMenu, ComponentModal, ComponentView, @@ -59,7 +58,7 @@ import { SessionsModalDirective } from './components/SessionsModal'; import { NoAccountWarningDirective } from './components/NoAccountWarning'; import { NoProtectionsdNoteWarningDirective } from './components/NoProtectionsNoteWarning'; import { SearchOptionsDirective } from './components/SearchOptions'; -import { AccountMenuReact } from './components/AccountMenuReact'; +import { AccountMenuDirective } from './components/AccountMenu'; import { ConfirmSignoutDirective } from './components/ConfirmSignoutModal'; import { MultipleSelectedNotesDirective } from './components/MultipleSelectedNotes'; import { NotesContextMenuDirective } from './components/NotesContextMenu'; @@ -137,7 +136,6 @@ const startApplication: StartApplication = async function startApplication( // Directives - Views angular .module('app') - .directive('accountMenu', () => new AccountMenu()) .directive('accountSwitcher', () => new AccountSwitcher()) .directive('actionsMenu', () => new ActionsMenu()) .directive('challengeModal', () => new ChallengeModal()) @@ -153,7 +151,7 @@ const startApplication: StartApplication = async function startApplication( .directive('historyMenu', () => new HistoryMenu()) .directive('syncResolutionMenu', () => new SyncResolutionMenu()) .directive('sessionsModal', SessionsModalDirective) - .directive('accountMenuReact', AccountMenuReact) + .directive('accountMenu', AccountMenuDirective) .directive('noAccountWarning', NoAccountWarningDirective) .directive('protectedNotePanel', NoProtectionsdNoteWarningDirective) .directive('searchOptions', SearchOptionsDirective) diff --git a/app/assets/javascripts/components/AccountMenuReact.tsx b/app/assets/javascripts/components/AccountMenu.tsx similarity index 53% rename from app/assets/javascripts/components/AccountMenuReact.tsx rename to app/assets/javascripts/components/AccountMenu.tsx index fa4537d6d..a7ff97322 100644 --- a/app/assets/javascripts/components/AccountMenuReact.tsx +++ b/app/assets/javascripts/components/AccountMenu.tsx @@ -32,6 +32,7 @@ import TargetedKeyboardEvent = JSXInternal.TargetedKeyboardEvent; import TargetedMouseEvent = JSXInternal.TargetedMouseEvent; import { alertDialog, confirmDialog } from '@Services/alertService'; import { RefObject } from 'react'; +import { ConfirmSignoutContainer } from '@/components/ConfirmSignoutModal'; type Props = { appState: AppState; @@ -367,7 +368,7 @@ const AccountMenu = observer(({ application, appState, closeAccountMenu }: Props }; const signOut = () => { - appState.accountMenuReact.setSigningOut(true); + appState.accountMenu.setSigningOut(true); }; const changePasscodePressed = () => { @@ -526,118 +527,109 @@ const AccountMenu = observer(({ application, appState, closeAccountMenu }: Props }, [refreshEncryptionStatus]); return ( -
-
-
-
-
Account
- Close -
-
- {!user && !showLogin && !showRegister && ( -
-
-
Sign in or register to enable sync and end-to-end encryption.
-
-
- - -
-
- Standard Notes is free on every platform, and comes - standard with sync and encryption. -
+
+
+
+
Account
+ Close +
+
+ {!user && !showLogin && !showRegister && ( +
+
+
Sign in or register to enable sync and end-to-end encryption.
- )} - {(showLogin || showRegister) && ( -
-
- {showLogin ? 'Sign In' : 'Register'} +
+ + +
+
+ Standard Notes is free on every platform, and comes + standard with sync and encryption. +
+
+ )} + {(showLogin || showRegister) && ( +
+
+ {showLogin ? 'Sign In' : 'Register'} +
+
+
+ + + {showRegister && + } + - -
- - - {showRegister && - } - - {showAdvanced && ( -
-
-
- Advanced Options -
-
- - -
- {showLogin && ( -