IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.4KB

  1. import { h, Component } from 'preact';
  2. import WBTable from 'wb-table';
  3. import WBNameAndUuid from 'wb-name-and-uuid';
  4. import wbFetchObjects from 'wb-fetch-objects';
  5. import wbFormatDate from 'wb-format-date';
  6. class WBToolboxDialog extends Component {
  7. constructor(...args) {
  8. super(...args);
  9. this.state.rows = [];
  10. }
  11. componentDidMount() {
  12. this.fetchRows();
  13. }
  14. componentWillReceiveProps(nextProps) {
  15. this.props = nextProps;
  16. this.fetchRows();
  17. }
  18. fetchRows() {
  19. const { items } = this.props;
  20. const { arvHost, arvToken } = this.props.app.state;
  21. let prom = wbFetchObjects(arvHost, arvToken,
  22. items);
  23. let lookup;
  24. prom = prom.then(lkup => (lookup = lkup));
  25. prom = prom.then(() => wbFetchObjects(arvHost, arvToken,
  26. items.map(uuid => lookup[uuid].owner_uuid)));
  27. let ownerLookup;
  28. prom = prom.then(lkup => (ownerLookup = lkup));
  29. prom = prom.then(() => {
  30. const rows = items.map(uuid => {
  31. const it = lookup[uuid];
  32. const ow = ownerLookup[it.owner_uuid];
  33. return [
  34. ( <div><input type="checkbox" /></div> ),
  35. ( <WBNameAndUuid uuid={ uuid } lookup={ lookup } /> ),
  36. it.kind,
  37. wbFormatDate(it.created_at),
  38. ( <WBNameAndUuid uuid={ it.owner_uuid } lookup={ ownerLookup } /> )
  39. ];
  40. });
  41. this.setState({ rows });
  42. });
  43. }
  44. render({ id }, { rows }) {
  45. return (
  46. <div class="modal" id={ id } tabindex="-1" role="dialog">
  47. <div class="modal-dialog modal-lg" role="document">
  48. <div class="modal-content">
  49. <div class="modal-header">
  50. <h5 class="modal-title">Browse Toolbox</h5>
  51. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  52. <span aria-hidden="true">&times;</span>
  53. </button>
  54. </div>
  55. <div class="modal-body">
  56. <WBTable columns={ [ '', 'Name', 'Kind', 'Created At', 'Owner' ] }
  57. rows={ rows } />
  58. </div>
  59. <div class="modal-footer">
  60. <button type="button" class="btn btn-primary">Accept</button>
  61. <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. );
  67. }
  68. }
  69. export default WBToolboxDialog;