issuesList.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import AssigneeSelectorDropdown, {
  4. AssigneeWrapper,
  5. } from 'sentry/components/assigneeSelectorDropdown';
  6. import GridEditable, {type GridColumnOrder} from 'sentry/components/gridEditable';
  7. import {Grid} from 'sentry/components/gridEditable/styles';
  8. import {GroupSummary} from 'sentry/components/group/groupSummary';
  9. import TimeSince from 'sentry/components/timeSince';
  10. import type {Group} from 'sentry/types/group';
  11. function IssuesList() {
  12. const [activeRowKey, setActiveRowKey] = useState<number | undefined>(undefined);
  13. const columnOrder: Array<GridColumnOrder<keyof Group>> = [
  14. {key: 'title', name: 'Issue'},
  15. {key: 'lastSeen', name: 'Age'},
  16. {key: 'assignedTo', name: 'Assignee'},
  17. ];
  18. const renderHeadCell = (column: GridColumnOrder) => column.name;
  19. const renderBodyCell = (column: GridColumnOrder<keyof Group>, dataRow: Group) => {
  20. switch (column.key) {
  21. case 'title':
  22. return (
  23. <GroupSummary
  24. group={dataRow}
  25. event={dataRow.latestEvent}
  26. project={dataRow.project}
  27. />
  28. );
  29. case 'lastSeen':
  30. return <TimeSince date={dataRow.lastSeen} unitStyle="extraShort" suffix="" />;
  31. case 'assignedTo':
  32. return <AssigneeSelectorDropdown group={dataRow} loading={false} />;
  33. default:
  34. return null;
  35. }
  36. };
  37. return (
  38. <Wrapper>
  39. <GridEditable
  40. data={[]}
  41. columnOrder={columnOrder}
  42. columnSortBy={[]}
  43. grid={{
  44. renderHeadCell,
  45. renderBodyCell,
  46. }}
  47. onRowMouseOver={(_dataRow, key) => {
  48. setActiveRowKey(key);
  49. }}
  50. onRowMouseOut={() => {
  51. setActiveRowKey(undefined);
  52. }}
  53. highlightedRowKey={activeRowKey}
  54. />
  55. </Wrapper>
  56. );
  57. }
  58. const Wrapper = styled('div')`
  59. ${Grid} {
  60. grid-template-columns: 3fr 1fr 1fr !important;
  61. }
  62. ${AssigneeWrapper} {
  63. justify-content: flex-start;
  64. }
  65. `;
  66. export default IssuesList;