Files
threshold-ui/ui/admin/app/components/breadcrumbs/item/index.js
T
hashicorp-copywrite[bot]andZhihe Li c548c381bf [COMPLIANCE] Add Copyright and License Headers (#1966)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
2023-10-24 14:31:07 -04:00

32 lines
802 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
/*
`BreadcrumbsItem` inserts the crumbs to an existing container.
For our purposes, there will always be at most one container.
*/
export default class BreadcrumbsItemComponent extends Component {
@service('breadcrumbs') breadcrumbsService;
@tracked element = null;
@action
registerSelf(element) {
this.element = element;
}
get current() {
const crumbs = this.breadcrumbsService.containers[0].element.children;
const lastCrumb = crumbs[crumbs.length - 1];
return lastCrumb.isEqualNode(this.element);
}
}