import {Component, Fragment} from 'react'; import {RouteComponentProps} from 'react-router'; import { addErrorMessage, addLoadingMessage, addSuccessMessage, } from 'sentry/actionCreators/indicator'; import {Client} from 'sentry/api'; import Access from 'sentry/components/acl/access'; import Button from 'sentry/components/button'; import Confirm from 'sentry/components/confirm'; import DateTime from 'sentry/components/dateTime'; import Field from 'sentry/components/forms/field'; import BooleanField from 'sentry/components/forms/fields/booleanField'; import SelectField from 'sentry/components/forms/fields/selectField'; import TextField from 'sentry/components/forms/fields/textField'; import Form from 'sentry/components/forms/form'; import ExternalLink from 'sentry/components/links/externalLink'; import {Panel, PanelAlert, PanelBody, PanelHeader} from 'sentry/components/panels'; import TextCopyInput from 'sentry/components/textCopyInput'; import {t, tct} from 'sentry/locale'; import getDynamicText from 'sentry/utils/getDynamicText'; import KeyRateLimitsForm from 'sentry/views/settings/project/projectKeys/details/keyRateLimitsForm'; import ProjectKeyCredentials from 'sentry/views/settings/project/projectKeys/projectKeyCredentials'; import {ProjectKey} from 'sentry/views/settings/project/projectKeys/types'; type Props = { api: Client; data: ProjectKey; onRemove: () => void; } & Pick< RouteComponentProps< { keyId: string; orgId: string; projectId: string; }, {} >, 'params' >; type State = { error: boolean; loading: boolean; }; class KeySettings extends Component { state: State = { loading: false, error: false, }; handleRemove = async () => { if (this.state.loading) { return; } addLoadingMessage(t('Revoking key\u2026')); const {api, onRemove, params} = this.props; const {keyId, orgId, projectId} = params; try { await api.requestPromise(`/projects/${orgId}/${projectId}/keys/${keyId}/`, { method: 'DELETE', }); onRemove(); addSuccessMessage(t('Revoked key')); } catch (_err) { this.setState({ error: true, loading: false, }); addErrorMessage(t('Unable to revoke key')); } }; render() { const {keyId, orgId, projectId} = this.props.params; const {data} = this.props; const apiEndpoint = `/projects/${orgId}/${projectId}/keys/${keyId}/`; const loaderLink = getDynamicText({ value: data.dsn.cdn, fixed: '__JS_SDK_LOADER_URL__', }); return ( {({hasAccess}) => (
{t('Details')}
{t('JavaScript Loader')} What does the script provide? ), } )} inline={false} flexibleControlStateSize > {``} ({ value, label, })) : [] } placeholder={t('4.x')} allowClear={false} disabled={!hasAccess} help={t( 'Select the version of the SDK that should be loaded. Note that it can take a few minutes until this change is live.' )} />
{t('Credentials')} {t( 'Your credentials are coupled to a public and secret key. Different clients will require different credentials, so make sure you check the documentation before plugging things in.' )} {t('Revoke Key')}
)}
); } } export default KeySettings;