* refactor: menuRow directive to MenuRow component * refactor: migrate footer to react * refactor: migrate actions menu to react * refactor: migrate history menu to react * fix: click outside handler use capture to trigger event before re-render occurs which would otherwise cause node.contains to return incorrect result (specifically for the account menu) * refactor: migrate revision preview modal to react * refactor: migrate permissions modal to react * refactor: migrate password wizard to react * refactor: remove unused input modal directive * refactor: remove unused delay hide component * refactor: remove unused filechange directive * refactor: remove unused elemReady directive * refactor: remove unused sn-enter directive * refactor: remove unused lowercase directive * refactor: remove unused autofocus directive * refactor(wip): note view to react * refactor: use mutation observer to deinit textarea listeners * refactor: migrate challenge modal to react * refactor: migrate note group view to react * refactor(wip): migrate remaining classes * fix: navigation parent ref * refactor: fully remove angular assets * fix: account switcher * fix: application view state * refactor: remove unused password wizard type * fix: revision preview and permissions modal * fix: remove angular comment * refactor: react panel resizers for editor * feat: simple panel resizer * fix: use simple panel resizer everywhere * fix: simplify panel resizer state * chore: rename simple panel resizer to panel resizer * refactor: simplify column layout * fix: editor mount safety check * fix: use inline onLoad callback for iframe, as setting onload after it loads will never call it * chore: fix note view test * chore(deps): upgrade snjs
81 lines
2.5 KiB
TypeScript
81 lines
2.5 KiB
TypeScript
import {
|
|
PreferencesGroup,
|
|
PreferencesSegment,
|
|
Subtitle,
|
|
Text,
|
|
Title,
|
|
} from '@/preferences/components';
|
|
import { Button } from '@/components/Button';
|
|
import { WebApplication } from '@/ui_models/application';
|
|
import { observer } from '@node_modules/mobx-react-lite';
|
|
import { HorizontalSeparator } from '@/components/shared/HorizontalSeparator';
|
|
import { dateToLocalizedString } from '@standardnotes/snjs';
|
|
import { useCallback, useState } from 'preact/hooks';
|
|
import { ChangeEmail } from '@/preferences/panes/account/changeEmail';
|
|
import { FunctionComponent, render } from 'preact';
|
|
import { AppState } from '@/ui_models/app_state';
|
|
import { PasswordWizard } from '@/components/PasswordWizard';
|
|
|
|
type Props = {
|
|
application: WebApplication;
|
|
appState: AppState;
|
|
};
|
|
|
|
export const Credentials: FunctionComponent<Props> = observer(
|
|
({ application }: Props) => {
|
|
const [isChangeEmailDialogOpen, setIsChangeEmailDialogOpen] =
|
|
useState(false);
|
|
|
|
const user = application.getUser();
|
|
|
|
const passwordCreatedAtTimestamp =
|
|
application.getUserPasswordCreationDate() as Date;
|
|
const passwordCreatedOn = dateToLocalizedString(passwordCreatedAtTimestamp);
|
|
|
|
const presentPasswordWizard = useCallback(() => {
|
|
render(
|
|
<PasswordWizard application={application} />,
|
|
document.body.appendChild(document.createElement('div'))
|
|
);
|
|
}, [application]);
|
|
|
|
return (
|
|
<PreferencesGroup>
|
|
<PreferencesSegment>
|
|
<Title>Credentials</Title>
|
|
<Subtitle>Email</Subtitle>
|
|
<Text>
|
|
You're signed in as <span className="font-bold">{user?.email}</span>
|
|
</Text>
|
|
<Button
|
|
className="min-w-20 mt-3"
|
|
type="normal"
|
|
label="Change email"
|
|
onClick={() => {
|
|
setIsChangeEmailDialogOpen(true);
|
|
}}
|
|
/>
|
|
<HorizontalSeparator classes="mt-5 mb-3" />
|
|
<Subtitle>Password</Subtitle>
|
|
<Text>
|
|
Current password was set on{' '}
|
|
<span className="font-bold">{passwordCreatedOn}</span>
|
|
</Text>
|
|
<Button
|
|
className="min-w-20 mt-3"
|
|
type="normal"
|
|
label="Change password"
|
|
onClick={presentPasswordWizard}
|
|
/>
|
|
{isChangeEmailDialogOpen && (
|
|
<ChangeEmail
|
|
onCloseDialog={() => setIsChangeEmailDialogOpen(false)}
|
|
application={application}
|
|
/>
|
|
)}
|
|
</PreferencesSegment>
|
|
</PreferencesGroup>
|
|
);
|
|
}
|
|
);
|