summaryrefslogtreecommitdiff
path: root/frontend/src/components/modals/PluginInstallModal.tsx
blob: 2c0c0bba6f4b9cba505a11c75be511916c626d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { ModalRoot, QuickAccessTab, Router, Spinner, 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();
        setTimeout(() => Router.OpenQuickAccessMenu(QuickAccessTab.Decky), 250);
      }}
      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}
          {!loading && '?'}
        </div>
      </div>
    </ModalRoot>
  );
};

export default PluginInstallModal;