2023-10-24 14:31:07 -04:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2024-05-31 11:29:24 -07:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-10-24 14:31:07 -04:00
|
|
|
*/
|
|
|
|
|
|
2023-10-17 09:45:34 -07:00
|
|
|
import Component from '@glimmer/component';
|
2025-03-12 08:29:54 -07:00
|
|
|
import { service } from '@ember/service';
|
2023-10-17 09:45:34 -07:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|