index.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {browserHistory, RouteComponentProps} from 'react-router';
  2. import {t} from 'sentry/locale';
  3. import {Organization, Project} from 'sentry/types';
  4. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  5. import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
  6. import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
  7. import PermissionAlert from 'sentry/views/settings/project/permissionAlert';
  8. import {KeySettings} from 'sentry/views/settings/project/projectKeys/details/keySettings';
  9. import KeyStats from 'sentry/views/settings/project/projectKeys/details/keyStats';
  10. import {ProjectKey} from 'sentry/views/settings/project/projectKeys/types';
  11. type Props = {
  12. organization: Organization;
  13. project: Project;
  14. } & RouteComponentProps<
  15. {
  16. keyId: string;
  17. projectId: string;
  18. },
  19. {}
  20. >;
  21. type State = {
  22. data: ProjectKey;
  23. } & DeprecatedAsyncView['state'];
  24. export default class ProjectKeyDetails extends DeprecatedAsyncView<Props, State> {
  25. getTitle() {
  26. return t('Key Details');
  27. }
  28. getEndpoints(): ReturnType<DeprecatedAsyncView['getEndpoints']> {
  29. const {organization} = this.props;
  30. const {keyId, projectId} = this.props.params;
  31. return [['data', `/projects/${organization.slug}/${projectId}/keys/${keyId}/`]];
  32. }
  33. handleRemove = () => {
  34. const {organization} = this.props;
  35. const {projectId} = this.props.params;
  36. browserHistory.push(
  37. normalizeUrl(`/settings/${organization.slug}/projects/${projectId}/keys/`)
  38. );
  39. };
  40. updateData = (data: ProjectKey) => {
  41. this.setState(state => {
  42. return {...state, data};
  43. });
  44. };
  45. renderBody() {
  46. const {organization, project, params} = this.props;
  47. const {data} = this.state;
  48. return (
  49. <div data-test-id="key-details">
  50. <SettingsPageHeader title={t('Key Details')} />
  51. <PermissionAlert project={project} />
  52. <KeyStats api={this.api} organization={organization} params={params} />
  53. <KeySettings
  54. data={data}
  55. updateData={this.updateData}
  56. onRemove={this.handleRemove}
  57. organization={organization}
  58. project={project}
  59. params={params}
  60. />
  61. </div>
  62. );
  63. }
  64. }