diff options
| author | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2026-09-11 12:58:16 -0400 |
|---|---|---|
| committer | xXJSONDeruloXx <danielhimebauch@gmail.com> | 2026-09-11 12:58:16 -0400 |
| commit | 4d14bc1086a1ba05acd01d7466749ff3cffba75f (patch) | |
| tree | 3a4e29c48f2e64bf94a5c52fd51dddcb9687cec0 /src/components/FlatpakTab.tsx | |
| parent | c7ca9c7ec2660d279f5e6957ef882390a8783667 (diff) | |
| download | decky-lsfg-vk-4d14bc1086a1ba05acd01d7466749ff3cffba75f.tar.gz decky-lsfg-vk-4d14bc1086a1ba05acd01d7466749ff3cffba75f.zip | |
enable all and disable all for flatpak
Diffstat (limited to 'src/components/FlatpakTab.tsx')
| -rw-r--r-- | src/components/FlatpakTab.tsx | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/components/FlatpakTab.tsx b/src/components/FlatpakTab.tsx index 0b20da0..35721f6 100644 --- a/src/components/FlatpakTab.tsx +++ b/src/components/FlatpakTab.tsx @@ -1,4 +1,4 @@ -import { ButtonItem, DialogButton, Field, Focusable, PanelSection, PanelSectionRow, gamepadDialogClasses } from "@decky/ui"; +import { ButtonItem, ConfirmModal, DialogButton, Field, Focusable, PanelSection, PanelSectionRow, gamepadDialogClasses, showModal } from "@decky/ui"; import { useCallback, useMemo, useState } from "react"; import { FaArrowLeft } from "react-icons/fa"; import type { FlatpakApp, LsfgConfig, WorkaroundState } from "../api/lsfgApi"; @@ -15,7 +15,9 @@ interface Props { busyAppId: string; onRefresh: () => Promise<void>; onEnable: (appId: string) => Promise<boolean>; + onEnableAll: () => Promise<void>; onRemove: (appId: string) => Promise<boolean>; + onRemoveAll: () => Promise<void>; onConfigChange: (appId: string, config: LsfgConfig) => Promise<boolean>; onWorkaroundChange: (appId: string, state: WorkaroundState) => Promise<boolean>; } @@ -30,7 +32,9 @@ export function FlatpakTab({ busyAppId, onRefresh, onEnable, + onEnableAll, onRemove, + onRemoveAll, onConfigChange, onWorkaroundChange, }: Props) { @@ -51,6 +55,33 @@ export function FlatpakTab({ () => apps.filter((app) => !app.enabled).sort((a, b) => a.app_name.localeCompare(b.app_name)), [apps], ); + const enableableApps = useMemo( + () => availableApps.filter((app) => !(app.prepared && !app.owned) && !app.error), + [availableApps], + ); + const confirmEnableAll = () => { + showModal( + <ConfirmModal + strTitle="Enable all available Flatpaks?" + strDescription="Create individual LSFG-VK profiles for every Flatpak app this plugin can manage. Apps prepared externally or unavailable will be skipped." + strOKButtonText="Enable all" + strCancelButtonText="Cancel" + onOK={() => void onEnableAll()} + onCancel={() => {}} + />, + ); + }; + const confirmRemoveAll = () => { + showModal( + <ConfirmModal + strTitle="Remove all Flatpak profiles?" + strOKButtonText="Remove all" + strCancelButtonText="Cancel" + onOK={() => void onRemoveAll()} + onCancel={() => {}} + />, + ); + }; const itemFor = (app: FlatpakApp) => ({ id: app.app_id, label: app.app_name, @@ -79,6 +110,26 @@ export function FlatpakTab({ onToggle={toggleAvailable} onSelect={setSelectedAppId} /> + {enableableApps.length > 0 && ( + <PanelSectionRow> + <ButtonItem + layout="below" + disabled={loading || Boolean(busyAppId)} + onClick={confirmEnableAll} + > + Enable all available Flatpaks + </ButtonItem> + </PanelSectionRow> + )} + <PanelSectionRow> + <ButtonItem + layout="below" + disabled={loading || Boolean(busyAppId) || enabledApps.length === 0} + onClick={confirmRemoveAll} + > + Remove all profiles + </ButtonItem> + </PanelSectionRow> {apps.length === 0 && !loading && ( <PanelSectionRow> <Field label="No Flatpak applications found" /> |
