Merge two plugin pages for easier management
This commit is contained in:
parent
199ed9f8b2
commit
3f0c22342a
3 changed files with 5 additions and 59 deletions
|
|
@ -21,18 +21,9 @@ export default function initSettings() {
|
|||
useTrailing: () => `(${version})`,
|
||||
},
|
||||
{
|
||||
key: "CORE_PLUGINS",
|
||||
key: "BUNNY_PLUGINS",
|
||||
title: () => Strings.PLUGINS,
|
||||
icon: findAssetId("ActivitiesIcon"),
|
||||
render: () => import("@core/ui/settings/pages/Plugins/CorePlugins"),
|
||||
},
|
||||
{
|
||||
key: "BUNNY_PLUGINS",
|
||||
title: () => "External Plugins",
|
||||
icon:
|
||||
findAssetId("DownloadIcon") ??
|
||||
findAssetId("LinkIcon") ??
|
||||
findAssetId("ActivitiesIcon"),
|
||||
render: () => import("@core/ui/settings/pages/Plugins"),
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
import { React } from "@metro/common";
|
||||
import AddonPage from "@core/ui/components/AddonPage";
|
||||
import PluginCard from "@core/ui/settings/pages/Plugins/components/PluginCard";
|
||||
import { corePluginInstances, registeredPlugins } from "@lib/addons/plugins";
|
||||
import { UnifiedPluginModel } from "@core/ui/settings/pages/Plugins/models";
|
||||
import unifyBunnyPlugin from "@core/ui/settings/pages/Plugins/models/bunny";
|
||||
import { Strings } from "@core/i18n";
|
||||
|
||||
/**
|
||||
* Core plugins settings page
|
||||
*
|
||||
* This page shows only the built-in core plugins. Core plugins are always
|
||||
* installed (can't be uninstalled) and are registered in `corePluginInstances`.
|
||||
*
|
||||
* We reuse the existing `AddonPage` + `PluginCard` components and feed them
|
||||
* the normalized `UnifiedPluginModel` objects produced by `unifyBunnyPlugin`.
|
||||
*/
|
||||
|
||||
export default function CorePlugins() {
|
||||
return (
|
||||
<AddonPage<UnifiedPluginModel>
|
||||
CardComponent={PluginCard}
|
||||
title={Strings.PLUGINS}
|
||||
searchKeywords={[
|
||||
"name",
|
||||
"description",
|
||||
(p) =>
|
||||
p.authors
|
||||
?.map((a: any) => (typeof a === "string" ? a : a.name))
|
||||
.join() || "",
|
||||
]}
|
||||
// Provide simple sort options so the Search input renders round and a sort menu appears
|
||||
sortOptions={{
|
||||
"Name (A-Z)": (a, b) => a.name.localeCompare(b.name),
|
||||
"Name (Z-A)": (a, b) => b.name.localeCompare(a.name),
|
||||
}}
|
||||
// Only core plugins: map corePluginInstances -> registeredPlugins -> unify
|
||||
items={[...corePluginInstances.keys()]
|
||||
.map((id) => registeredPlugins.get(id))
|
||||
.filter((m): m is any => m !== undefined)
|
||||
.map(unifyBunnyPlugin)}
|
||||
ListHeaderComponent={() => null}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -702,7 +702,7 @@ export default function Plugins() {
|
|||
// Use the insertion order of pluginSettings so newly-installed plugins
|
||||
// (which add entries to pluginSettings) appear first.
|
||||
const installedBnIds = Object.keys(pluginSettings || {})
|
||||
.filter((id) => registeredPlugins.has(id) && !isCorePlugin(id))
|
||||
.filter((id) => registeredPlugins.has(id))
|
||||
.slice()
|
||||
.reverse();
|
||||
|
||||
|
|
@ -710,12 +710,12 @@ export default function Plugins() {
|
|||
.map((id) => registeredPlugins.get(id)!)
|
||||
.map(unifyBunnyPlugin);
|
||||
|
||||
// Merge lists: show Vendetta-managed plugins first (recent first),
|
||||
// Merge lists: show Vendetta-managed plugins first,
|
||||
// then Bunny-installed externals (recent first).
|
||||
const allPlugins = [...vdPlugins, ...bnPlugins];
|
||||
|
||||
// Filter out core plugins from the list
|
||||
return allPlugins.filter((plugin) => !isCorePlugin(plugin.id));
|
||||
// Include core plugins in the list
|
||||
return allPlugins;
|
||||
}}
|
||||
ListHeaderComponent={() => null}
|
||||
installAction={{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue