adminProjects.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import type {RouteComponentProps} from 'react-router';
  2. import moment from 'moment';
  3. import ResultGrid from 'sentry/components/resultGrid';
  4. import {t} from 'sentry/locale';
  5. import type {Organization} from 'sentry/types/organization';
  6. type Row = {
  7. dateCreated: string;
  8. name: string;
  9. organization: Organization;
  10. slug: string;
  11. status: string;
  12. };
  13. type Props = RouteComponentProps<{}, {}>;
  14. const getRow = (row: Row) => [
  15. <td key="name">
  16. <strong>
  17. <a href={`/${row.organization.slug}/${row.slug}/`}>{row.name}</a>
  18. </strong>
  19. <br />
  20. <small>{row.organization.name}</small>
  21. </td>,
  22. <td key="status" style={{textAlign: 'center'}}>
  23. {row.status}
  24. </td>,
  25. <td key="dateCreated" style={{textAlign: 'right'}}>
  26. {moment(row.dateCreated).format('ll')}
  27. </td>,
  28. ];
  29. function AdminProjects(props: Props) {
  30. const columns = [
  31. <th key="name">Project</th>,
  32. <th key="status" style={{width: 150, textAlign: 'center'}}>
  33. Status
  34. </th>,
  35. <th key="dateCreated" style={{width: 200, textAlign: 'right'}}>
  36. Created
  37. </th>,
  38. ];
  39. return (
  40. <div>
  41. <h3>{t('Projects')}</h3>
  42. <ResultGrid
  43. path="/manage/projects/"
  44. endpoint="/projects/?show=all"
  45. method="GET"
  46. columns={columns}
  47. columnsForRow={getRow}
  48. hasSearch
  49. filters={{
  50. status: {
  51. name: 'Status',
  52. options: [
  53. ['active', 'Active'],
  54. ['deleted', 'Deleted'],
  55. ],
  56. },
  57. }}
  58. sortOptions={[['date', 'Date Created']]}
  59. defaultSort="date"
  60. {...props}
  61. />
  62. </div>
  63. );
  64. }
  65. export default AdminProjects;