import {Component} from 'react'; import styled from '@emotion/styled'; import { addErrorMessage, addLoadingMessage, clearIndicators, } from 'sentry/actionCreators/indicator'; import {Client} from 'sentry/api'; import {Button} from 'sentry/components/button'; import Link from 'sentry/components/links/link'; import PanelItem from 'sentry/components/panels/panelItem'; import {IconDelete} from 'sentry/icons'; import {t} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import {ApiApplication} from 'sentry/types'; import getDynamicText from 'sentry/utils/getDynamicText'; const ROUTE_PREFIX = '/settings/account/api/'; type Props = { api: Client; app: ApiApplication; onRemove: (app: ApiApplication) => void; }; type State = { loading: boolean; }; class Row extends Component { state: State = { loading: false, }; handleRemove = () => { if (this.state.loading) { return; } const {api, app, onRemove} = this.props; this.setState( { loading: true, }, async () => { addLoadingMessage(); try { await api.requestPromise(`/api-applications/${app.id}/`, { method: 'DELETE', }); clearIndicators(); onRemove(app); } catch (_err) { addErrorMessage(t('Unable to remove application. Please try again.')); } } ); }; render() { const {app} = this.props; return ( {getDynamicText({value: app.name, fixed: 'CI_APPLICATION_NAME'})} {getDynamicText({value: app.clientID, fixed: 'CI_CLIENT_ID'})}