import {Fragment} from 'react'; import {RouteComponentProps} from 'react-router'; import styled from '@emotion/styled'; import {addErrorMessage} from 'sentry/actionCreators/indicator'; import {openModal} from 'sentry/actionCreators/modal'; import Button from 'sentry/components/actions/button'; import {Alert} from 'sentry/components/alert'; import Form from 'sentry/components/forms/form'; import FormField from 'sentry/components/forms/formField'; import JsonForm from 'sentry/components/forms/jsonForm'; import Panel from 'sentry/components/panels/panel'; import PanelBody from 'sentry/components/panels/panelBody'; import PanelHeader from 'sentry/components/panels/panelHeader'; import TextCopyInput from 'sentry/components/textCopyInput'; import apiApplication from 'sentry/data/forms/apiApplication'; import {t} from 'sentry/locale'; import ConfigStore from 'sentry/stores/configStore'; import {ApiApplication} from 'sentry/types'; import getDynamicText from 'sentry/utils/getDynamicText'; import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView'; import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader'; type Props = RouteComponentProps<{appId: string}, {}>; type State = { app: ApiApplication; } & DeprecatedAsyncView['state']; class ApiApplicationsDetails extends DeprecatedAsyncView { rotateClientSecret = async () => { try { const rotateResponse = await this.api.requestPromise( `/api-applications/${this.props.params.appId}/rotate-secret/`, { method: 'POST', } ); openModal(({Body, Header}) => (
{t('Rotated Client Secret')}
{t('This will be the only time your client secret is visible!')}

{t('Your client secret is:')} {rotateResponse.clientSecret}

)); } catch { addErrorMessage(t('Error rotating secret')); } }; getEndpoints(): ReturnType { return [['app', `/api-applications/${this.props.params.appId}/`]]; } getTitle() { return t('Application Details'); } renderBody() { const urlPrefix = ConfigStore.get('urlPrefix'); return (
addErrorMessage('Unable to save change')} > {t('Credentials')} {({value}) => (
{getDynamicText({value, fixed: 'CI_CLIENT_ID'})}
)}
{({value}) => value ? ( {getDynamicText({value, fixed: 'CI_CLIENT_SECRET'})} ) : ( {t('hidden')} ) } {() => {`${urlPrefix}/oauth/authorize/`}} {() => {`${urlPrefix}/oauth/token/`}}
); } } const HiddenSecret = styled('span')` width: 100px; font-style: italic; `; const ClientSecret = styled('div')` display: flex; justify-content: right; align-items: center; margin-right: 0; `; export default ApiApplicationsDetails;