summaryrefslogtreecommitdiff
path: root/frontend/src/components/settings/pages/general/BranchSelect.tsx
blob: 91e814e52ceb043e39bb769b032569867c7a82b5 (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
import { Dropdown, Field } from 'decky-frontend-lib';
import { FunctionComponent } from 'react';

import { useSetting } from '../../../../utils/hooks/useSetting';

enum UpdateBranch {
  Stable,
  Prerelease,
  Nightly,
}

const BranchSelect: FunctionComponent<{}> = () => {
  const [selectedBranch, setSelectedBranch] = useSetting<UpdateBranch>('branch', UpdateBranch.Prerelease);

  return (
    <Field label="Update Channel">
      <Dropdown
        rgOptions={Object.values(UpdateBranch)
          .filter((branch) => typeof branch == 'string')
          .map((branch) => ({
            label: branch,
            data: UpdateBranch[branch],
          }))}
        selectedOption={selectedBranch}
        onChange={(newVal) => {
          setSelectedBranch(newVal.data);
        }}
      />
    </Field>
  );
};

export default BranchSelect;