assigneeSelector.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {useEffect} from 'react';
  2. import {fetchOrgMembers} from 'sentry/actionCreators/members';
  3. import {getOwnerList} from 'sentry/components/group/assignedTo';
  4. import {
  5. AssigneeSelector,
  6. useHandleAssigneeChange,
  7. } from 'sentry/components/group/assigneeSelector';
  8. import type {Event} from 'sentry/types/event';
  9. import type {Group} from 'sentry/types/group';
  10. import type {Project} from 'sentry/types/project';
  11. import useApi from 'sentry/utils/useApi';
  12. import useCommitters from 'sentry/utils/useCommitters';
  13. import {useIssueEventOwners} from 'sentry/utils/useIssueEventOwners';
  14. import useOrganization from 'sentry/utils/useOrganization';
  15. interface GroupHeaderAssigneeSelectorProps {
  16. event: Event | null;
  17. group: Group;
  18. project: Project;
  19. }
  20. export function GroupHeaderAssigneeSelector({
  21. group,
  22. project,
  23. event,
  24. }: GroupHeaderAssigneeSelectorProps) {
  25. const api = useApi();
  26. const organization = useOrganization();
  27. const {handleAssigneeChange, assigneeLoading} = useHandleAssigneeChange({
  28. organization,
  29. group,
  30. });
  31. const {data: eventOwners} = useIssueEventOwners({
  32. eventId: event?.id ?? '',
  33. projectSlug: project.slug,
  34. });
  35. const {data: committersResponse} = useCommitters({
  36. eventId: event?.id ?? '',
  37. projectSlug: project.slug,
  38. group,
  39. });
  40. useEffect(() => {
  41. // TODO: We should check if this is already loaded
  42. fetchOrgMembers(api, organization.slug, [project.id]);
  43. }, [api, organization, project]);
  44. const owners = getOwnerList(
  45. committersResponse?.committers ?? [],
  46. eventOwners,
  47. group.assignedTo
  48. );
  49. return (
  50. <AssigneeSelector
  51. group={group}
  52. owners={owners}
  53. assigneeLoading={assigneeLoading}
  54. handleAssigneeChange={handleAssigneeChange}
  55. />
  56. );
  57. }