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.

47 lines
1.1KB

  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 fetchProjectParents from 'fetch-project-parents';
  10. class WBProjectCrumbs extends Component {
  11. constructor(...args) {
  12. super(...args);
  13. this.state.items = [ { 'name': 'All Projects' } ];
  14. }
  15. fetchCrumbs() {
  16. if (!this.props.uuid) {
  17. this.setState({ 'items': [ { 'name': 'All Projects' } ] });
  18. return;
  19. }
  20. let { arvHost, arvToken } = this.props.appState;
  21. let prom = fetchProjectParents(arvHost, arvToken, this.props.uuid);
  22. prom = prom.then(parents => this.setState({ 'items': parents }));
  23. }
  24. componentDidMount() {
  25. this.fetchCrumbs();
  26. }
  27. componentWillReceiveProps(nextProps) {
  28. this.props = nextProps;
  29. this.fetchCrumbs();
  30. }
  31. render({ onItemClicked }, { items }) {
  32. return (
  33. <WBBreadcrumbs items={ items }
  34. onItemClicked={ onItemClicked } />
  35. );
  36. }
  37. }
  38. export default WBProjectCrumbs;