feat: add delete server button to server settings (#373)

Co-authored-by: Paul Makles <paulmakles@gmail.com>
This commit is contained in:
Ed L 2021-11-12 22:24:30 +00:00 committed by GitHub
parent 31d90481c2
commit 50e1aa0dff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 4 deletions

View file

@ -155,8 +155,6 @@ export const SpecialPromptModal = observer((props: SpecialProps) => {
case "leave_group": case "leave_group":
case "close_dm": case "close_dm":
case "delete_channel": case "delete_channel":
props.target.delete();
break;
case "leave_server": case "leave_server":
case "delete_server": case "delete_server":
props.target.delete(); props.target.delete();

View file

@ -1,15 +1,24 @@
import { ListUl, ListCheck, ListMinus } from "@styled-icons/boxicons-regular"; import {
ListUl,
ListCheck,
ListMinus,
Trash,
} from "@styled-icons/boxicons-regular";
import { XSquare, Share, Group } from "@styled-icons/boxicons-solid"; import { XSquare, Share, Group } from "@styled-icons/boxicons-solid";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Route, Switch, useHistory, useParams } from "react-router-dom"; import { Route, Switch, useHistory, useParams } from "react-router-dom";
import styles from "./Settings.module.scss";
import { Text } from "preact-i18n"; import { Text } from "preact-i18n";
import { useIntermediate } from "../../context/intermediate/Intermediate";
import RequiresOnline from "../../context/revoltjs/RequiresOnline"; import RequiresOnline from "../../context/revoltjs/RequiresOnline";
import { useClient } from "../../context/revoltjs/RevoltClient"; import { useClient } from "../../context/revoltjs/RevoltClient";
import Category from "../../components/ui/Category"; import Category from "../../components/ui/Category";
import LineDivider from "../../components/ui/LineDivider";
import ButtonItem from "../../components/navigation/items/ButtonItem";
import { GenericSettings } from "./GenericSettings"; import { GenericSettings } from "./GenericSettings";
import { Bans } from "./server/Bans"; import { Bans } from "./server/Bans";
import { Categories } from "./server/Categories"; import { Categories } from "./server/Categories";
@ -19,11 +28,13 @@ import { Overview } from "./server/Overview";
import { Roles } from "./server/Roles"; import { Roles } from "./server/Roles";
export default observer(() => { export default observer(() => {
const { openScreen } = useIntermediate();
const { server: sid } = useParams<{ server: string }>(); const { server: sid } = useParams<{ server: string }>();
const client = useClient(); const client = useClient();
const server = client.servers.get(sid); const server = client.servers.get(sid);
if (!server) return null; if (!server) return null;
const owner = server.owner === client.user?._id;
const history = useHistory(); const history = useHistory();
function switchPage(to?: string) { function switchPage(to?: string) {
if (to) { if (to) {
@ -111,6 +122,26 @@ export default observer(() => {
category="server_pages" category="server_pages"
switchPage={switchPage} switchPage={switchPage}
defaultPage="overview" defaultPage="overview"
custom={
owner ? (
<>
<LineDivider />
<ButtonItem
onClick={() =>
openScreen({
id: "special_prompt",
type: "delete_server",
target: server,
})
}
className={styles.deleteServer}
compact>
<Trash size={20} />
<Text id="app.context_menu.delete_server" />
</ButtonItem>
</>
) : undefined
}
showExitButton showExitButton
/> />
); );

View file

@ -144,7 +144,9 @@
.donate { .donate {
color: goldenrod !important; color: goldenrod !important;
} }
.logOut {
.logOut,
.deleteServer {
color: var(--error) !important; color: var(--error) !important;
} }