resolveActions.tsx 1.6 KB

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