|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // 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 (
- <WBBreadcrumbs items={ items }
- onItemClicked={ item => app.breadcrumbClicked(item) } />
- );
- }
- }
-
- export default WBArvadosCrumbs;
|