({ option }: { option: SettingsOption })
| 588 | |
| 589 | |
| 590 | function EditOptionBooleanField({ option }: { option: SettingsOption }) { |
| 591 | const { value: rawValue, setValue, error } = useSettingsField(option.name) |
| 592 | const value = booleanValue(rawValue?.value, option) |
| 593 | |
| 594 | if (option.kind.kind !== "boolean") { |
| 595 | throw new Error("not a number field") |
| 596 | } |
| 597 | |
| 598 | return <Box mt={3}> |
| 599 | <Box> |
| 600 | <FormControlLabel |
| 601 | sx={{ marginRight: 0 }} |
| 602 | label={option.label} |
| 603 | control={<Checkbox checked={value} |
| 604 | onChange={(evt) => { |
| 605 | setValue(evt.target.checked) |
| 606 | }} |
| 607 | />} |
| 608 | /> |
| 609 | |
| 610 | {(Boolean(rawValue) && (option.defaultValue || !option.required)) && |
| 611 | <IconButton |
| 612 | color='warning' |
| 613 | onClick={() => { |
| 614 | setValue(null) |
| 615 | }} |
| 616 | > |
| 617 | <ReplayIcon /> |
| 618 | </IconButton>} |
| 619 | </Box> |
| 620 | |
| 621 | <FormHelperText error={Boolean(error)}> |
| 622 | <FieldHelpText description={option.description} error={error} /> |
| 623 | </FormHelperText> |
| 624 | </Box> |
| 625 | } |
| 626 | |
| 627 | |
| 628 | function EditOptionTextField({ option }: { option: SettingsOption }) { |
nothing calls this directly
no test coverage detected