import initMatrix from '../../../client/initMatrix';
import cons from '../../../client/state/cons';
import colorMXID from '../../../util/colorMXID';
-import logout from '../../../client/action/logout';
import {
selectTab, openInviteList, openSearch, openSettings,
} from '../../../client/action/navigation';
import ScrollView from '../../atoms/scroll/ScrollView';
import SidebarAvatar from '../../molecules/sidebar-avatar/SidebarAvatar';
-import ContextMenu, { MenuItem, MenuHeader, MenuBorder } from '../../atoms/context-menu/ContextMenu';
import HomeIC from '../../../../public/res/ic/outlined/home.svg';
import UserIC from '../../../../public/res/ic/outlined/user.svg';
import SearchIC from '../../../../public/res/ic/outlined/search.svg';
import InviteIC from '../../../../public/res/ic/outlined/invite.svg';
-import SettingsIC from '../../../../public/res/ic/outlined/settings.svg';
-import PowerIC from '../../../../public/res/ic/outlined/power.svg';
function ProfileAvatarMenu() {
const mx = initMatrix.matrixClient;
}, []);
return (
- <ContextMenu
- content={(hideMenu) => (
- <>
- <MenuHeader>{mx.getUserId()}</MenuHeader>
- {/* <MenuItem iconSrc={UserIC} onClick={() => ''}>Profile</MenuItem> */}
- {/* <MenuItem iconSrc={BellIC} onClick={() => ''}>Notification settings</MenuItem> */}
- <MenuItem
- iconSrc={SettingsIC}
- onClick={() => { hideMenu(); openSettings(); }}
- >
- Settings
- </MenuItem>
- <MenuBorder />
- <MenuItem iconSrc={PowerIC} variant="danger" onClick={logout}>Logout</MenuItem>
- </>
- )}
- render={(toggleMenu) => (
- <SidebarAvatar
- onClick={toggleMenu}
- tooltip={profile.displayName}
- imageSrc={profile.avatarUrl !== null ? mx.mxcUrlToHttp(profile.avatarUrl, 42, 42, 'crop') : null}
- bgColor={colorMXID(mx.getUserId())}
- text={profile.displayName}
- />
- )}
+ <SidebarAvatar
+ onClick={openSettings}
+ tooltip={profile.displayName}
+ imageSrc={profile.avatarUrl !== null ? mx.mxcUrlToHttp(profile.avatarUrl, 42, 42, 'crop') : null}
+ bgColor={colorMXID(mx.getUserId())}
+ text={profile.displayName}
/>
);
}
import cons from '../../../client/state/cons';
import settings from '../../../client/state/settings';
import { toggleMarkdown, toggleMembershipEvents, toggleNickAvatarEvents } from '../../../client/action/settings';
+import logout from '../../../client/action/logout';
import Text from '../../atoms/text/Text';
import IconButton from '../../atoms/button/IconButton';
import SunIC from '../../../../public/res/ic/outlined/sun.svg';
import LockIC from '../../../../public/res/ic/outlined/lock.svg';
import InfoIC from '../../../../public/res/ic/outlined/info.svg';
+import PowerIC from '../../../../public/res/ic/outlined/power.svg';
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
import CinnySVG from '../../../../public/res/svg/cinny.svg';
}];
const [selectedSection, setSelectedSection] = useState(settingSections[0]);
+ const handleLogout = () => {
+ if (confirm('Confirm logout')) logout();
+ };
+
return (
<PopupWindow
className="settings-window"
onRequestClose={onRequestClose}
title="Settings"
contentTitle={selectedSection.name}
- drawer={
- settingSections.map((section) => (
+ drawer={(
+ <>
+ {
+ settingSections.map((section) => (
+ <PWContentSelector
+ key={section.name}
+ selected={selectedSection.name === section.name}
+ onClick={() => setSelectedSection(section)}
+ iconSrc={section.iconSrc}
+ >
+ {section.name}
+ </PWContentSelector>
+ ))
+ }
<PWContentSelector
- key={section.name}
- selected={selectedSection.name === section.name}
- onClick={() => setSelectedSection(section)}
- iconSrc={section.iconSrc}
+ variant="danger"
+ onClick={handleLogout}
+ iconSrc={PowerIC}
>
- {section.name}
+ Logout
</PWContentSelector>
- ))
- }
+ </>
+ )}
contentOptions={<IconButton src={CrossIC} onClick={onRequestClose} tooltip="Close" />}
>
{selectedSection.render()}