ZipFileTable.jsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 ExportTableMenu from './ExportTableMenu';
  6. import { createSubscribedElement } from '../../UnstatedUtils';
  7. import AppContainer from '../../../services/AppContainer';
  8. // import { toastSuccess, toastError } from '../../../util/apiNotification';
  9. class ZipFileTable 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, fileStats }) => {
  26. return (
  27. <tr key={fileName}>
  28. <th>{fileName}</th>
  29. <td>{meta.version}</td>
  30. <td className="text-capitalize">{fileStats.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. <ExportTableMenu
  34. fileName={fileName}
  35. removeZipFileStat={this.props.removeZipFileStat}
  36. />
  37. </td>
  38. </tr>
  39. );
  40. })}
  41. </tbody>
  42. </table>
  43. );
  44. }
  45. }
  46. ZipFileTable.propTypes = {
  47. t: PropTypes.func.isRequired, // i18next
  48. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  49. zipFileStats: PropTypes.arrayOf(PropTypes.object).isRequired,
  50. removeZipFileStat: PropTypes.func.isRequired,
  51. };
  52. /**
  53. * Wrapper component for using unstated
  54. */
  55. const ZipFileTableWrapper = (props) => {
  56. return createSubscribedElement(ZipFileTable, props, [AppContainer]);
  57. };
  58. export default withTranslation()(ZipFileTableWrapper);