({ option }: { option: SettingsOption })
| 626 | |
| 627 | |
| 628 | function EditOptionTextField({ option }: { option: SettingsOption }) { |
| 629 | if (option.kind.kind !== "string") { |
| 630 | throw new Error("not a string field") |
| 631 | } |
| 632 | |
| 633 | const { value: rawValue, setValue, error } = useSettingsField(option.name) |
| 634 | const value = textFieldValue(rawValue?.value, option) |
| 635 | |
| 636 | return <Box mt={3}> |
| 637 | <TextField |
| 638 | id={"script-option-" + option.name} |
| 639 | label={option.label} |
| 640 | // defaultValue="Default Value" |
| 641 | type={"text"} |
| 642 | inputProps={{ |
| 643 | maxLength: option.kind.max_length, |
| 644 | minLength: option.kind.min_length, |
| 645 | }} |
| 646 | helperText={<FieldHelpText description={option.description} error={error} />} |
| 647 | onChange={(evt) => { |
| 648 | setValue(evt.target.value) |
| 649 | }} |
| 650 | value={value} |
| 651 | error={Boolean(error)} |
| 652 | /> |
| 653 | {(Boolean(rawValue) && (option.defaultValue || !option.required)) && |
| 654 | <IconButton |
| 655 | color='warning' |
| 656 | onClick={() => setValue(null)} |
| 657 | > |
| 658 | <ReplayIcon /> |
| 659 | </IconButton>} |
| 660 | </Box> |
| 661 | } |
| 662 | |
| 663 | function EditOptionSelect({ option }: { option: SettingsOption }) { |
| 664 | console.assert(option.kind.kind === "channel" |
nothing calls this directly
no test coverage detected