mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-28 18:00:59 -05:00
feat: add admin shortcuts for convenience
This commit is contained in:
parent
9bbc22b091
commit
8c183b530b
2 changed files with 38 additions and 6 deletions
|
@ -52,6 +52,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: "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 }
|
||||||
|
@ -133,6 +134,12 @@ export default function ContextMenus() {
|
||||||
case "copy_id":
|
case "copy_id":
|
||||||
modalController.writeText(data.id);
|
modalController.writeText(data.id);
|
||||||
break;
|
break;
|
||||||
|
case "admin":
|
||||||
|
window.open(
|
||||||
|
`https://admin.revolt.chat/panel/inspect/${data.type}/${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}`;
|
||||||
|
@ -496,11 +503,15 @@ export default function ContextMenus() {
|
||||||
elements.push(
|
elements.push(
|
||||||
<MenuItem data={action} disabled={disabled}>
|
<MenuItem data={action} disabled={disabled}>
|
||||||
<span style={{ color }}>
|
<span style={{ color }}>
|
||||||
|
{locale === "admin" ? (
|
||||||
|
"Open in Admin Panel"
|
||||||
|
) : (
|
||||||
<Text
|
<Text
|
||||||
id={`app.context_menu.${
|
id={`app.context_menu.${
|
||||||
locale ?? action.action
|
locale ?? action.action
|
||||||
}`}
|
}`}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
{tip && <div className="tip">{tip}</div>}
|
{tip && <div className="tip">{tip}</div>}
|
||||||
</MenuItem>,
|
</MenuItem>,
|
||||||
|
@ -1107,6 +1118,21 @@ export default function ContextMenus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hideIDButton) {
|
if (!hideIDButton) {
|
||||||
|
if (state.experiments.isEnabled("admin_beta")) {
|
||||||
|
generateAction(
|
||||||
|
{
|
||||||
|
action: "admin",
|
||||||
|
id,
|
||||||
|
type: cid
|
||||||
|
? "channel"
|
||||||
|
: message
|
||||||
|
? "message"
|
||||||
|
: "user",
|
||||||
|
},
|
||||||
|
"admin",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
generateAction(
|
generateAction(
|
||||||
{ action: "copy_id", id },
|
{ action: "copy_id", id },
|
||||||
cid
|
cid
|
||||||
|
|
|
@ -10,7 +10,7 @@ import Store from "../interfaces/Store";
|
||||||
/**
|
/**
|
||||||
* Union type of available experiments.
|
* Union type of available experiments.
|
||||||
*/
|
*/
|
||||||
export type Experiment = "dummy" | "offline_users" | "plugins";
|
export type Experiment = "dummy" | "offline_users" | "plugins" | "admin_beta";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently active experiments.
|
* Currently active experiments.
|
||||||
|
@ -19,6 +19,7 @@ export const AVAILABLE_EXPERIMENTS: Experiment[] = [
|
||||||
"dummy",
|
"dummy",
|
||||||
"offline_users",
|
"offline_users",
|
||||||
"plugins",
|
"plugins",
|
||||||
|
"admin_beta",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,6 +42,11 @@ export const EXPERIMENTS: {
|
||||||
description:
|
description:
|
||||||
"This will enable the experimental plugin API. Only touch this if you know what you're doing.",
|
"This will enable the experimental plugin API. Only touch this if you know what you're doing.",
|
||||||
},
|
},
|
||||||
|
admin_beta: {
|
||||||
|
title: "Admin Panel Shortcuts",
|
||||||
|
description:
|
||||||
|
"Adds context menu entries to quickly jump to Revolt Admin Panel. This is intended for use by the team.",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface Data {
|
export interface Data {
|
||||||
|
|
Loading…
Reference in a new issue