feat: admin panel link for system message user

This commit is contained in:
Lea 2023-09-01 11:53:37 +02:00 committed by Paul Makles
parent fe63c6633f
commit d4e0f19f95

View file

@ -2,32 +2,29 @@ import { ChevronRight, Trash } from "@styled-icons/boxicons-regular";
import { Cog, UserVoice } from "@styled-icons/boxicons-solid"; import { Cog, UserVoice } from "@styled-icons/boxicons-solid";
import { isFirefox } from "react-device-detect"; import { isFirefox } from "react-device-detect";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import { import { Channel, Message, Server, User, API, Permission, UserPermission, Member } from "revolt.js";
Channel,
Message,
Server,
User,
API,
Permission,
UserPermission,
Member,
} from "revolt.js";
import {
ContextMenuWithData,
MenuItem, import { ContextMenuWithData, MenuItem, openContextMenu } from "preact-context-menu";
openContextMenu,
} from "preact-context-menu";
import { Text } from "preact-i18n"; import { Text } from "preact-i18n";
import { Column, IconButton, LineDivider } from "@revoltchat/ui"; import { Column, IconButton, LineDivider } from "@revoltchat/ui";
import { useApplicationState } from "../mobx/State"; import { useApplicationState } from "../mobx/State";
import { QueuedMessage } from "../mobx/stores/MessageQueue"; import { QueuedMessage } from "../mobx/stores/MessageQueue";
import { NotificationState } from "../mobx/stores/NotificationOptions"; import { NotificationState } from "../mobx/stores/NotificationOptions";
import CMNotifications from "./contextmenu/CMNotifications"; import CMNotifications from "./contextmenu/CMNotifications";
import Tooltip from "../components/common/Tooltip"; import Tooltip from "../components/common/Tooltip";
import UserStatus from "../components/common/user/UserStatus"; import UserStatus from "../components/common/user/UserStatus";
import { useSession } from "../controllers/client/ClientController"; import { useSession } from "../controllers/client/ClientController";
@ -36,6 +33,7 @@ import { modalController } from "../controllers/modals/ModalController";
import { internalEmit } from "./eventEmitter"; import { internalEmit } from "./eventEmitter";
import { getRenderer } from "./renderer/Singleton"; import { getRenderer } from "./renderer/Singleton";
interface ContextMenuData { interface ContextMenuData {
user?: string; user?: string;
server?: string; server?: string;
@ -53,6 +51,7 @@ interface ContextMenuData {
type Action = type Action =
| { action: "copy_id"; id: string } | { action: "copy_id"; id: string }
| { action: "admin"; id: string; type: "channel" | "message" | "user" } | { action: "admin"; id: string; type: "channel" | "message" | "user" }
| { action: "admin_system"; id: string }
| { action: "copy_message_link"; message: Message } | { action: "copy_message_link"; message: Message }
| { action: "copy_selection" } | { action: "copy_selection" }
| { action: "copy_text"; content: string } | { action: "copy_text"; content: string }
@ -140,6 +139,12 @@ export default function ContextMenus() {
"_blank", "_blank",
); );
break; break;
case "admin_system":
window.open(
`https://admin.revolt.chat/panel/inspect/user/${data.id}`,
"_blank",
);
break;
case "copy_message_link": case "copy_message_link":
{ {
let pathname = `/channel/${data.message.channel_id}/${data.message._id}`; let pathname = `/channel/${data.message.channel_id}/${data.message._id}`;
@ -505,6 +510,8 @@ export default function ContextMenus() {
<span style={{ color }}> <span style={{ color }}>
{locale === "admin" ? ( {locale === "admin" ? (
"Open in Admin Panel" "Open in Admin Panel"
) : locale === "admin_system" ? (
"Inspect user"
) : ( ) : (
<Text <Text
id={`app.context_menu.${ id={`app.context_menu.${
@ -1131,6 +1138,22 @@ export default function ContextMenus() {
}, },
"admin", "admin",
); );
switch (message?.system?.type) {
case "user_added":
case "user_remove":
case "user_joined":
case "user_left":
case "user_kicked":
case "user_banned":
generateAction(
{
action: "admin_system",
id: message.system.id,
},
"admin_system",
);
}
} }
generateAction( generateAction(
@ -1270,4 +1293,4 @@ export default function ContextMenus() {
<CMNotifications /> <CMNotifications />
</> </>
); );
} }