details.tsx 3.2 KB

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