2021-07-05 06:23:23 -04:00
|
|
|
import { Gitlab } from "@styled-icons/boxicons-logos";
|
|
|
|
import {
|
2021-07-05 06:25:20 -04:00
|
|
|
Sync as SyncIcon,
|
|
|
|
Globe,
|
|
|
|
LogOut,
|
2021-07-31 17:39:15 -04:00
|
|
|
Desktop,
|
2021-08-12 10:29:19 -04:00
|
|
|
Bot,
|
2021-07-05 06:23:23 -04:00
|
|
|
} from "@styled-icons/boxicons-regular";
|
|
|
|
import {
|
2021-07-05 06:25:20 -04:00
|
|
|
Bell,
|
|
|
|
Palette,
|
|
|
|
Coffee,
|
|
|
|
IdCard,
|
|
|
|
CheckShield,
|
|
|
|
Flask,
|
|
|
|
User,
|
|
|
|
Megaphone,
|
2021-07-05 06:23:23 -04:00
|
|
|
} from "@styled-icons/boxicons-solid";
|
2021-08-05 09:47:00 -04:00
|
|
|
import { Route, Switch, useHistory } from "react-router-dom";
|
2021-07-05 06:23:23 -04:00
|
|
|
import { LIBRARY_VERSION } from "revolt.js";
|
|
|
|
|
|
|
|
import styles from "./Settings.module.scss";
|
2021-06-19 17:37:12 -04:00
|
|
|
import { Text } from "preact-i18n";
|
|
|
|
import { useContext } from "preact/hooks";
|
2021-07-05 06:23:23 -04:00
|
|
|
|
|
|
|
import RequiresOnline from "../../context/revoltjs/RequiresOnline";
|
2021-06-19 17:37:12 -04:00
|
|
|
import {
|
2021-07-05 06:25:20 -04:00
|
|
|
AppContext,
|
|
|
|
OperationsContext,
|
2021-07-05 06:23:23 -04:00
|
|
|
} from "../../context/revoltjs/RevoltClient";
|
|
|
|
|
2021-06-19 17:37:12 -04:00
|
|
|
import LineDivider from "../../components/ui/LineDivider";
|
2021-07-05 06:23:23 -04:00
|
|
|
|
2021-06-19 17:37:12 -04:00
|
|
|
import ButtonItem from "../../components/navigation/items/ButtonItem";
|
2021-07-05 06:23:23 -04:00
|
|
|
import { GIT_BRANCH, GIT_REVISION, REPO_URL } from "../../revision";
|
|
|
|
import { APP_VERSION } from "../../version";
|
|
|
|
import { GenericSettings } from "./GenericSettings";
|
2021-06-19 17:37:12 -04:00
|
|
|
import { Account } from "./panes/Account";
|
2021-07-05 06:23:23 -04:00
|
|
|
import { Appearance } from "./panes/Appearance";
|
|
|
|
import { ExperimentsPage } from "./panes/Experiments";
|
2021-06-19 17:37:12 -04:00
|
|
|
import { Feedback } from "./panes/Feedback";
|
|
|
|
import { Languages } from "./panes/Languages";
|
2021-08-12 10:29:19 -04:00
|
|
|
import { MyBots } from "./panes/MyBots";
|
2021-07-31 17:39:15 -04:00
|
|
|
import { Native } from "./panes/Native";
|
2021-06-19 17:37:12 -04:00
|
|
|
import { Notifications } from "./panes/Notifications";
|
2021-07-05 06:23:23 -04:00
|
|
|
import { Profile } from "./panes/Profile";
|
|
|
|
import { Sessions } from "./panes/Sessions";
|
|
|
|
import { Sync } from "./panes/Sync";
|
2021-06-19 17:37:12 -04:00
|
|
|
|
|
|
|
export default function Settings() {
|
2021-07-05 06:25:20 -04:00
|
|
|
const history = useHistory();
|
|
|
|
const client = useContext(AppContext);
|
|
|
|
const operations = useContext(OperationsContext);
|
2021-07-05 06:23:23 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
function switchPage(to?: string) {
|
|
|
|
if (to) {
|
|
|
|
history.replace(`/settings/${to}`);
|
|
|
|
} else {
|
|
|
|
history.replace(`/settings`);
|
|
|
|
}
|
|
|
|
}
|
2021-06-19 17:37:12 -04:00
|
|
|
|
2021-07-05 06:25:20 -04:00
|
|
|
return (
|
|
|
|
<GenericSettings
|
|
|
|
pages={[
|
|
|
|
{
|
|
|
|
category: (
|
|
|
|
<Text id="app.settings.categories.user_settings" />
|
|
|
|
),
|
|
|
|
id: "account",
|
|
|
|
icon: <User size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.account.title" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "profile",
|
|
|
|
icon: <IdCard size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.profile.title" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "sessions",
|
|
|
|
icon: <CheckShield size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.sessions.title" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
category: (
|
|
|
|
<Text id="app.settings.categories.client_settings" />
|
|
|
|
),
|
|
|
|
id: "appearance",
|
|
|
|
icon: <Palette size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.appearance.title" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "notifications",
|
|
|
|
icon: <Bell size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.notifications.title" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "language",
|
|
|
|
icon: <Globe size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.language.title" />,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "sync",
|
|
|
|
icon: <SyncIcon size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.sync.title" />,
|
|
|
|
},
|
2021-07-31 17:39:15 -04:00
|
|
|
{
|
|
|
|
id: "native",
|
2021-08-01 16:55:13 -04:00
|
|
|
hidden: !window.isNative,
|
2021-07-31 17:39:15 -04:00
|
|
|
icon: <Desktop size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.native.title" />,
|
|
|
|
},
|
2021-07-05 06:25:20 -04:00
|
|
|
{
|
|
|
|
id: "experiments",
|
|
|
|
icon: <Flask size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.experiments.title" />,
|
|
|
|
},
|
2021-08-12 10:29:19 -04:00
|
|
|
{
|
|
|
|
divider: true,
|
|
|
|
category: "revolt",
|
|
|
|
id: "bots",
|
|
|
|
icon: <Bot size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.bots.title" />,
|
|
|
|
},
|
2021-07-05 06:25:20 -04:00
|
|
|
{
|
|
|
|
id: "feedback",
|
|
|
|
icon: <Megaphone size={20} />,
|
|
|
|
title: <Text id="app.settings.pages.feedback.title" />,
|
|
|
|
},
|
|
|
|
]}
|
2021-08-05 09:47:00 -04:00
|
|
|
children={
|
|
|
|
<Switch>
|
|
|
|
<Route path="/settings/profile">
|
|
|
|
<Profile />
|
|
|
|
</Route>
|
|
|
|
<Route path="/settings/sessions">
|
|
|
|
<RequiresOnline>
|
|
|
|
<Sessions />
|
|
|
|
</RequiresOnline>
|
|
|
|
</Route>
|
|
|
|
<Route path="/settings/appearance">
|
|
|
|
<Appearance />
|
|
|
|
</Route>
|
|
|
|
<Route path="/settings/notifications">
|
|
|
|
<Notifications />
|
|
|
|
</Route>
|
|
|
|
<Route path="/settings/language">
|
|
|
|
<Languages />
|
|
|
|
</Route>
|
|
|
|
<Route path="/settings/sync">
|
|
|
|
<Sync />
|
|
|
|
</Route>
|
|
|
|
<Route path="/settings/native">
|
|
|
|
<Native />
|
|
|
|
</Route>
|
|
|
|
<Route path="/settings/experiments">
|
|
|
|
<ExperimentsPage />
|
|
|
|
</Route>
|
2021-08-12 10:29:19 -04:00
|
|
|
<Route path="/settings/bots">
|
|
|
|
<MyBots />
|
|
|
|
</Route>
|
2021-08-05 09:47:00 -04:00
|
|
|
<Route path="/settings/feedback">
|
|
|
|
<Feedback />
|
|
|
|
</Route>
|
2021-08-05 15:19:02 -04:00
|
|
|
<Route path="/">
|
2021-08-05 09:47:00 -04:00
|
|
|
<Account />
|
|
|
|
</Route>
|
|
|
|
</Switch>
|
|
|
|
}
|
2021-07-05 06:25:20 -04:00
|
|
|
defaultPage="account"
|
|
|
|
switchPage={switchPage}
|
|
|
|
category="pages"
|
2021-08-05 09:47:00 -04:00
|
|
|
custom={
|
|
|
|
<>
|
|
|
|
<a
|
|
|
|
href="https://gitlab.insrt.uk/revolt"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer">
|
|
|
|
<ButtonItem compact>
|
|
|
|
<Gitlab size={20} />
|
|
|
|
<Text id="app.settings.pages.source_code" />
|
|
|
|
</ButtonItem>
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
href="https://insrt.uk/donate"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer">
|
|
|
|
<ButtonItem className={styles.donate} compact>
|
|
|
|
<Coffee size={20} />
|
|
|
|
<Text id="app.settings.pages.donate.title" />
|
|
|
|
</ButtonItem>
|
|
|
|
</a>
|
|
|
|
<LineDivider />
|
|
|
|
<ButtonItem
|
|
|
|
onClick={() => operations.logout()}
|
|
|
|
className={styles.logOut}
|
|
|
|
compact>
|
|
|
|
<LogOut size={20} />
|
|
|
|
<Text id="app.settings.pages.logOut" />
|
2021-07-05 06:25:20 -04:00
|
|
|
</ButtonItem>
|
2021-08-05 09:47:00 -04:00
|
|
|
<div className={styles.version}>
|
|
|
|
<span className={styles.revision}>
|
|
|
|
<a
|
|
|
|
href={`${REPO_URL}/${GIT_REVISION}`}
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer">
|
|
|
|
{GIT_REVISION.substr(0, 7)}
|
|
|
|
</a>
|
|
|
|
{` `}
|
|
|
|
<a
|
|
|
|
href={
|
|
|
|
GIT_BRANCH !== "DETACHED"
|
|
|
|
? `https://gitlab.insrt.uk/revolt/client/-/tree/${GIT_BRANCH}`
|
|
|
|
: undefined
|
|
|
|
}
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer">
|
|
|
|
({GIT_BRANCH})
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{GIT_BRANCH === "production" ? "Stable" : "Nightly"}{" "}
|
|
|
|
{APP_VERSION}
|
|
|
|
</span>
|
|
|
|
{window.isNative && (
|
|
|
|
<span>Native: {window.nativeVersion}</span>
|
|
|
|
)}
|
|
|
|
<span>
|
|
|
|
API: {client.configuration?.revolt ?? "N/A"}
|
|
|
|
</span>
|
|
|
|
<span>revolt.js: {LIBRARY_VERSION}</span>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
}
|
2021-07-05 06:25:20 -04:00
|
|
|
/>
|
|
|
|
);
|
2021-06-19 17:37:12 -04:00
|
|
|
}
|