mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-21 22:50:59 -05:00
feat: add delete server button to server settings (#373)
Co-authored-by: Paul Makles <paulmakles@gmail.com>
This commit is contained in:
parent
31d90481c2
commit
50e1aa0dff
3 changed files with 35 additions and 4 deletions
|
@ -155,8 +155,6 @@ export const SpecialPromptModal = observer((props: SpecialProps) => {
|
|||
case "leave_group":
|
||||
case "close_dm":
|
||||
case "delete_channel":
|
||||
props.target.delete();
|
||||
break;
|
||||
case "leave_server":
|
||||
case "delete_server":
|
||||
props.target.delete();
|
||||
|
|
|
@ -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 { observer } from "mobx-react-lite";
|
||||
import { Route, Switch, useHistory, useParams } from "react-router-dom";
|
||||
|
||||
import styles from "./Settings.module.scss";
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
import { useIntermediate } from "../../context/intermediate/Intermediate";
|
||||
import RequiresOnline from "../../context/revoltjs/RequiresOnline";
|
||||
import { useClient } from "../../context/revoltjs/RevoltClient";
|
||||
|
||||
import Category from "../../components/ui/Category";
|
||||
import LineDivider from "../../components/ui/LineDivider";
|
||||
|
||||
import ButtonItem from "../../components/navigation/items/ButtonItem";
|
||||
import { GenericSettings } from "./GenericSettings";
|
||||
import { Bans } from "./server/Bans";
|
||||
import { Categories } from "./server/Categories";
|
||||
|
@ -19,11 +28,13 @@ import { Overview } from "./server/Overview";
|
|||
import { Roles } from "./server/Roles";
|
||||
|
||||
export default observer(() => {
|
||||
const { openScreen } = useIntermediate();
|
||||
const { server: sid } = useParams<{ server: string }>();
|
||||
const client = useClient();
|
||||
const server = client.servers.get(sid);
|
||||
if (!server) return null;
|
||||
|
||||
const owner = server.owner === client.user?._id;
|
||||
const history = useHistory();
|
||||
function switchPage(to?: string) {
|
||||
if (to) {
|
||||
|
@ -111,6 +122,26 @@ export default observer(() => {
|
|||
category="server_pages"
|
||||
switchPage={switchPage}
|
||||
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
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -144,7 +144,9 @@
|
|||
.donate {
|
||||
color: goldenrod !important;
|
||||
}
|
||||
.logOut {
|
||||
|
||||
.logOut,
|
||||
.deleteServer {
|
||||
color: var(--error) !important;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue