groupPriority.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. IssueListCacheStore.reset();
  29. bulkUpdate(
  30. api,
  31. {
  32. orgId: organization.slug,
  33. projectId: group.project.slug,
  34. itemIds: [group.id],
  35. data: {priority},
  36. },
  37. {complete: clearIndicators}
  38. );
  39. };
  40. return (
  41. <GroupPriorityDropdown
  42. onChange={onChange}
  43. value={group.priority ?? PriorityLevel.MEDIUM}
  44. />
  45. );
  46. }
  47. export default GroupPriority;