From 07439bd5f68ce92cd62023c015e232f0dcca54fd Mon Sep 17 00:00:00 2001 From: Alyxia Sother Date: Mon, 28 Mar 2022 21:32:19 +0200 Subject: [PATCH] feat: Implement a plugins page --- src/mobx/stores/Plugins.ts | 14 ++++++++- src/pages/settings/Settings.tsx | 13 +++++++- src/pages/settings/panes/Panes.module.scss | 6 ++++ src/pages/settings/panes/Plugins.tsx | 36 ++++++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/pages/settings/panes/Plugins.tsx diff --git a/src/mobx/stores/Plugins.ts b/src/mobx/stores/Plugins.ts index 10b6c01f..506decb5 100644 --- a/src/mobx/stores/Plugins.ts +++ b/src/mobx/stores/Plugins.ts @@ -94,6 +94,18 @@ export default class Plugins implements Store, Persistent { 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() { return { "revite:plugins": mapToRecord(this.plugins), @@ -211,7 +223,7 @@ export default class Plugins implements Store, Persistent { loaded.onUnload?.(); this.plugins.set(ns, { ...plugin, - enabled: true, + enabled: false, }); } } diff --git a/src/pages/settings/Settings.tsx b/src/pages/settings/Settings.tsx index e8743a02..6befe9d5 100644 --- a/src/pages/settings/Settings.tsx +++ b/src/pages/settings/Settings.tsx @@ -15,7 +15,7 @@ import { User, Megaphone, Speaker, - Store, + Plug, Bot, Trash, } from "@styled-icons/boxicons-solid"; @@ -53,6 +53,7 @@ import { Languages } from "./panes/Languages"; import { MyBots } from "./panes/MyBots"; import { Native } from "./panes/Native"; import { Notifications } from "./panes/Notifications"; +import { PluginsPage } from "./panes/Plugins"; import { Profile } from "./panes/Profile"; import { Sessions } from "./panes/Sessions"; import { Sync } from "./panes/Sync"; @@ -162,6 +163,13 @@ export default observer(() => { icon: , title: , }, + { + id: "plugins", + icon: , + // TODO(lexisother): Replace this with the actual i18n + title:

Plugins

, + hidden: !experiments.isEnabled("plugins"), + }, { id: "notifications", icon: , @@ -214,6 +222,9 @@ export default observer(() => { + + + diff --git a/src/pages/settings/panes/Panes.module.scss b/src/pages/settings/panes/Panes.module.scss index 91427372..2695cb45 100644 --- a/src/pages/settings/panes/Panes.module.scss +++ b/src/pages/settings/panes/Panes.module.scss @@ -528,6 +528,12 @@ } } +.plugins { + h1 { + margin-bottom: 20px !important; + } +} + .myBots { margin-top: 10px; .botList { diff --git a/src/pages/settings/panes/Plugins.tsx b/src/pages/settings/panes/Plugins.tsx new file mode 100644 index 00000000..fdb19c57 --- /dev/null +++ b/src/pages/settings/panes/Plugins.tsx @@ -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 ( +
+ {/* TODO(lexisother): Wrap in

*/} +

Plugins

+ + Warning: This feature is still in development. + + {plugins.list().map((plugin) => { + return ( + { + !plugin.enabled + ? plugins.load(plugin.namespace, plugin.id) + : plugins.unload(plugin.namespace, plugin.id); + }} + description={""}> + {plugin.namespace} / {plugin.id} + + ); + })} +
+ ); +});