import {Form} from 'sentry/components/forms'; import {Panel, PanelHeader} from 'sentry/components/panels'; import {t} from 'sentry/locale'; import AsyncView from 'sentry/views/asyncView'; import {getOption, getOptionField} from './options'; const optionsAvailable = [ 'system.url-prefix', 'system.admin-email', 'system.support-email', 'system.security-email', 'system.rate-limit', 'auth.allow-registration', 'auth.ip-rate-limit', 'auth.user-rate-limit', 'api.rate-limit.org-create', 'beacon.anonymous', ]; type Field = ReturnType; type FieldDef = { field: Field; value: string | undefined; }; type State = AsyncView['state'] & { data: Record; }; export default class AdminSettings extends AsyncView<{}, State> { get endpoint() { return '/internal/options/'; } getEndpoints(): ReturnType { return [['data', this.endpoint]]; } renderBody() { const {data} = this.state; const initialData = {}; const fields = {}; for (const key of optionsAvailable) { // TODO(dcramer): we should not be mutating options const option = data[key] ?? {field: {}, value: undefined}; if (option.value === undefined || option.value === '') { const defn = getOption(key); initialData[key] = defn.defaultValue ? defn.defaultValue() : ''; } else { initialData[key] = option.value; } fields[key] = getOptionField(key, option.field); } return (

{t('Settings')}

General {fields['system.url-prefix']} {fields['system.admin-email']} {fields['system.support-email']} {fields['system.security-email']} {fields['system.rate-limit']} Security & Abuse {fields['auth.allow-registration']} {fields['auth.ip-rate-limit']} {fields['auth.user-rate-limit']} {fields['api.rate-limit.org-create']} Beacon {fields['beacon.anonymous']}
); } }