adminProjects.tsx 1.8 KB

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