Open space options on right click pinned space icon
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
2bc21f13d4
commit
91d7d78621
2 changed files with 19 additions and 3 deletions
|
@ -12,7 +12,8 @@ import { blurOnBubbling } from '../../atoms/button/script';
|
||||||
|
|
||||||
const SidebarAvatar = React.forwardRef(({
|
const SidebarAvatar = React.forwardRef(({
|
||||||
tooltip, text, bgColor, imageSrc,
|
tooltip, text, bgColor, imageSrc,
|
||||||
iconSrc, active, onClick, isUnread, notificationCount, isAlert,
|
iconSrc, active, onClick, onContextMenu,
|
||||||
|
isUnread, notificationCount, isAlert,
|
||||||
}, ref) => {
|
}, ref) => {
|
||||||
let activeClass = '';
|
let activeClass = '';
|
||||||
if (active) activeClass = ' sidebar-avatar--active';
|
if (active) activeClass = ' sidebar-avatar--active';
|
||||||
|
@ -27,6 +28,7 @@ const SidebarAvatar = React.forwardRef(({
|
||||||
type="button"
|
type="button"
|
||||||
onMouseUp={(e) => blurOnBubbling(e, '.sidebar-avatar')}
|
onMouseUp={(e) => blurOnBubbling(e, '.sidebar-avatar')}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
onContextMenu={onContextMenu}
|
||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
text={text}
|
text={text}
|
||||||
|
@ -52,6 +54,7 @@ SidebarAvatar.defaultProps = {
|
||||||
imageSrc: null,
|
imageSrc: null,
|
||||||
active: false,
|
active: false,
|
||||||
onClick: null,
|
onClick: null,
|
||||||
|
onContextMenu: null,
|
||||||
isUnread: false,
|
isUnread: false,
|
||||||
notificationCount: 0,
|
notificationCount: 0,
|
||||||
isAlert: false,
|
isAlert: false,
|
||||||
|
@ -65,6 +68,7 @@ SidebarAvatar.propTypes = {
|
||||||
iconSrc: PropTypes.string,
|
iconSrc: PropTypes.string,
|
||||||
active: PropTypes.bool,
|
active: PropTypes.bool,
|
||||||
onClick: PropTypes.func,
|
onClick: PropTypes.func,
|
||||||
|
onContextMenu: PropTypes.func,
|
||||||
isUnread: PropTypes.bool,
|
isUnread: PropTypes.bool,
|
||||||
notificationCount: PropTypes.oneOfType([
|
notificationCount: PropTypes.oneOfType([
|
||||||
PropTypes.string,
|
PropTypes.string,
|
||||||
|
|
|
@ -5,12 +5,14 @@ import initMatrix from '../../../client/initMatrix';
|
||||||
import cons from '../../../client/state/cons';
|
import cons from '../../../client/state/cons';
|
||||||
import colorMXID from '../../../util/colorMXID';
|
import colorMXID from '../../../util/colorMXID';
|
||||||
import {
|
import {
|
||||||
selectTab, openInviteList, openSearch, openSettings,
|
selectTab, openInviteList, openSearch,
|
||||||
|
openSettings, openReusableContextMenu,
|
||||||
} from '../../../client/action/navigation';
|
} from '../../../client/action/navigation';
|
||||||
import { abbreviateNumber } from '../../../util/common';
|
import { abbreviateNumber, getEventCords } from '../../../util/common';
|
||||||
|
|
||||||
import ScrollView from '../../atoms/scroll/ScrollView';
|
import ScrollView from '../../atoms/scroll/ScrollView';
|
||||||
import SidebarAvatar from '../../molecules/sidebar-avatar/SidebarAvatar';
|
import SidebarAvatar from '../../molecules/sidebar-avatar/SidebarAvatar';
|
||||||
|
import SpaceOptions from '../../molecules/space-options/SpaceOptions';
|
||||||
|
|
||||||
import HomeIC from '../../../../public/res/ic/outlined/home.svg';
|
import HomeIC from '../../../../public/res/ic/outlined/home.svg';
|
||||||
import UserIC from '../../../../public/res/ic/outlined/user.svg';
|
import UserIC from '../../../../public/res/ic/outlined/user.svg';
|
||||||
|
@ -96,6 +98,15 @@ function SideBar() {
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const openSpaceOptions = (e, spaceId) => {
|
||||||
|
e.preventDefault();
|
||||||
|
openReusableContextMenu(
|
||||||
|
'right',
|
||||||
|
getEventCords(e, '.sidebar-avatar'),
|
||||||
|
(closeMenu) => <SpaceOptions roomId={spaceId} afterOptionSelect={closeMenu} />,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
function getHomeNoti() {
|
function getHomeNoti() {
|
||||||
const orphans = roomList.getOrphans();
|
const orphans = roomList.getOrphans();
|
||||||
let noti = null;
|
let noti = null;
|
||||||
|
@ -174,6 +185,7 @@ function SideBar() {
|
||||||
notificationCount={abbreviateNumber(notifications.getTotalNoti(sRoomId))}
|
notificationCount={abbreviateNumber(notifications.getTotalNoti(sRoomId))}
|
||||||
isAlert={notifications.getHighlightNoti(sRoomId) !== 0}
|
isAlert={notifications.getHighlightNoti(sRoomId) !== 0}
|
||||||
onClick={() => selectTab(shortcut)}
|
onClick={() => selectTab(shortcut)}
|
||||||
|
onContextMenu={(e) => openSpaceOptions(e, sRoomId)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue