feat: context menus in contact list page
This commit is contained in:
@@ -18,8 +18,10 @@ export default function ContactContextMenu({
|
|||||||
copyEmail,
|
copyEmail,
|
||||||
canCopyEmail,
|
canCopyEmail,
|
||||||
startChat,
|
startChat,
|
||||||
|
canRemove,
|
||||||
canRemoveFromChannel,
|
canRemoveFromChannel,
|
||||||
removeFromChannel,
|
removeFromChannel,
|
||||||
|
removeUser,
|
||||||
} = useContactOperation({
|
} = useContactOperation({
|
||||||
uid,
|
uid,
|
||||||
cid,
|
cid,
|
||||||
@@ -56,6 +58,11 @@ export default function ContactContextMenu({
|
|||||||
title: "Remove From Channel",
|
title: "Remove From Channel",
|
||||||
handler: removeFromChannel,
|
handler: removeFromChannel,
|
||||||
},
|
},
|
||||||
|
canRemove && {
|
||||||
|
danger: true,
|
||||||
|
title: "Remove From Server",
|
||||||
|
handler: removeUser,
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ export default function ContextMenu({ items = [], hideMenu = null }) {
|
|||||||
}`}
|
}`}
|
||||||
key={title}
|
key={title}
|
||||||
onClick={(evt) => {
|
onClick={(evt) => {
|
||||||
|
evt.stopPropagation();
|
||||||
|
evt.preventDefault();
|
||||||
handler(evt);
|
handler(evt);
|
||||||
if (hideMenu) {
|
if (hideMenu) {
|
||||||
hideMenu();
|
hideMenu();
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export default function useContactOperation({ uid, cid }) {
|
|||||||
const canRemoveFromChannel =
|
const canRemoveFromChannel =
|
||||||
cid && !channel?.is_public && (isAdmin || channel?.owner == loginUid);
|
cid && !channel?.is_public && (isAdmin || channel?.owner == loginUid);
|
||||||
const canCall = loginUid != uid;
|
const canCall = loginUid != uid;
|
||||||
const canRemove = isAdmin && loginUid != uid;
|
const canRemove = isAdmin && loginUid != uid && !cid;
|
||||||
return {
|
return {
|
||||||
canRemove,
|
canRemove,
|
||||||
removeUser: handleRemove,
|
removeUser: handleRemove,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function ContactsPage() {
|
|||||||
{contactIds.map((uid) => {
|
{contactIds.map((uid) => {
|
||||||
return (
|
return (
|
||||||
<NavLink key={uid} className="session" to={`/contacts/${uid}`}>
|
<NavLink key={uid} className="session" to={`/contacts/${uid}`}>
|
||||||
<Contact uid={uid} />
|
<Contact uid={uid} enableContextMenu={true} />
|
||||||
</NavLink>
|
</NavLink>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in New Issue
Block a user