resolveActions.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import ResolveActions from 'sentry/components/actions/resolve';
  2. import {Organization, Release} from 'sentry/types';
  3. import {ConfirmAction, getConfirm, getLabel} from './utils';
  4. type Props = {
  5. anySelected: boolean;
  6. onShouldConfirm: (action: ConfirmAction) => boolean;
  7. onUpdate: (data?: any) => void;
  8. orgSlug: Organization['slug'];
  9. params: {
  10. confirm: ReturnType<typeof getConfirm>;
  11. hasReleases: boolean;
  12. label: ReturnType<typeof getLabel>;
  13. disabled?: boolean;
  14. latestRelease?: Release;
  15. loadingProjects?: boolean;
  16. projectFetchError?: boolean;
  17. projectId?: string;
  18. };
  19. };
  20. function ResolveActionsContainer({
  21. params,
  22. orgSlug,
  23. anySelected,
  24. onShouldConfirm,
  25. onUpdate,
  26. }: Props) {
  27. const {
  28. hasReleases,
  29. latestRelease,
  30. projectId,
  31. confirm,
  32. label,
  33. loadingProjects,
  34. projectFetchError,
  35. } = params;
  36. // resolve requires a single project to be active in an org context
  37. // projectId is null when 0 or >1 projects are selected.
  38. const resolveDisabled = Boolean(!anySelected || projectFetchError);
  39. const resolveDropdownDisabled = Boolean(
  40. !anySelected || !projectId || loadingProjects || projectFetchError
  41. );
  42. return (
  43. <ResolveActions
  44. hasRelease={hasReleases}
  45. latestRelease={latestRelease}
  46. orgSlug={orgSlug}
  47. projectSlug={projectId}
  48. onUpdate={onUpdate}
  49. shouldConfirm={onShouldConfirm(ConfirmAction.RESOLVE)}
  50. confirmMessage={confirm({action: ConfirmAction.RESOLVE, canBeUndone: true})}
  51. confirmLabel={label('resolve')}
  52. disabled={resolveDisabled}
  53. disableDropdown={resolveDropdownDisabled}
  54. projectFetchError={projectFetchError}
  55. />
  56. );
  57. }
  58. export default ResolveActionsContainer;