Files
threshold-ui/ui/admin/app/components/breadcrumbs/container/index.js
T
Lisbet AlvarezandZhihe Li a20483d1af update breadcrumbs to use hds::breadcrumbs (#1934)
* refactor: 💡 initial changes for updating breadcrumbs to use hds

* refactor: 💡 add breadcrumbs to all paths

* refactor: 💡 add more hds breadcrumbs to remaining paths

* refactor: 💡 remove BreadCrumbs from templates

* refactor: 💡 remove breadcrumb only controller files

* test: 💍 remove unnused test files & add missing tests

* test: 💍 update tests

* test: 💍 add missing scope in test

* test: 💍 fix test

* refactor: 💡 remove icons

* refactor: 💡 remove addon and use service instead

* docs: ✏️ add comment to breadcrumb service

* test: 💍 update service unit test

* docs: ✏️ add comments to breadcrumb components

* Update ui/admin/app/components/breadcrumbs/container/index.js

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>

---------

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
2023-10-17 09:45:34 -07:00

33 lines
938 B
JavaScript

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
/*
The `containers` property from the `breadcrumbsService` is tracked
so registering or unregistering a container will cause the DOM
to re-render a container with the correct breadcrumbs.
*/
export default class BreadcrumbsContainerComponent extends Component {
@service('breadcrumbs') breadcrumbsService;
container = null;
@action
registerContainer(element) {
// A child `ol` is rendered in the Hds::Breadcrumb container and this is
// the element that the in-element helper should drop breadcrumbs into.
this.container = {
element: element.querySelector('ol'),
};
this.breadcrumbsService.registerContainer(this.container);
}
willDestroy() {
super.willDestroy(...arguments);
this.breadcrumbsService.unregisterContainer(this.container);
}
}