|
- 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() {
- if (!this.props.uuid) {
- this.setState({ 'items': [ { 'name': 'All Projects' } ] });
- return;
- }
-
- let { arvHost, arvToken } = this.props.app.state;
- let prom = fetchObjectParents(arvHost, arvToken, this.props.uuid);
- prom = prom.then(parents => this.setState({ 'items': parents }));
- }
-
- componentDidMount() {
- this.fetchCrumbs();
- }
-
- componentWillReceiveProps(nextProps) {
- this.props = nextProps;
- this.fetchCrumbs();
- }
-
- render({ app }, { items }) {
- return (
- <WBBreadcrumbs items={ items }
- onItemClicked={ item => app.breadcrumbClicked(item) } />
- );
- }
- }
-
- export default WBArvadosCrumbs;
|