From d72f364a8d032ca53c35c22c8dbe01ba354629df Mon Sep 17 00:00:00 2001 From: AAGaming Date: Thu, 30 Jun 2022 16:04:29 -0400 Subject: backwards-compatible plugin store, legacy plugin library --- frontend/src/components/store/PluginCard.tsx | 73 ++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 14 deletions(-) (limited to 'frontend/src/components/store/PluginCard.tsx') diff --git a/frontend/src/components/store/PluginCard.tsx b/frontend/src/components/store/PluginCard.tsx index 20ffead6..e99d95d0 100644 --- a/frontend/src/components/store/PluginCard.tsx +++ b/frontend/src/components/store/PluginCard.tsx @@ -10,16 +10,26 @@ import { } from 'decky-frontend-lib'; import { FC, useRef, useState } from 'react'; -import { StorePlugin, StorePluginVersion, requestPluginInstall } from './Store'; +import { + LegacyStorePlugin, + StorePlugin, + StorePluginVersion, + requestLegacyPluginInstall, + requestPluginInstall, +} from './Store'; interface PluginCardProps { - plugin: StorePlugin; + plugin: StorePlugin | LegacyStorePlugin; } const classNames = (...classes: string[]) => { return classes.join(' '); }; +function isLegacyPlugin(plugin: LegacyStorePlugin | StorePlugin): plugin is LegacyStorePlugin { + return 'artifact' in plugin; +} + const PluginCard: FC = ({ plugin }) => { const [selectedOption, setSelectedOption] = useState(0); const buttonRef = useRef(null); @@ -36,10 +46,10 @@ const PluginCard: FC = ({ plugin }) => { { + onActivate={(_: CustomEvent) => { buttonRef.current!.focus(); }} - onCancel={(e: CustomEvent) => { + onCancel={(_: CustomEvent) => { if (containerRef.current!.querySelectorAll('* :focus').length === 0) { Router.NavigateBackOrOpenMenu(); setTimeout(() => Router.OpenQuickAccessMenu(QuickAccessTab.Decky), 1000); @@ -64,7 +74,14 @@ const PluginCard: FC = ({ plugin }) => { className={classNames(staticClasses.Text)} // onClick={() => Router.NavigateToExternalWeb('https://github.com/' + plugin.artifact)} > - {plugin.name} + {isLegacyPlugin(plugin) ? ( +
+ {plugin.artifact.split('/')[0]}/ + {plugin.artifact.split('/')[1]} +
+ ) : ( + plugin.name + )}
= ({ plugin }) => { width: 'auto', height: '160px', }} - src={`https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/artifact_images/${plugin.name.replace( - '/', - '_', - )}.png`} + src={ + isLegacyPlugin(plugin) + ? `https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/artifact_images/${plugin.artifact.replace( + '/', + '_', + )}.png` + : `https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/artifact_images/${plugin.name.replace( + '/', + '_', + )}.png` + } />
= ({ plugin }) => { {tag == 'root' ? 'Requires root' : tag} ))} + {isLegacyPlugin(plugin) && ( + + legacy + + )}

@@ -132,7 +168,11 @@ const PluginCard: FC = ({ plugin }) => { > requestPluginInstall(plugin, plugin.versions[selectedOption])} + onClick={() => + isLegacyPlugin(plugin) + ? requestLegacyPluginInstall(plugin, Object.keys(plugin.versions)[selectedOption]) + : requestPluginInstall(plugin, plugin.versions[selectedOption]) + } > Install @@ -144,10 +184,15 @@ const PluginCard: FC = ({ plugin }) => { > ({ - data: index, - label: version.name, - })) as SingleDropdownOption[] + (isLegacyPlugin(plugin) + ? Object.keys(plugin.versions).map((v, k) => ({ + data: k, + label: v, + })) + : plugin.versions.map((version: StorePluginVersion, index) => ({ + data: index, + label: version.name, + }))) as SingleDropdownOption[] } strDefaultLabel={'Select a version'} selectedOption={selectedOption} -- cgit v1.2.3