mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-01 11:20:58 -05:00
feat: Implement a plugins page
This commit is contained in:
parent
8021169131
commit
07439bd5f6
4 changed files with 67 additions and 2 deletions
|
@ -94,6 +94,18 @@ export default class Plugins implements Store, Persistent<Data> {
|
||||||
return "revite:plugins";
|
return "revite:plugins";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lexisother: https://github.com/revoltchat/revite/pull/571#discussion_r836824601
|
||||||
|
list() {
|
||||||
|
return [...this.plugins.values()].map(
|
||||||
|
({ namespace, id, version, enabled }) => ({
|
||||||
|
namespace,
|
||||||
|
id,
|
||||||
|
version,
|
||||||
|
enabled,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
"revite:plugins": mapToRecord(this.plugins),
|
"revite:plugins": mapToRecord(this.plugins),
|
||||||
|
@ -211,7 +223,7 @@ export default class Plugins implements Store, Persistent<Data> {
|
||||||
loaded.onUnload?.();
|
loaded.onUnload?.();
|
||||||
this.plugins.set(ns, {
|
this.plugins.set(ns, {
|
||||||
...plugin,
|
...plugin,
|
||||||
enabled: true,
|
enabled: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
User,
|
User,
|
||||||
Megaphone,
|
Megaphone,
|
||||||
Speaker,
|
Speaker,
|
||||||
Store,
|
Plug,
|
||||||
Bot,
|
Bot,
|
||||||
Trash,
|
Trash,
|
||||||
} from "@styled-icons/boxicons-solid";
|
} from "@styled-icons/boxicons-solid";
|
||||||
|
@ -53,6 +53,7 @@ import { Languages } from "./panes/Languages";
|
||||||
import { MyBots } from "./panes/MyBots";
|
import { MyBots } from "./panes/MyBots";
|
||||||
import { Native } from "./panes/Native";
|
import { Native } from "./panes/Native";
|
||||||
import { Notifications } from "./panes/Notifications";
|
import { Notifications } from "./panes/Notifications";
|
||||||
|
import { PluginsPage } from "./panes/Plugins";
|
||||||
import { Profile } from "./panes/Profile";
|
import { Profile } from "./panes/Profile";
|
||||||
import { Sessions } from "./panes/Sessions";
|
import { Sessions } from "./panes/Sessions";
|
||||||
import { Sync } from "./panes/Sync";
|
import { Sync } from "./panes/Sync";
|
||||||
|
@ -162,6 +163,13 @@ export default observer(() => {
|
||||||
icon: <Palette size={20} />,
|
icon: <Palette size={20} />,
|
||||||
title: <Text id="app.settings.pages.appearance.title" />,
|
title: <Text id="app.settings.pages.appearance.title" />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "plugins",
|
||||||
|
icon: <Plug size={20} />,
|
||||||
|
// TODO(lexisother): Replace this with the actual i18n <Text />
|
||||||
|
title: <p>Plugins</p>,
|
||||||
|
hidden: !experiments.isEnabled("plugins"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "notifications",
|
id: "notifications",
|
||||||
icon: <Bell size={20} />,
|
icon: <Bell size={20} />,
|
||||||
|
@ -214,6 +222,9 @@ export default observer(() => {
|
||||||
<Route path="/settings/appearance">
|
<Route path="/settings/appearance">
|
||||||
<Appearance />
|
<Appearance />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="/settings/plugins">
|
||||||
|
<PluginsPage />
|
||||||
|
</Route>
|
||||||
<Route path="/settings/audio">
|
<Route path="/settings/audio">
|
||||||
<Audio />
|
<Audio />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
|
@ -528,6 +528,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.plugins {
|
||||||
|
h1 {
|
||||||
|
margin-bottom: 20px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.myBots {
|
.myBots {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
.botList {
|
.botList {
|
||||||
|
|
36
src/pages/settings/panes/Plugins.tsx
Normal file
36
src/pages/settings/panes/Plugins.tsx
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
|
|
||||||
|
import styles from "./Panes.module.scss";
|
||||||
|
|
||||||
|
import { useApplicationState } from "../../../mobx/State";
|
||||||
|
|
||||||
|
import Checkbox from "../../../components/ui/Checkbox";
|
||||||
|
import Tip from "../../../components/ui/Tip";
|
||||||
|
|
||||||
|
export const PluginsPage = observer(() => {
|
||||||
|
const plugins = useApplicationState().plugins;
|
||||||
|
return (
|
||||||
|
<div className={styles.plugins}>
|
||||||
|
{/* TODO(lexisother): Wrap in <h3><Text /></h3> */}
|
||||||
|
<h1>Plugins</h1>
|
||||||
|
<Tip error hideSeparator>
|
||||||
|
Warning: This feature is still in development.
|
||||||
|
</Tip>
|
||||||
|
{plugins.list().map((plugin) => {
|
||||||
|
return (
|
||||||
|
<Checkbox
|
||||||
|
key={plugin.id}
|
||||||
|
checked={plugin.enabled!}
|
||||||
|
onChange={() => {
|
||||||
|
!plugin.enabled
|
||||||
|
? plugins.load(plugin.namespace, plugin.id)
|
||||||
|
: plugins.unload(plugin.namespace, plugin.id);
|
||||||
|
}}
|
||||||
|
description={""}>
|
||||||
|
{plugin.namespace} / {plugin.id}
|
||||||
|
</Checkbox>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
Loading…
Reference in a new issue