forked from abner/for-legacy-web
fix: remove ability for owners to leave server from ServerInfo modal (#1070)
Co-authored-by: Declan Chidlow <git.rh92c@8shield.net>mentioneverything
parent
ac2beaf549
commit
97a6c7d399
|
|
@ -5,6 +5,7 @@ import { Text } from "preact-i18n";
|
|||
import { Column, H1, IconButton, Modal, Row } from "@revoltchat/ui";
|
||||
|
||||
import Markdown from "../../../components/markdown/Markdown";
|
||||
import { useClient } from "../../client/ClientController";
|
||||
import { report } from "../../safety";
|
||||
import { modalController } from "../ModalController";
|
||||
import { ModalProps } from "../types";
|
||||
|
|
@ -13,6 +14,49 @@ export default function ServerInfo({
|
|||
server,
|
||||
...props
|
||||
}: ModalProps<"server_info">) {
|
||||
const client = useClient();
|
||||
const isOwner = server.owner === client.user?._id;
|
||||
|
||||
const actions = [
|
||||
{
|
||||
onClick: () => {
|
||||
modalController.push({
|
||||
type: "server_identity",
|
||||
member: server.member!,
|
||||
});
|
||||
return true;
|
||||
},
|
||||
children: "Edit Identity",
|
||||
palette: "primary",
|
||||
},
|
||||
];
|
||||
|
||||
if (!isOwner) {
|
||||
actions.push({
|
||||
onClick: () => {
|
||||
modalController.push({
|
||||
type: "leave_server",
|
||||
target: server,
|
||||
});
|
||||
return true;
|
||||
},
|
||||
children: "Leave Server",
|
||||
palette: "error",
|
||||
});
|
||||
}
|
||||
|
||||
actions.push({
|
||||
onClick: () => {
|
||||
modalController.push({
|
||||
type: "report",
|
||||
target: server,
|
||||
});
|
||||
return true;
|
||||
},
|
||||
children: <Text id="app.special.modals.actions.report" />,
|
||||
palette: "error",
|
||||
});
|
||||
|
||||
return (
|
||||
<Modal
|
||||
{...props}
|
||||
|
|
@ -26,41 +70,7 @@ export default function ServerInfo({
|
|||
</IconButton>
|
||||
</Row>
|
||||
}
|
||||
actions={[
|
||||
{
|
||||
onClick: () => {
|
||||
modalController.push({
|
||||
type: "server_identity",
|
||||
member: server.member!,
|
||||
});
|
||||
return true;
|
||||
},
|
||||
children: "Edit Identity",
|
||||
palette: "primary",
|
||||
},
|
||||
{
|
||||
onClick: () => {
|
||||
modalController.push({
|
||||
type: "leave_server",
|
||||
target: server,
|
||||
});
|
||||
return true;
|
||||
},
|
||||
children: "Leave Server",
|
||||
palette: "error",
|
||||
},
|
||||
{
|
||||
onClick: () => {
|
||||
modalController.push({
|
||||
type: "report",
|
||||
target: server,
|
||||
});
|
||||
return true;
|
||||
},
|
||||
children: <Text id="app.special.modals.actions.report" />,
|
||||
palette: "error",
|
||||
},
|
||||
]}>
|
||||
actions={actions}>
|
||||
<Markdown content={server.description!} />
|
||||
</Modal>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue