|
123456789101112131415161718192021222324252627282930313233343536373839 |
- import { h, Component } from 'preact';
- import WBBreadcrumbs from 'wb-breadcrumbs';
- import fetchProjectParents from 'fetch-project-parents';
-
- class WBProjectCrumbs 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.appState;
- let prom = fetchProjectParents(arvHost, arvToken, this.props.uuid);
- prom = prom.then(parents => this.setState({ 'items': parents }));
- }
-
- componentDidMount() {
- this.fetchCrumbs();
- }
-
- componentWillReceiveProps(nextProps) {
- this.props = nextProps;
- this.fetchCrumbs();
- }
-
- render({ onItemClicked }, { items }) {
- return (
- <WBBreadcrumbs items={ items }
- onItemClicked={ onItemClicked } />
- );
- }
- }
-
- export default WBProjectCrumbs;
|