import type {RouteComponentProps} from 'react-router'; import FieldGroup from 'sentry/components/forms/fieldGroup'; import RangeField from 'sentry/components/forms/fields/rangeField'; import Form from 'sentry/components/forms/form'; import Panel from 'sentry/components/panels/panel'; import PanelAlert from 'sentry/components/panels/panelAlert'; import PanelBody from 'sentry/components/panels/panelBody'; import PanelHeader from 'sentry/components/panels/panelHeader'; import {t, tct} from 'sentry/locale'; import type {Organization} from 'sentry/types'; import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader'; import TextBlock from 'sentry/views/settings/components/text/textBlock'; export type OrganizationRateLimitProps = RouteComponentProps<{}, {}> & { organization: Organization; }; const getRateLimitValues = () => { const steps: number[] = []; let i = 0; while (i <= 1_000_000) { steps.push(i); if (i < 10_000) { i += 1_000; } else if (i < 100_000) { i += 10_000; } else { i += 100_000; } } return steps; }; // We can just generate this once const ACCOUNT_RATE_LIMIT_VALUES = getRateLimitValues(); function OrganizationRateLimit({organization}: OrganizationRateLimitProps) { // TODO(billy): Update organization.quota in organizationStore with new values const {quota} = organization; const {maxRate, maxRateInterval, projectLimit, accountLimit} = quota; const initialData = { projectRateLimit: projectLimit || 100, accountRateLimit: accountLimit, }; return (
{t('Adjust Limits')} {t(`Rate limits allow you to control how much data is stored for this organization. When a rate is exceeded the system will begin discarding data until the next interval.`)}
{!maxRate ? ( !value ? t('No Limit') : tct('[number] per hour', { number: value.toLocaleString(), }) } /> ) : ( {tct( 'Your account is limited to a maximum of [maxRate] events per [maxRateInterval] seconds.', { maxRate, maxRateInterval, } )} )} value !== 100 ? `${value}%` : t('No Limit \u2014 100%') } />
); } export default OrganizationRateLimit;