Skip to content

Commit

Permalink
refactor: migrate account-menu to react - implement functionality
Browse files Browse the repository at this point in the history
- remove all Angular code related to `account-menu`
- rename React component to AccountMenu so that many parts of old code remain unchanged
- code cleanup
  • Loading branch information
vardan-arm committed Jun 7, 2021
1 parent 6db9743 commit 7f11e25
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 1,400 deletions.
6 changes: 2 additions & 4 deletions app/assets/javascripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
} from './directives/functional';

import {
AccountMenu,
ActionsMenu,
ComponentModal,
ComponentView,
Expand All @@ -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';
Expand Down Expand Up @@ -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())
Expand All @@ -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)
Expand Down

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions app/assets/javascripts/components/ConfirmSignoutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ type Props = {
appState: AppState;
};

const ConfirmSignoutContainer = observer((props: Props) => {
export const ConfirmSignoutContainer = observer((props: Props) => {
if (!props.appState.accountMenu.signingOut) {
return null;
}
if (!props.appState.accountMenuReact.signingOut) {
return null;
}
return <ConfirmSignoutModal {...props} />;
});

Expand All @@ -33,14 +30,13 @@ const ConfirmSignoutModal = observer(({ application, appState }: Props) => {
const cancelRef = useRef<HTMLButtonElement>();
function close() {
appState.accountMenu.setSigningOut(false);
appState.accountMenuReact.setSigningOut(false);
}

const [localBackupsCount, setLocalBackupsCount] = useState(0);

useEffect(() => {
application.bridge.localBackupsCount().then(setLocalBackupsCount);
}, [appState.accountMenu.signingOut, appState.accountMenuReact.signingOut, application.bridge]);
}, [appState.accountMenu.signingOut, application.bridge]);

return (
<AlertDialog onDismiss={close} leastDestructiveRef={cancelRef}>
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/components/NoAccountWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const NoAccountWarning = observer(({ appState }: Props) => {
onClick={(event) => {
event.stopPropagation();
appState.accountMenu.setShow(true);
appState.accountMenuReact.setShow(true);
}}
>
Open Account menu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function NoProtectionsNoteWarning({ appState, onViewNote }: Props) {
className="sn-button small info"
onClick={() => {
appState.accountMenu.setShow(true);
appState.accountMenuReact.setShow(true);
}}
>
Open account menu
Expand Down
Loading

0 comments on commit 7f11e25

Please sign in to comment.