ArchiveFilesTable.jsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { format } from 'date-fns';
  5. import { createSubscribedElement } from '../../UnstatedUtils';
  6. import AppContainer from '../../../services/AppContainer';
  7. // import { toastSuccess, toastError } from '../../../util/apiNotification';
  8. import ArchiveFilesTableMenu from './ArchiveFilesTableMenu';
  9. class ArchiveFilesTable extends React.Component {
  10. render() {
  11. // eslint-disable-next-line no-unused-vars
  12. const { t } = this.props;
  13. return (
  14. <table className="table table-bordered">
  15. <thead>
  16. <tr>
  17. <th>{t('export_management.file')}</th>
  18. <th>{t('export_management.growi_version')}</th>
  19. <th>{t('export_management.collections')}</th>
  20. <th>{t('export_management.exported_at')}</th>
  21. <th></th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. {this.props.zipFileStats.map(({ meta, fileName, innerFileStats }) => {
  26. return (
  27. <tr key={fileName}>
  28. <th>{fileName}</th>
  29. <td>{meta.version}</td>
  30. <td className="text-capitalize">{innerFileStats.map(fileStat => fileStat.collectionName).join(', ')}</td>
  31. <td>{meta.exportedAt ? format(new Date(meta.exportedAt), 'yyyy/MM/dd HH:mm:ss') : ''}</td>
  32. <td>
  33. <ArchiveFilesTableMenu
  34. fileName={fileName}
  35. onZipFileStatRemove={this.props.onZipFileStatRemove}
  36. />
  37. </td>
  38. </tr>
  39. );
  40. })}
  41. </tbody>
  42. </table>
  43. );
  44. }
  45. }
  46. ArchiveFilesTable.propTypes = {
  47. t: PropTypes.func.isRequired, // i18next
  48. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  49. zipFileStats: PropTypes.arrayOf(PropTypes.object).isRequired,
  50. onZipFileStatRemove: PropTypes.func.isRequired,
  51. };
  52. /**
  53. * Wrapper component for using unstated
  54. */
  55. const ArchiveFilesTableWrapper = (props) => {
  56. return createSubscribedElement(ArchiveFilesTable, props, [AppContainer]);
  57. };
  58. export default withTranslation()(ArchiveFilesTableWrapper);