From cc625d9029dacbdda8de43be71d62077668364f3 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Thu, 10 Mar 2022 00:59:13 -0500 Subject: [PATCH] Show loaded plugins that edit cell on cell pane --- components/CellData.tsx | 3 +++ components/PluginsList.tsx | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/CellData.tsx b/components/CellData.tsx index f96c01e..95fc327 100644 --- a/components/CellData.tsx +++ b/components/CellData.tsx @@ -4,6 +4,7 @@ import useSWRImmutable from "swr/immutable"; import styles from "../styles/CellData.module.css"; import CellModList from "./CellModList"; +import PluginList from "./PluginsList"; export interface Mod { id: number; @@ -120,6 +121,8 @@ const CellData: React.FC = ({ selectedCell, counts }) => { {data.plugins_count} +

Loaded Plugins

+ ) diff --git a/components/PluginsList.tsx b/components/PluginsList.tsx index a8192c0..a0d08b4 100644 --- a/components/PluginsList.tsx +++ b/components/PluginsList.tsx @@ -6,11 +6,21 @@ import { excludedPlugins } from "../lib/plugins"; import { togglePlugin } from "../slices/plugins"; import styles from "../styles/PluginList.module.css"; -type Props = {}; +type Props = { + selectedCell: { x: number; y: number }; +}; -const PluginsList: React.FC = () => { +const PluginsList: React.FC = ({ selectedCell }) => { const dispatch = useAppDispatch(); - const plugins = useAppSelector((state) => state.plugins.plugins); + const plugins = useAppSelector((state) => + selectedCell + ? state.plugins.plugins.filter((plugin) => + plugin.parsed?.cells.some( + (cell) => cell.x === selectedCell.x && cell.y === selectedCell.y + ) + ) + : state.plugins.plugins + ); const pluginsPending = useAppSelector((state) => state.plugins.pending); return (