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.

106 lines
3.5KB

  1. import { h, Component } from 'preact';
  2. import WBBrowseDialogProjectList from 'wb-browse-dialog-project-list';
  3. import WBBrowseDialogCollectionList from 'wb-browse-dialog-project-list';
  4. import linkState from 'linkstate';
  5. import { Router } from 'preact-router';
  6. import { createHashHistory } from 'history';
  7. class WBBrowseDialog extends Component {
  8. constructor(...args) {
  9. super(...args);
  10. this.state.history = [];
  11. this.state.history_1 = createHashHistory();
  12. }
  13. resetSearch() {
  14. this.setState({
  15. 'textSearch': null,
  16. 'textSearchInput': null
  17. });
  18. }
  19. pushHistory(child) {
  20. const { history, textSearch } = this.state;
  21. history.push([ child, { textSearch } ]);
  22. this.state.history = history.slice(history.length - 1000);
  23. }
  24. popHistory() {
  25. if (this.history.length === 0)
  26. return;
  27. const entry = history.pop();
  28. this.setState(entry[1]);
  29. entry[0].popHistory();
  30. }
  31. render({ app, id }, { mode, textSearch, textSearchInput, history, history_1 }) {
  32. return (
  33. <div class="modal" id={ id } tabindex="-1" role="dialog">
  34. <div class="modal-dialog modal-lg" role="document">
  35. <div class="modal-content">
  36. <div class="modal-header">
  37. <h5 class="modal-title">Browse</h5>
  38. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  39. <span aria-hidden="true">&times;</span>
  40. </button>
  41. </div>
  42. <div class="modal-body">
  43. <Router history={ history_1 }>
  44. <div path="/a">
  45. A
  46. </div>
  47. <div path="/b">
  48. B
  49. </div>
  50. </Router>
  51. <div>
  52. <h5>Go to: <a href="#">Home</a>, <a href="#">All Projects</a>,
  53. <a href="#">All Users</a>, <a href="#">Shared with Me</a></h5>
  54. </div>
  55. <div class="input-group mb-3">
  56. <div class="input-group-prepend">
  57. <button class="btn btn-outline-secondary" type="button">Back</button>
  58. </div>
  59. <input type="text" class="form-control" placeholder="Search"
  60. aria-label="Search" value={ textSearchInput }
  61. onChange={ linkState(this, 'textSearchInput') } />
  62. <div class="input-group-append">
  63. <button class="btn btn-outline-primary" type="button"
  64. onclick={ () => this.setState({ 'textSearch': this.state.textSearchInput }) }>Search</button>
  65. </div>
  66. </div>
  67. <h5>Projects</h5>
  68. <WBBrowseDialogProjectList app={ app } textSearch={ textSearch }
  69. resetSearch={ () => this.resetSearch() }
  70. pushHistory={ () => this.pushHistory() }
  71. popHistory={ () => this.popHistory() } />
  72. { mode === 'collection-content' ? (
  73. <h5>Content</h5>
  74. ) : (
  75. <div>
  76. <h5>Collections</h5>
  77. <WBBrowseDialogCollectionList app={ app } />
  78. </div>
  79. ) }
  80. </div>
  81. <div class="modal-footer">
  82. <button type="button" class="btn btn-primary">Accept</button>
  83. <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. );
  89. }
  90. }
  91. export default WBBrowseDialog;