From afb2c7c0ed1ef9ccad6b5a6764cdbc5c103563a8 Mon Sep 17 00:00:00 2001
From: AAGaming <aa@mail.catvibers.me>
Date: Mon, 25 Jul 2022 17:13:50 -0400
Subject: Better install process UX, fix reinstalling

---
 .../src/components/modals/PluginInstallModal.tsx   | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 frontend/src/components/modals/PluginInstallModal.tsx

(limited to 'frontend/src/components/modals/PluginInstallModal.tsx')

diff --git a/frontend/src/components/modals/PluginInstallModal.tsx b/frontend/src/components/modals/PluginInstallModal.tsx
new file mode 100644
index 00000000..992ce748
--- /dev/null
+++ b/frontend/src/components/modals/PluginInstallModal.tsx
@@ -0,0 +1,42 @@
+import { ModalRoot, QuickAccessTab, Router, Spinner, sleep, staticClasses } from 'decky-frontend-lib';
+import { FC, useState } from 'react';
+
+interface PluginInstallModalProps {
+  artifact: string;
+  version: string;
+  hash: string;
+  // reinstall: boolean;
+  onOK(): void;
+  onCancel(): void;
+  closeModal?(): void;
+}
+
+const PluginInstallModal: FC<PluginInstallModalProps> = ({ artifact, version, hash, onOK, onCancel, closeModal }) => {
+  const [loading, setLoading] = useState<boolean>(false);
+  return (
+    <ModalRoot
+      bOKDisabled={loading}
+      closeModal={closeModal}
+      onOK={async () => {
+        setLoading(true);
+        await onOK();
+        Router.NavigateBackOrOpenMenu();
+        await sleep(250);
+        setTimeout(() => Router.OpenQuickAccessMenu(QuickAccessTab.Decky), 1000);
+      }}
+      onCancel={async () => {
+        await onCancel();
+      }}
+    >
+      <div className={staticClasses.Title} style={{ flexDirection: 'column' }}>
+        {hash == 'False' ? <h3 style={{ color: 'red' }}>!!!!NO HASH PROVIDED!!!!</h3> : null}
+        <div style={{ flexDirection: 'row' }}>
+          {loading && <Spinner style={{ width: '20px' }} />} {loading ? 'Installing' : 'Install'} {artifact}
+          {version ? ' version ' + version : null}?
+        </div>
+      </div>
+    </ModalRoot>
+  );
+};
+
+export default PluginInstallModal;
-- 
cgit v1.2.3

