groupPriority.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {bulkUpdate} from 'sentry/actionCreators/group';
  2. import {addLoadingMessage, clearIndicators} from 'sentry/actionCreators/indicator';
  3. import {GroupPriorityDropdown} from 'sentry/components/group/groupPriority';
  4. import {t} from 'sentry/locale';
  5. import IssueListCacheStore from 'sentry/stores/IssueListCacheStore';
  6. import {type Group, PriorityLevel} from 'sentry/types';
  7. import {trackAnalytics} from 'sentry/utils/analytics';
  8. import {getAnalyticsDataForGroup} from 'sentry/utils/events';
  9. import useApi from 'sentry/utils/useApi';
  10. import useOrganization from 'sentry/utils/useOrganization';
  11. type GroupDetailsPriorityProps = {
  12. group: Group;
  13. };
  14. function GroupPriority({group}: GroupDetailsPriorityProps) {
  15. const api = useApi({persistInFlight: true});
  16. const organization = useOrganization();
  17. const onChange = (priority: PriorityLevel) => {
  18. if (priority === group.priority) {
  19. return;
  20. }
  21. trackAnalytics('issue_details.set_priority', {
  22. organization,
  23. ...getAnalyticsDataForGroup(group),
  24. from_priority: group.priority,
  25. to_priority: priority,
  26. });
  27. addLoadingMessage(t('Saving changes\u2026'));
  28. bulkUpdate(
  29. api,
  30. {
  31. orgId: organization.slug,
  32. projectId: group.project.slug,
  33. itemIds: [group.id],
  34. data: {priority},
  35. },
  36. {complete: clearIndicators}
  37. );
  38. IssueListCacheStore.reset();
  39. };
  40. return (
  41. <GroupPriorityDropdown
  42. onChange={onChange}
  43. value={group.priority ?? PriorityLevel.MEDIUM}
  44. />
  45. );
  46. }
  47. export default GroupPriority;