resolveActions.tsx 1.8 KB

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