summaryrefslogtreecommitdiff
path: root/frontend/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components')
-rw-r--r--frontend/src/components/DeckyState.tsx8
-rw-r--r--frontend/src/components/modals/PluginUninstallModal.tsx3
-rw-r--r--frontend/src/components/settings/index.tsx2
-rw-r--r--frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx22
-rw-r--r--frontend/src/components/settings/pages/plugin_list/index.tsx30
5 files changed, 55 insertions, 10 deletions
diff --git a/frontend/src/components/DeckyState.tsx b/frontend/src/components/DeckyState.tsx
index d20c8d86..749e27ce 100644
--- a/frontend/src/components/DeckyState.tsx
+++ b/frontend/src/components/DeckyState.tsx
@@ -8,6 +8,7 @@ import { VerInfo } from '../updater';
interface PublicDeckyState {
plugins: Plugin[];
pluginOrder: string[];
+ frozenPlugins: string[];
hiddenPlugins: string[];
activePlugin: Plugin | null;
updates: PluginUpdateMapping | null;
@@ -26,6 +27,7 @@ export interface UserInfo {
export class DeckyState {
private _plugins: Plugin[] = [];
private _pluginOrder: string[] = [];
+ private _frozenPlugins: string[] = [];
private _hiddenPlugins: string[] = [];
private _activePlugin: Plugin | null = null;
private _updates: PluginUpdateMapping | null = null;
@@ -41,6 +43,7 @@ export class DeckyState {
return {
plugins: this._plugins,
pluginOrder: this._pluginOrder,
+ frozenPlugins: this._frozenPlugins,
hiddenPlugins: this._hiddenPlugins,
activePlugin: this._activePlugin,
updates: this._updates,
@@ -67,6 +70,11 @@ export class DeckyState {
this.notifyUpdate();
}
+ setFrozenPlugins(frozenPlugins: string[]) {
+ this._frozenPlugins = frozenPlugins;
+ this.notifyUpdate();
+ }
+
setHiddenPlugins(hiddenPlugins: string[]) {
this._hiddenPlugins = hiddenPlugins;
this.notifyUpdate();
diff --git a/frontend/src/components/modals/PluginUninstallModal.tsx b/frontend/src/components/modals/PluginUninstallModal.tsx
index e7ecbc99..5de0085e 100644
--- a/frontend/src/components/modals/PluginUninstallModal.tsx
+++ b/frontend/src/components/modals/PluginUninstallModal.tsx
@@ -15,8 +15,9 @@ const PluginUninstallModal: FC<PluginUninstallModalProps> = ({ name, title, butt
closeModal={closeModal}
onOK={async () => {
await window.DeckyPluginLoader.callServerMethod('uninstall_plugin', { name });
- // uninstalling a plugin resets the hidden setting for it server-side
+ // uninstalling a plugin resets the frozen and hidden setting for it server-side
// we invalidate here so if you re-install it, you won't have an out-of-date hidden filter
+ await window.DeckyPluginLoader.frozenPluginsService.invalidate();
await window.DeckyPluginLoader.hiddenPluginsService.invalidate();
}}
strTitle={title}
diff --git a/frontend/src/components/settings/index.tsx b/frontend/src/components/settings/index.tsx
index 568a0a49..80400058 100644
--- a/frontend/src/components/settings/index.tsx
+++ b/frontend/src/components/settings/index.tsx
@@ -25,7 +25,7 @@ export default function SettingsPage() {
},
{
title: t('SettingsIndex.plugins_title'),
- content: <PluginList />,
+ content: <PluginList isDeveloper={isDeveloper} />,
route: '/decky/settings/plugins',
icon: <FaPlug />,
},
diff --git a/frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx b/frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx
index a49f808f..fec03e56 100644
--- a/frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx
+++ b/frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx
@@ -1,18 +1,34 @@
import { FC } from 'react';
import { useTranslation } from 'react-i18next';
-import { FaEyeSlash } from 'react-icons/fa';
+import { FaEyeSlash, FaLock } from 'react-icons/fa';
interface PluginListLabelProps {
+ frozen: boolean;
hidden: boolean;
name: string;
version?: string;
}
-const PluginListLabel: FC<PluginListLabelProps> = ({ name, hidden, version }) => {
+const PluginListLabel: FC<PluginListLabelProps> = ({ name, frozen, hidden, version }) => {
const { t } = useTranslation();
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '6px' }}>
- <div>{version ? `${name} - ${version}` : name}</div>
+ <div>
+ {name}
+ {version && (
+ <>
+ {' - '}
+ <span style={{ color: frozen ? '#67707b' : 'inherit' }}>
+ {frozen && (
+ <>
+ <FaLock />{' '}
+ </>
+ )}
+ {version}
+ </span>
+ </>
+ )}
+ </div>
{hidden && (
<div
style={{
diff --git a/frontend/src/components/settings/pages/plugin_list/index.tsx b/frontend/src/components/settings/pages/plugin_list/index.tsx
index 09d06d48..d222664a 100644
--- a/frontend/src/components/settings/pages/plugin_list/index.tsx
+++ b/frontend/src/components/settings/pages/plugin_list/index.tsx
@@ -33,7 +33,16 @@ async function reinstallPlugin(pluginName: string, currentVersion?: string) {
}
}
-type PluginTableData = PluginData & { name: string; hidden: boolean; onHide(): void; onShow(): void };
+type PluginTableData = PluginData & {
+ name: string;
+ frozen: boolean;
+ onFreeze(): void;
+ onUnfreeze(): void;
+ hidden: boolean;
+ onHide(): void;
+ onShow(): void;
+ isDeveloper: boolean;
+};
function PluginInteractables(props: { entry: ReorderableEntry<PluginTableData> }) {
const { t } = useTranslation();
@@ -43,7 +52,7 @@ function PluginInteractables(props: { entry: ReorderableEntry<PluginTableData> }
return null;
}
- const { name, update, version, onHide, onShow, hidden } = props.entry.data;
+ const { name, update, version, onHide, onShow, hidden, onFreeze, onUnfreeze, frozen, isDeveloper } = props.entry.data;
const showCtxMenu = (e: MouseEvent | GamepadEvent) => {
showContextMenu(
@@ -84,6 +93,11 @@ function PluginInteractables(props: { entry: ReorderableEntry<PluginTableData> }
) : (
<MenuItem onSelected={onHide}>{t('PluginListIndex.hide')}</MenuItem>
)}
+ {frozen ? (
+ <MenuItem onSelected={onUnfreeze}>{t('PluginListIndex.unfreeze')}</MenuItem>
+ ) : (
+ isDeveloper && <MenuItem onSelected={onFreeze}>{t('PluginListIndex.freeze')}</MenuItem>
+ )}
</Menu>,
e.currentTarget ?? window,
);
@@ -138,8 +152,8 @@ type PluginData = {
version?: string;
};
-export default function PluginList() {
- const { plugins, updates, pluginOrder, setPluginOrder, hiddenPlugins } = useDeckyState();
+export default function PluginList({ isDeveloper }: { isDeveloper: boolean }) {
+ const { plugins, updates, pluginOrder, setPluginOrder, frozenPlugins, hiddenPlugins } = useDeckyState();
const [_, setPluginOrderSetting] = useSetting<string[]>(
'pluginOrder',
plugins.map((plugin) => plugin.name),
@@ -151,21 +165,27 @@ export default function PluginList() {
}, []);
const [pluginEntries, setPluginEntries] = useState<ReorderableEntry<PluginTableData>[]>([]);
+ const frozenPluginsService = window.DeckyPluginLoader.frozenPluginsService;
const hiddenPluginsService = window.DeckyPluginLoader.hiddenPluginsService;
useEffect(() => {
setPluginEntries(
plugins.map(({ name, version }) => {
+ const frozen = frozenPlugins.includes(name);
const hidden = hiddenPlugins.includes(name);
return {
- label: <PluginListLabel name={name} hidden={hidden} version={version} />,
+ label: <PluginListLabel name={name} frozen={frozen} hidden={hidden} version={version} />,
position: pluginOrder.indexOf(name),
data: {
name,
+ frozen,
hidden,
+ isDeveloper,
version,
update: updates?.get(name),
+ onFreeze: () => frozenPluginsService.update([...frozenPlugins, name]),
+ onUnfreeze: () => frozenPluginsService.update(frozenPlugins.filter((pluginName) => name !== pluginName)),
onHide: () => hiddenPluginsService.update([...hiddenPlugins, name]),
onShow: () => hiddenPluginsService.update(hiddenPlugins.filter((pluginName) => name !== pluginName)),
},