import {FieldGroupProps} from 'sentry/components/forms/field/types'; import SeparatorField from 'sentry/components/forms/fields/separatorField'; import {Field} from 'sentry/components/forms/types'; import {Scope} from 'sentry/types'; import BlankField from './fields/blankField'; import BooleanField, {BooleanFieldProps} from './fields/booleanField'; import ChoiceMapperField, {ChoiceMapperFieldProps} from './fields/choiceMapperField'; import DateTimeField, {DateTimeFieldProps} from './fields/dateTimeField'; import EmailField, {EmailFieldProps} from './fields/emailField'; import FileField, {FileFieldProps} from './fields/fileField'; import HiddenField, {HiddenFieldProps} from './fields/hiddenField'; import NumberField, {NumberFieldProps} from './fields/numberField'; import ProjectMapperField, {ProjectMapperProps} from './fields/projectMapperField'; import RadioField, {RadioFieldProps} from './fields/radioField'; import RangeField, {RangeFieldProps} from './fields/rangeField'; import SecretField, {SecretFieldProps} from './fields/secretField'; import SelectAsyncField, {SelectAsyncFieldProps} from './fields/selectAsyncField'; import SelectField, {SelectFieldProps} from './fields/selectField'; import SentryProjectSelectorField, { RenderFieldProps, } from './fields/sentryProjectSelectorField'; import TableField, {TableFieldProps} from './fields/tableField'; import TextareaField, {TextareaFieldProps} from './fields/textareaField'; import TextField, {TextFieldProps} from './fields/textField'; interface FieldFromConfigProps { field: Field; access?: Set; disabled?: boolean | ((props) => boolean); flexibleControlStateSize?: boolean; getData?: (data) => any; highlighted?: boolean; inline?: boolean; noOptionsMessage?: () => string; onBlur?: (value, event) => void; stacked?: boolean; } function FieldFromConfig(props: FieldFromConfigProps): React.ReactElement | null { const {field, ...otherProps} = props; const componentProps = { ...otherProps, ...field, }; switch (field.type) { case 'separator': return ; case 'secret': return ; case 'range': return ; case 'blank': return ; case 'bool': case 'boolean': return ; case 'email': return ; case 'hidden': return ; case 'string': case 'text': case 'url': if (componentProps.multiline) { return ; } return ; case 'number': return ; case 'textarea': return ; case 'choice': case 'select': case 'array': return )} />; case 'choice_mapper': return ; case 'radio': if (Array.isArray(componentProps.choices)) { return ; } throw new Error('Invalid `choices` type. Use an array of options'); case 'table': return ; case 'project_mapper': return ; case 'sentry_project_selector': return ; case 'select_async': return ; case 'file': return ; case 'datetime': return ; case 'custom': return field.Component(field); default: return null; } } export default FieldFromConfig;