mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-09-13 12:11:30 +08:00
Add link to user admin page in messages dropdown for admin users
Fix potential undefined data user revert type change next-auth
This commit is contained in:
@@ -9,5 +9,6 @@
|
|||||||
"report_placeholder": "Why should this message be reviewed?",
|
"report_placeholder": "Why should this message be reviewed?",
|
||||||
"report_title": "Report",
|
"report_title": "Report",
|
||||||
"send_report": "Send",
|
"send_report": "Send",
|
||||||
"submit_labels": "Submit"
|
"submit_labels": "Submit",
|
||||||
|
"view_user": "View user"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ import {
|
|||||||
useDisclosure,
|
useDisclosure,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { boolean } from "boolean";
|
import { boolean } from "boolean";
|
||||||
import { ClipboardList, Flag, MessageSquare, MoreHorizontal } from "lucide-react";
|
import { ClipboardList, Edit, Flag, MessageSquare, MoreHorizontal } from "lucide-react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
import { useSession } from "next-auth/react";
|
||||||
import { useTranslation } from "next-i18next";
|
import { useTranslation } from "next-i18next";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { LabelMessagePopup } from "src/components/Messages/LabelPopup";
|
import { LabelMessagePopup } from "src/components/Messages/LabelPopup";
|
||||||
@@ -109,7 +110,7 @@ export function MessageTableEntry({ message, enabled, highlight }: MessageTableE
|
|||||||
userEmoji={emojiState.user_emojis}
|
userEmoji={emojiState.user_emojis}
|
||||||
onLabel={showLabelPopup}
|
onLabel={showLabelPopup}
|
||||||
onReport={showReportPopup}
|
onReport={showReportPopup}
|
||||||
messageId={message.id}
|
message={message}
|
||||||
/>
|
/>
|
||||||
<LabelMessagePopup messageId={message.id} show={labelPopupOpen} onClose={closeLabelPopup} />
|
<LabelMessagePopup messageId={message.id} show={labelPopupOpen} onClose={closeLabelPopup} />
|
||||||
<ReportPopup messageId={message.id} show={reportPopupOpen} onClose={closeReportPopup} />
|
<ReportPopup messageId={message.id} show={reportPopupOpen} onClose={closeReportPopup} />
|
||||||
@@ -142,16 +143,17 @@ const MessageActions = ({
|
|||||||
userEmoji,
|
userEmoji,
|
||||||
onLabel,
|
onLabel,
|
||||||
onReport,
|
onReport,
|
||||||
messageId,
|
message,
|
||||||
}: {
|
}: {
|
||||||
react: (emoji: string, state: boolean) => void;
|
react: (emoji: string, state: boolean) => void;
|
||||||
userEmoji: string[];
|
userEmoji: string[];
|
||||||
onLabel: () => void;
|
onLabel: () => void;
|
||||||
onReport: () => void;
|
onReport: () => void;
|
||||||
messageId: string;
|
message: Message;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation("message");
|
const { t } = useTranslation("message");
|
||||||
|
const { data } = useSession() || {};
|
||||||
|
const role = data?.user?.role;
|
||||||
return (
|
return (
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuButton>
|
<MenuButton>
|
||||||
@@ -173,9 +175,17 @@ const MessageActions = ({
|
|||||||
{t("report_action")}
|
{t("report_action")}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem as="a" href={`/messages/${messageId}`} target="_blank" icon={<MessageSquare />}>
|
<MenuItem as="a" href={`/messages/${message.id}`} target="_blank" icon={<MessageSquare />}>
|
||||||
{t("open_new_tab_action")}
|
{t("open_new_tab_action")}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
{role === "admin" && (
|
||||||
|
<>
|
||||||
|
<MenuDivider />
|
||||||
|
<MenuItem as="a" href={`/admin/manage_user/${message.user_id}`} target="_blank" icon={<Edit />}>
|
||||||
|
{t("view_user")}
|
||||||
|
</MenuItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export interface Message extends MessageEmojis {
|
|||||||
created_date: string; // iso date string
|
created_date: string; // iso date string
|
||||||
parent_id: string;
|
parent_id: string;
|
||||||
frontend_message_id?: string;
|
frontend_message_id?: string;
|
||||||
|
user_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Conversation {
|
export interface Conversation {
|
||||||
|
|||||||
Reference in New Issue
Block a user