details.tsx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import {RouteComponentProps} from 'react-router';
  2. import {addErrorMessage} from 'sentry/actionCreators/indicator';
  3. import Form from 'sentry/components/forms/form';
  4. import FormField from 'sentry/components/forms/formField';
  5. import JsonForm from 'sentry/components/forms/jsonForm';
  6. import {Panel, PanelBody, PanelHeader} from 'sentry/components/panels';
  7. import TextCopyInput from 'sentry/components/textCopyInput';
  8. import apiApplication from 'sentry/data/forms/apiApplication';
  9. import {t} from 'sentry/locale';
  10. import ConfigStore from 'sentry/stores/configStore';
  11. import {ApiApplication} from 'sentry/types';
  12. import getDynamicText from 'sentry/utils/getDynamicText';
  13. import AsyncView from 'sentry/views/asyncView';
  14. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  15. type Props = RouteComponentProps<{appId: string}, {}>;
  16. type State = {
  17. app: ApiApplication;
  18. } & AsyncView['state'];
  19. class ApiApplicationsDetails extends AsyncView<Props, State> {
  20. getEndpoints(): ReturnType<AsyncView['getEndpoints']> {
  21. return [['app', `/api-applications/${this.props.params.appId}/`]];
  22. }
  23. getTitle() {
  24. return t('Application Details');
  25. }
  26. renderBody() {
  27. const urlPrefix = ConfigStore.get('urlPrefix');
  28. return (
  29. <div>
  30. <SettingsPageHeader title={this.getTitle()} />
  31. <Form
  32. apiMethod="PUT"
  33. apiEndpoint={`/api-applications/${this.props.params.appId}/`}
  34. saveOnBlur
  35. allowUndo
  36. initialData={this.state.app}
  37. onSubmitError={() => addErrorMessage('Unable to save change')}
  38. >
  39. <JsonForm forms={apiApplication} />
  40. <Panel>
  41. <PanelHeader>{t('Credentials')}</PanelHeader>
  42. <PanelBody>
  43. <FormField name="clientID" label="Client ID">
  44. {({value}) => (
  45. <div>
  46. <TextCopyInput>
  47. {getDynamicText({value, fixed: 'CI_CLIENT_ID'})}
  48. </TextCopyInput>
  49. </div>
  50. )}
  51. </FormField>
  52. <FormField
  53. name="clientSecret"
  54. label="Client Secret"
  55. help={t(`Your secret is only available briefly after application creation. Make
  56. sure to save this value!`)}
  57. >
  58. {({value}) =>
  59. value ? (
  60. <TextCopyInput>
  61. {getDynamicText({value, fixed: 'CI_CLIENT_SECRET'})}
  62. </TextCopyInput>
  63. ) : (
  64. <em>hidden</em>
  65. )
  66. }
  67. </FormField>
  68. <FormField name="" label="Authorization URL">
  69. {() => <TextCopyInput>{`${urlPrefix}/oauth/authorize/`}</TextCopyInput>}
  70. </FormField>
  71. <FormField name="" label="Token URL">
  72. {() => <TextCopyInput>{`${urlPrefix}/oauth/token/`}</TextCopyInput>}
  73. </FormField>
  74. </PanelBody>
  75. </Panel>
  76. </Form>
  77. </div>
  78. );
  79. }
  80. }
  81. export default ApiApplicationsDetails;