diff --git a/components/PluginsList.tsx b/components/PluginsList.tsx index 0d1812c..f7271e1 100644 --- a/components/PluginsList.tsx +++ b/components/PluginsList.tsx @@ -3,7 +3,11 @@ import React from "react"; import { useAppSelector, useAppDispatch } from "../lib/hooks"; import { excludedPlugins } from "../lib/plugins"; -import { togglePlugin } from "../slices/plugins"; +import { + enableAllPlugins, + disableAllPlugins, + togglePlugin, +} from "../slices/plugins"; import styles from "../styles/PluginList.module.css"; type Props = { @@ -30,6 +34,16 @@ const PluginsList: React.FC = ({ selectedCell }) => { return ( <> {plugins.length > 0 &&

Loaded Plugins ({plugins.length})

} + {!selectedCell && plugins.length > 0 && ( +
+ + +
+ )}
    {plugins.map((plugin) => (
  1. diff --git a/slices/plugins.ts b/slices/plugins.ts index db16d5b..dc5221a 100644 --- a/slices/plugins.ts +++ b/slices/plugins.ts @@ -1,6 +1,7 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit" import type { AppState, AppThunk } from "../lib/store" +import { excludedPlugins } from "../lib/plugins"; import { Mod } from "../components/ModData"; export interface Header { @@ -128,6 +129,16 @@ export const pluginsSlice = createSlice({ pending: state.pending, fetchedPlugin: state.fetchedPlugin, }), + enableAllPlugins: (state) => ({ + plugins: state.plugins.map((plugin) => ({ ...plugin, enabled: !plugin.parseError && !excludedPlugins.includes(plugin.filename) && true })), + pending: state.pending, + fetchedPlugin: state.fetchedPlugin, + }), + disableAllPlugins: (state) => ({ + plugins: state.plugins.map((plugin) => ({ ...plugin, enabled: false })), + pending: state.pending, + fetchedPlugin: state.fetchedPlugin, + }), setFetchedPlugin: (state, action: PayloadAction) => ({ plugins: state.plugins, pending: state.pending, @@ -141,7 +152,7 @@ export const pluginsSlice = createSlice({ }, }) -export const { addPlugin, setPlugins, setPending, decrementPending, togglePlugin, setFetchedPlugin, clearPlugins } = pluginsSlice.actions +export const { addPlugin, setPlugins, setPending, decrementPending, togglePlugin, enableAllPlugins, disableAllPlugins, setFetchedPlugin, clearPlugins } = pluginsSlice.actions export const selectPlugins = (state: AppState) => state.plugins diff --git a/styles/PluginList.module.css b/styles/PluginList.module.css index 71bf8ff..d4f9d95 100644 --- a/styles/PluginList.module.css +++ b/styles/PluginList.module.css @@ -17,6 +17,10 @@ margin-left: 8px; } +.loading { + margin-bottom: 12px; +} + /* From: https://stackoverflow.com/a/28074607/6620612 */ .loading:after { overflow: hidden; @@ -39,3 +43,17 @@ width: 1.25em; } } + +.buttons { + display: flex; + flex-direction: row; + padding-right: 12px; + padding-left: 12px; + justify-content: space-evenly; +} + +.buttons button { + flex: 1; + margin-right: 12px; + margin-right: 12px; +}