adminUsers.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import {RouteComponentProps} from 'react-router';
  2. import moment from 'moment';
  3. import Link from 'sentry/components/links/link';
  4. import ResultGrid from 'sentry/components/resultGrid';
  5. import {t} from 'sentry/locale';
  6. type Row = {
  7. dateJoined: string;
  8. email: string;
  9. id: string;
  10. lastLogin: string;
  11. username: string;
  12. };
  13. type Props = RouteComponentProps<{}, {}>;
  14. const getRow = (row: Row) => [
  15. <td key="username">
  16. <strong>
  17. <Link to={`/manage/users/${row.id}/`}>{row.username}</Link>
  18. </strong>
  19. <br />
  20. {row.email !== row.username && <small>{row.email}</small>}
  21. </td>,
  22. <td key="dateJoined" style={{textAlign: 'center'}}>
  23. {moment(row.dateJoined).format('ll')}
  24. </td>,
  25. <td key="lastLogin" style={{textAlign: 'center'}}>
  26. {moment(row.lastLogin).format('ll')}
  27. </td>,
  28. ];
  29. function AdminUsers(props: Props) {
  30. const columns = [
  31. <th key="username">User</th>,
  32. <th key="dateJoined" style={{textAlign: 'center', width: 150}}>
  33. Joined
  34. </th>,
  35. <th key="lastLogin" style={{textAlign: 'center', width: 150}}>
  36. Last Login
  37. </th>,
  38. ];
  39. return (
  40. <div>
  41. <h3>{t('Users')}</h3>
  42. <ResultGrid
  43. path="/manage/users/"
  44. endpoint="/users/"
  45. method="GET"
  46. columns={columns}
  47. columnsForRow={getRow}
  48. hasSearch
  49. filters={{
  50. status: {
  51. name: 'Status',
  52. options: [
  53. ['active', 'Active'],
  54. ['disabled', 'Disabled'],
  55. ],
  56. },
  57. }}
  58. sortOptions={[['date', 'Date Joined']]}
  59. defaultSort="date"
  60. {...props}
  61. />
  62. </div>
  63. );
  64. }
  65. export default AdminUsers;