resolveActions.tsx 1.6 KB

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