resolveActions.tsx 1.7 KB

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