Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(ui) Update more deprecated forms including ones in manage #28991

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions static/app/views/admin/adminSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import isUndefined from 'lodash/isUndefined';

import {ApiForm} from 'app/components/forms';
import {Panel, PanelHeader} from 'app/components/panels';
import {t} from 'app/locale';
import AsyncView from 'app/views/asyncView';
import {Form} from 'app/views/settings/components/forms';

import {getOption, getOptionField} from './options';

Expand Down Expand Up @@ -61,29 +62,34 @@ export default class AdminSettings extends AsyncView<{}, State> {
<div>
<h3>{t('Settings')}</h3>

<ApiForm
<Form
apiMethod="PUT"
apiEndpoint={this.endpoint}
initialData={initialData}
omitDisabled
requireChanges
saveOnBlur
>
<h4>General</h4>
{fields['system.url-prefix']}
{fields['system.admin-email']}
{fields['system.support-email']}
{fields['system.security-email']}
{fields['system.rate-limit']}
<Panel>
<PanelHeader>General</PanelHeader>
{fields['system.url-prefix']}
{fields['system.admin-email']}
{fields['system.support-email']}
{fields['system.security-email']}
{fields['system.rate-limit']}
</Panel>

<h4>Security & Abuse</h4>
{fields['auth.allow-registration']}
{fields['auth.ip-rate-limit']}
{fields['auth.user-rate-limit']}
{fields['api.rate-limit.org-create']}
<Panel>
<PanelHeader>Security & Abuse</PanelHeader>
{fields['auth.allow-registration']}
{fields['auth.ip-rate-limit']}
{fields['auth.user-rate-limit']}
{fields['api.rate-limit.org-create']}
</Panel>

<h4>Beacon</h4>
{fields['beacon.anonymous']}
</ApiForm>
<Panel>
<PanelHeader>Beacon</PanelHeader>
{fields['beacon.anonymous']}
</Panel>
</Form>
</div>
);
}
Expand Down
11 changes: 6 additions & 5 deletions static/app/views/admin/options.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from 'react';
import keyBy from 'lodash/keyBy';

import {t, tct} from 'app/locale';
import ConfigStore from 'app/stores/configStore';
import {
BooleanField,
EmailField,
RadioBooleanField,
TextField,
} from 'app/components/forms';
import {t, tct} from 'app/locale';
import ConfigStore from 'app/stores/configStore';
} from 'app/views/settings/components/forms';

type Section = {
key: string;
Expand All @@ -26,6 +26,7 @@ type Field = {
required?: boolean;
allowEmpty?: boolean;
disabledReason?: string;
disabled?: boolean;
defaultValue?: () => string | false;
component?: React.ComponentType<any>;
};
Expand Down Expand Up @@ -194,11 +195,11 @@ const disabledReasons = {
smtpDisabled: 'SMTP mail has been disabled, so this option is unavailable',
};

export function getOption(option: string) {
export function getOption(option: string): Field {
return definitionsMap[option];
}

export function getOptionDefault(option: string) {
export function getOptionDefault(option: string): string | false | undefined {
const meta = getOption(option);
return meta.defaultValue ? meta.defaultValue() : undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/issueList/testSessionPercent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as qs from 'query-string';
import {Client} from 'app/api';
import Feature from 'app/components/acl/feature';
import FeatureDisabled from 'app/components/acl/featureDisabled';
import Input from 'app/components/forms/input';
import * as Layout from 'app/components/layouts/thirds';
import Link from 'app/components/links/link';
import {t, tn} from 'app/locale';
Expand All @@ -23,6 +22,7 @@ import EventView from 'app/utils/discover/eventView';
import withApi from 'app/utils/withApi';
import withGlobalSelection from 'app/utils/withGlobalSelection';
import withOrganization from 'app/utils/withOrganization';
import Input from 'app/views/settings/components/forms/controls/input';

type Props = {
selection: GlobalSelection;
Expand Down