|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- 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;
|