feat(web): add role-based channel actions in chat info
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
addChatMember,
|
||||
banChatMember,
|
||||
createInviteLink,
|
||||
deleteChat,
|
||||
getChatAttachments,
|
||||
getMessages,
|
||||
getChatNotificationSettings,
|
||||
@@ -936,21 +937,45 @@ export function ChatInfoPanel({ chatId, open, onClose }: Props) {
|
||||
) : null}
|
||||
|
||||
{showMembersSection && (chat.type === "group" || chat.type === "channel") ? (
|
||||
<button
|
||||
className="w-full rounded bg-slate-700 px-3 py-2 text-sm"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await leaveChat(chatId);
|
||||
await loadChats();
|
||||
setActiveChatId(null);
|
||||
onClose();
|
||||
} catch {
|
||||
setError("Failed to leave chat");
|
||||
}
|
||||
}}
|
||||
>
|
||||
{chat.type === "channel" ? "Leave channel" : "Leave chat"}
|
||||
</button>
|
||||
<>
|
||||
{chat.type === "channel" && (myRoleNormalized === "owner" || myRoleNormalized === "admin") ? (
|
||||
<button
|
||||
className="mb-2 w-full rounded bg-red-500 px-3 py-2 text-sm font-semibold text-white hover:bg-red-400"
|
||||
onClick={async () => {
|
||||
const confirmed = window.confirm("Delete this channel for all subscribers?");
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteChat(chatId, true);
|
||||
await loadChats();
|
||||
setActiveChatId(null);
|
||||
onClose();
|
||||
} catch {
|
||||
setError("Failed to delete channel");
|
||||
}
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
Delete channel for all
|
||||
</button>
|
||||
) : null}
|
||||
<button
|
||||
className="w-full rounded bg-slate-700 px-3 py-2 text-sm"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await leaveChat(chatId);
|
||||
await loadChats();
|
||||
setActiveChatId(null);
|
||||
onClose();
|
||||
} catch {
|
||||
setError("Failed to leave chat");
|
||||
}
|
||||
}}
|
||||
>
|
||||
{chat.type === "channel" ? "Leave channel" : "Leave chat"}
|
||||
</button>
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
) : null}
|
||||
|
||||
Reference in New Issue
Block a user