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.

56 lines
1.3KB

  1. //
  2. // Copyright (C) Stanislaw Adaszewski, 2020
  3. // Contact: s.adaszewski@gmail.com
  4. // Website: https://adared.ch/wba
  5. // License: GNU Affero General Public License, Version 3
  6. //
  7. import { h, Component } from 'preact';
  8. import WBBreadcrumbs from 'wb-breadcrumbs';
  9. import fetchObjectParents from 'fetch-object-parents';
  10. class WBArvadosCrumbs extends Component {
  11. constructor(...args) {
  12. super(...args);
  13. this.state.items = [ { 'name': 'All Projects' } ];
  14. }
  15. fetchCrumbs() {
  16. const { mode, uuid, app } = this.props;
  17. const { arvHost, arvToken } = app.state;
  18. if (mode === 'shared-with-me') {
  19. this.setState({ 'items': [ { 'name': 'Shared with Me' } ] });
  20. return;
  21. }
  22. if (!uuid) {
  23. this.setState({ 'items': [ { 'name': 'All Projects' } ] });
  24. return;
  25. }
  26. let prom = fetchObjectParents(arvHost, arvToken, uuid);
  27. prom = prom.then(parents => {
  28. this.setState({ 'items': parents });
  29. });
  30. }
  31. componentDidMount() {
  32. this.fetchCrumbs();
  33. }
  34. componentWillReceiveProps(nextProps) {
  35. this.props = nextProps;
  36. this.fetchCrumbs();
  37. }
  38. render({ app }, { items }) {
  39. return (
  40. <WBBreadcrumbs items={ items }
  41. onItemClicked={ item => app.breadcrumbClicked(item) } />
  42. );
  43. }
  44. }
  45. export default WBArvadosCrumbs;