feat(settings): reset plugins & settings options(#57)

* start of channelbadges

* update badges

* give in and add colors to settings page, refactor

* change from styles.css to style.css

* update for linter

* forgot to remove dm css no need for them

* Fixes

* update PluginModal.tsx and src/components/PluginSettings/index.tsx

adds options to disable all plugins and a option to reset a plugins settings to the default state

* Update warning image and image size in PluginModal and PluginSettings

---------

Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
Creation's 2024-10-15 10:17:43 -04:00 committed by GitHub
parent 2cb70a7cb8
commit 70c15730b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 226 additions and 14 deletions

View file

@ -386,6 +386,76 @@ export default function PluginSettings() {
</div>
<Forms.FormTitle className={Margins.top20}>Plugins</Forms.FormTitle>
{enabledPlugins.length > 0 && (
<Button
size={Button.Sizes.SMALL}
style={{ backgroundColor: "var(--button-danger-background)", margin: "20px 0" }}
onClick={() => {
return Alerts.show({
title: "Disable All Plugins",
body: (
<>
<img
src="https://media.tenor.com/Y6DXKZiBCs8AAAAi/stavario-josefbenes.gif"
alt="Warning"
style={{ width: "60%", height: "auto", marginBottom: "10px", display: "block", margin: "auto" }}
/>
<p style={{ fontSize: "1.2rem", color: "var(--text-danger)", fontWeight: "bold" }}>
WARNING: You are about to disable <span style={{ textDecoration: "underline" }}>{enabledPlugins.length}</span> plugins!
</p>
<p style={{ fontSize: "1rem" }}>
Are you absolutely sure you want to proceed? You can always enable them back later.
</p>
</>
),
confirmText: "Disable All",
cancelText: "Cancel",
onConfirm: () => {
let restartNeeded = false;
for (const plugin of enabledPlugins) {
const pluginSettings = settings.plugins[plugin];
if (Plugins[plugin].patches?.length) {
pluginSettings.enabled = false;
changes.handleChange(plugin);
restartNeeded = true;
continue;
}
const result = stopPlugin(Plugins[plugin]);
if (!result) {
logger.error(`Error while stopping plugin ${plugin}`);
showErrorToast(`Error while stopping plugin ${plugin}`);
continue;
}
pluginSettings.enabled = false;
}
if (restartNeeded) {
Alerts.show({
title: "Restart Required",
body: (
<>
<p>Some plugins require a restart to fully disable.</p>
<p>Would you like to restart now?</p>
</>
),
confirmText: "Restart Now",
cancelText: "Later",
onConfirm: () => location.reload()
});
}
}
});
}}
>
Disable All Plugins
</Button>
)}
{plugins.length || requiredPlugins.length
? (