import type {RouteComponentProps} from 'react-router'; import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator'; import ApiForm from 'sentry/components/forms/apiForm'; import MultipleCheckbox from 'sentry/components/forms/controls/multipleCheckbox'; import TextareaField from 'sentry/components/forms/fields/textareaField'; import TextField from 'sentry/components/forms/fields/textField'; import FormField from 'sentry/components/forms/formField'; import Panel from 'sentry/components/panels/panel'; import PanelBody from 'sentry/components/panels/panelBody'; import PanelHeader from 'sentry/components/panels/panelHeader'; import {API_ACCESS_SCOPES} from 'sentry/constants'; import {t} from 'sentry/locale'; import type {Organization} from 'sentry/types/organization'; import {browserHistory} from 'sentry/utils/browserHistory'; import recreateRoute from 'sentry/utils/recreateRoute'; import routeTitleGen from 'sentry/utils/routeTitle'; import withOrganization from 'sentry/utils/withOrganization'; import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView'; import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader'; import type {DeprecatedApiKey} from './types'; type RouteParams = { apiKey: string; }; type Props = RouteComponentProps & { organization: Organization; }; type State = DeprecatedAsyncView['state'] & { apiKey: DeprecatedApiKey; }; class OrganizationApiKeyDetails extends DeprecatedAsyncView { getEndpoints(): ReturnType { const {organization} = this.props; return [ [ 'apiKey', `/organizations/${organization.slug}/api-keys/${this.props.params.apiKey}/`, ], ]; } getTitle() { return routeTitleGen(t('Edit API Key'), this.props.organization.slug, false); } handleSubmitSuccess = () => { addSuccessMessage('Saved changes'); // Go back to API list browserHistory.push( recreateRoute('', { stepBack: -1, routes: this.props.routes, params: this.props.params, }) ); }; handleSubmitError = () => { addErrorMessage('Unable to save changes. Please try again.'); }; renderBody() { const {organization} = this.props; return (
{t('API Key')} browserHistory.push( recreateRoute('', { stepBack: -1, routes: this.props.routes, params: this.props.params, }) ) } > {({name, value, onChange}) => ( {API_ACCESS_SCOPES.map(scope => ( {scope} ))} )}
); } } export default withOrganization(OrganizationApiKeyDetails);