diff --git a/app/plugins/page.tsx b/app/plugins/page.tsx index b1c36c2..89b5dcd 100644 --- a/app/plugins/page.tsx +++ b/app/plugins/page.tsx @@ -32,7 +32,7 @@ import { AnimatePresence, motion } from "framer-motion" export default function Home() { const [ search, setSearch ] = useState("") - const [ searchTags, setSearchTags ] = useState([]) + const [ searchTags, setSearchTags ] = useState(["Base"]) const [ searchAuthors, setSearchAuthors ] = useState([]) const { data, error, isLoading } = useSWR("plugins", () => GetPlugins(), { refreshInterval: 1000 }) as any if (isLoading) return

{translate("loading")}

@@ -78,6 +78,7 @@ export default function Home() { } let hidden:number = 0; + const visible_plugins:string[] = []; const enabled_plugins:string[] = []; const disabled_plugins:string[] = []; for (const key in data) { @@ -134,6 +135,20 @@ export default function Home() { } } + const all_visible_enabled = disabled_plugins.length == 0; + + const EnableAllVisiblePlugins = async () => { + for (const plugin in disabled_plugins) { + await EnablePlugin(disabled_plugins[plugin]) + } + } + + const DisableAllVisiblePlugins = async () => { + for (const plugin in enabled_plugins) { + await DisablePlugin(enabled_plugins[plugin]) + } + } + return ( {translate("frontend.plugins.name")}

{translate("frontend.plugins.authors")}

{translate("frontend.plugins.tags")}

+ { + if(all_visible_enabled){ + toast.promise( + DisableAllVisiblePlugins(), + { + loading: translate("frontend.plugins.disabling_all_plugins"), + success: translate("frontend.plugins.disabled_all_plugins"), + error: translate("frontend.plugins.error_disabling_all_plugins"), + } + ) + } + else{ + toast.promise( + EnableAllVisiblePlugins(), + { + loading: translate("frontend.plugins.enabling_all_plugins"), + success: translate("frontend.plugins.enabled_all_plugins"), + error: translate("frontend.plugins.error_enabling_all_plugins"), + } + ) + } + setTimeout(() => { + mutate("plugins") + }, 200) + }} className={all_visible_enabled ? "left-3.5 absolute opacity-100" : "left-3.5 absolute opacity-60"} /> {enabled_plugins.map((plugin:any, index) => (