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.

72 lines
2.1KB

  1. import { h, Component, createRef } from 'preact';
  2. import WBNavbarCommon from 'wb-navbar-common';
  3. import WBArvadosCrumbs from 'wb-arvados-crumbs';
  4. import WBNameAndUuid from 'wb-name-and-uuid';
  5. import WBSelect from 'wb-select';
  6. import WBTable from 'wb-table';
  7. import WBBrowseDialog from 'wb-browse-dialog';
  8. import makeArvadosRequest from 'make-arvados-request';
  9. class WBSharingPage extends Component {
  10. constructor(...args) {
  11. super(...args);
  12. this.state.rows = [];
  13. this.browseDialogRef = createRef();
  14. }
  15. componentDidMount() {
  16. this.fetchData();
  17. }
  18. fetchData() {
  19. const { app, uuid } = this.props;
  20. const { arvHost, arvToken } = app.state;
  21. let prom = makeArvadosRequest(arvHost, arvToken,
  22. '/arvados/v1/permissions/' + encodeURIComponent(uuid));
  23. prom = prom.then(xhr => this.setState({
  24. 'rows': this.prepareRows(xhr.response.items)
  25. }));
  26. }
  27. deletePermission(uuid) {
  28. throw Error('Not implemented');
  29. }
  30. prepareRows(items) {
  31. const { app } = this.props;
  32. return items.map(it => [
  33. ( <WBNameAndUuid app={ app } uuid={ it.tail_uuid } /> ),
  34. ( <WBSelect value={ it.name } options={ ['can_read', 'can_write', 'can_manage'] } /> ),
  35. ( <button class="btn btn-outline-danger m-1" title="Delete"
  36. onclick={ () => this.deletePermission(it.uuid) }>
  37. <i class="fas fa-trash"></i>
  38. </button> )
  39. ]);
  40. }
  41. render({ app, uuid }, { rows }) {
  42. return (
  43. <div>
  44. <WBNavbarCommon app={ app } />
  45. <WBArvadosCrumbs app={ app } uuid={ uuid } />
  46. <div class="my-2">
  47. This is the sharing management page for { uuid }
  48. </div>
  49. <WBTable columns={ [ 'Name', 'Permission', '' ] }
  50. headerClasses={ [ null, null, 'w-1' ] }
  51. rows={ rows } />
  52. <WBBrowseDialog app={ app } ref={ this.browseDialogRef } />
  53. <button class="btn btn-primary"
  54. onclick={ () => this.browseDialogRef.current.show() }>Add</button>
  55. </div>
  56. );
  57. }
  58. }
  59. export default WBSharingPage;