// // Copyright (C) Stanislaw Adaszewski, 2020 // Contact: s.adaszewski@gmail.com // Website: https://adared.ch/wba // License: GNU Affero General Public License, Version 3 // import { h, Component } from 'preact'; import WBBreadcrumbs from 'wb-breadcrumbs'; import fetchObjectParents from 'fetch-object-parents'; class WBArvadosCrumbs extends Component { constructor(...args) { super(...args); this.state.items = [ { 'name': 'All Projects' } ]; } fetchCrumbs() { const { mode, uuid, app } = this.props; const { arvHost, arvToken } = app.state; if (mode === 'shared-with-me') { this.setState({ 'items': [ { 'name': 'Shared with Me' } ] }); return; } if (!uuid) { this.setState({ 'items': [ { 'name': 'All Projects' } ] }); return; } let prom = fetchObjectParents(arvHost, arvToken, uuid); prom = prom.then(parents => { this.setState({ 'items': parents }); }); } componentDidMount() { this.fetchCrumbs(); } componentWillReceiveProps(nextProps) { this.props = nextProps; this.fetchCrumbs(); } render({ app }, { items }) { return ( app.breadcrumbClicked(item) } /> ); } } export default WBArvadosCrumbs;