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.

49 lines
1.1KB

  1. import { h, Component } from 'preact';
  2. import WBBreadcrumbs from 'wb-breadcrumbs';
  3. import fetchObjectParents from 'fetch-object-parents';
  4. class WBArvadosCrumbs extends Component {
  5. constructor(...args) {
  6. super(...args);
  7. this.state.items = [ { 'name': 'All Projects' } ];
  8. }
  9. fetchCrumbs() {
  10. const { mode, uuid, app } = this.props;
  11. const { arvHost, arvToken } = app.state;
  12. if (mode === 'shared-with-me') {
  13. this.setState({ 'items': [ { 'name': 'Shared with Me' } ] });
  14. return;
  15. }
  16. if (!uuid) {
  17. this.setState({ 'items': [ { 'name': 'All Projects' } ] });
  18. return;
  19. }
  20. let prom = fetchObjectParents(arvHost, arvToken, uuid);
  21. prom = prom.then(parents => {
  22. this.setState({ 'items': parents });
  23. });
  24. }
  25. componentDidMount() {
  26. this.fetchCrumbs();
  27. }
  28. componentWillReceiveProps(nextProps) {
  29. this.props = nextProps;
  30. this.fetchCrumbs();
  31. }
  32. render({ app }, { items }) {
  33. return (
  34. <WBBreadcrumbs items={ items }
  35. onItemClicked={ item => app.breadcrumbClicked(item) } />
  36. );
  37. }
  38. }
  39. export default WBArvadosCrumbs;