summaryrefslogtreecommitdiff
path: root/frontend/src/components/modals/PluginDisableModal.tsx
blob: 16ddd4bf044a077480ea9ab78e83b361af6a8c8a (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
import { ConfirmModal, Spinner } from '@decky/ui';
import { FC, useState } from 'react';

import { disablePlugin } from '../../plugin';

interface PluginDisableModalProps {
  name: string;
  title: string;
  buttonText: string;
  description: string;
  closeModal?(): void;
}

const PluginDisableModal: FC<PluginDisableModalProps> = ({ name, title, buttonText, description, closeModal }) => {
  const [disabling, setDisabling] = useState<boolean>(false);
  return (
    <ConfirmModal
      closeModal={closeModal}
      onOK={async () => {
        setDisabling(true);
        await disablePlugin(name);
        closeModal?.();
      }}
      bOKDisabled={disabling}
      bCancelDisabled={disabling}
      strTitle={
        <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', width: '100%' }}>
          {title}
          {disabling && <Spinner width="24px" height="24px" style={{ marginLeft: 'auto' }} />}
        </div>
      }
      strOKButtonText={buttonText}
    >
      {description}
    </ConfirmModal>
  );
};

export default PluginDisableModal;