mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-08 01:45:28 +00:00
feat(modal): add report success modal (also allows blocking user)
This commit is contained in:
2
external/lang
vendored
2
external/lang
vendored
Submodule external/lang updated: 98592389de...a8c7759645
@@ -42,6 +42,7 @@ import ModifyAccount from "./components/ModifyAccount";
|
|||||||
import OutOfDate from "./components/OutOfDate";
|
import OutOfDate from "./components/OutOfDate";
|
||||||
import PendingFriendRequests from "./components/PendingFriendRequests";
|
import PendingFriendRequests from "./components/PendingFriendRequests";
|
||||||
import ReportContent from "./components/Report";
|
import ReportContent from "./components/Report";
|
||||||
|
import ReportSuccess from "./components/ReportSuccess";
|
||||||
import ServerIdentity from "./components/ServerIdentity";
|
import ServerIdentity from "./components/ServerIdentity";
|
||||||
import ServerInfo from "./components/ServerInfo";
|
import ServerInfo from "./components/ServerInfo";
|
||||||
import ShowToken from "./components/ShowToken";
|
import ShowToken from "./components/ShowToken";
|
||||||
@@ -278,4 +279,5 @@ export const modalController = new ModalControllerExtended({
|
|||||||
user_picker: UserPicker,
|
user_picker: UserPicker,
|
||||||
user_profile: UserProfile,
|
user_profile: UserProfile,
|
||||||
report: ReportContent,
|
report: ReportContent,
|
||||||
|
report_success: ReportSuccess,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ModalForm, Row } from "@revoltchat/ui";
|
|||||||
import Message from "../../../components/common/messaging/Message";
|
import Message from "../../../components/common/messaging/Message";
|
||||||
import UserShort from "../../../components/common/user/UserShort";
|
import UserShort from "../../../components/common/user/UserShort";
|
||||||
import { useClient } from "../../client/ClientController";
|
import { useClient } from "../../client/ClientController";
|
||||||
|
import { modalController } from "../ModalController";
|
||||||
import { ModalProps } from "../types";
|
import { ModalProps } from "../types";
|
||||||
|
|
||||||
const CONTENT_REASONS: API.ContentReportReason[] = [
|
const CONTENT_REASONS: API.ContentReportReason[] = [
|
||||||
@@ -126,6 +127,16 @@ export default function ReportContent({
|
|||||||
},
|
},
|
||||||
additional_context,
|
additional_context,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modalController.push({
|
||||||
|
type: "report_success",
|
||||||
|
user:
|
||||||
|
target instanceof MessageInterface
|
||||||
|
? target.author
|
||||||
|
: target instanceof User
|
||||||
|
? target
|
||||||
|
: undefined,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
submit={{
|
submit={{
|
||||||
children: <Text id="app.special.modals.actions.report" />,
|
children: <Text id="app.special.modals.actions.report" />,
|
||||||
|
|||||||
65
src/controllers/modals/components/ReportSuccess.tsx
Normal file
65
src/controllers/modals/components/ReportSuccess.tsx
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
|
import { noopTrue } from "../../../lib/js";
|
||||||
|
|
||||||
|
import { ModalProps } from "../types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report success modal
|
||||||
|
*/
|
||||||
|
export default function ReportSuccess({
|
||||||
|
user,
|
||||||
|
...props
|
||||||
|
}: ModalProps<"report_success">) {
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
{...props}
|
||||||
|
title={<Text id="app.special.modals.report.reported" />}
|
||||||
|
description={
|
||||||
|
<>
|
||||||
|
<Text id="app.special.modals.report.thank_you" />
|
||||||
|
{user && (
|
||||||
|
<>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<Text id="app.special.modals.report.block_user" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
actions={
|
||||||
|
user
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
palette: "plain",
|
||||||
|
onClick: async () => {
|
||||||
|
user.blockUser();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
children: (
|
||||||
|
<Text id="app.special.modals.actions.block" />
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
palette: "plain-secondary",
|
||||||
|
onClick: noopTrue,
|
||||||
|
children: (
|
||||||
|
<Text id="app.special.modals.actions.dont_block" />
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
palette: "plain",
|
||||||
|
onClick: noopTrue,
|
||||||
|
children: (
|
||||||
|
<Text id="app.special.modals.actions.done" />
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -183,6 +183,10 @@ export type Modal = {
|
|||||||
type: "report";
|
type: "report";
|
||||||
target: Server | User | Message;
|
target: Server | User | Message;
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: "report_success";
|
||||||
|
user?: User;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export type ModalProps<T extends Modal["type"]> = Modal & { type: T } & {
|
export type ModalProps<T extends Modal["type"]> = Modal & { type: T } & {
|
||||||
|
|||||||
Reference in New Issue
Block a user