({ option }: { option: SettingsOption })
| 758 | } |
| 759 | |
| 760 | function EditOptionSelectMultiple({ option }: { option: SettingsOption }) { |
| 761 | const { value: rawValue, setValue, error } = useSettingsField(option.name) |
| 762 | |
| 763 | const defaultValue = option.defaultValue ?? [] |
| 764 | const value = rawValue?.value |
| 765 | ? Array.isArray(rawValue?.value) |
| 766 | ? rawValue.value |
| 767 | : defaultValue |
| 768 | : defaultValue |
| 769 | |
| 770 | if (option.kind.kind === "channels") { |
| 771 | return <SelectChannel |
| 772 | multiple={true} |
| 773 | value={value} |
| 774 | label={option.label} |
| 775 | error={error} |
| 776 | onChange={(newValue) => { |
| 777 | setValue(newValue) |
| 778 | }} |
| 779 | /> |
| 780 | } else if (option.kind.kind === "roles") { |
| 781 | return <SelectRole |
| 782 | multiple={true} |
| 783 | value={value} |
| 784 | label={option.name} |
| 785 | error={error} |
| 786 | onChange={(newValue) => { |
| 787 | setValue(newValue) |
| 788 | }} |
| 789 | /> |
| 790 | } else if (option.kind.kind === "customStringMultiSelect") { |
| 791 | return <SelectCustom |
| 792 | multiple={true} |
| 793 | value={value} |
| 794 | label={option.label} |
| 795 | error={error} |
| 796 | onChange={(newValue) => { |
| 797 | setValue(newValue ?? null) |
| 798 | }} |
| 799 | options={option.kind.options} |
| 800 | /> |
| 801 | } else if (option.kind.kind === "customNumberMultiSelect") { |
| 802 | return <SelectCustom |
| 803 | multiple={true} |
| 804 | value={value} |
| 805 | label={option.label} |
| 806 | error={error} |
| 807 | onChange={(newValue) => { |
| 808 | setValue(newValue ?? null) |
| 809 | }} |
| 810 | options={option.kind.options} |
| 811 | /> |
| 812 | } else { |
| 813 | return <>TODO unsupported kind {option.kind.kind}</> |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | function FieldHelpText({ description, error }: { description: string, error?: string }) { |
nothing calls this directly
no test coverage detected