project.tsx 790 B

1234567891011121314151617181920212223242526272829
  1. import {addErrorMessage} from 'sentry/actionCreators/indicator';
  2. import {Client} from 'sentry/api';
  3. import {t} from 'sentry/locale';
  4. import ProjectsStore from 'sentry/stores/projectsStore';
  5. import {Project} from 'sentry/types';
  6. import handleXhrErrorResponse from 'sentry/utils/handleXhrErrorResponse';
  7. /**
  8. * Fetches a project's details
  9. */
  10. export function fetchProjectDetails({
  11. api,
  12. orgSlug,
  13. projSlug,
  14. }: {
  15. api: Client;
  16. orgSlug: string;
  17. projSlug: string;
  18. }): Promise<Project> {
  19. const promise = api.requestPromise(`/projects/${orgSlug}/${projSlug}/`);
  20. promise.then(ProjectsStore.onUpdateSuccess).catch(error => {
  21. const message = t('Unable to fetch project details');
  22. handleXhrErrorResponse(message)(error);
  23. addErrorMessage(message);
  24. });
  25. return promise;
  26. }