open-nomad/ui/app/services/breadcrumbs.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
595 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Service from '@ember/service';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { schedule } from '@ember/runloop';
export default class BucketService extends Service {
@tracked crumbs = [];
@action registerBreadcrumb(crumb) {
schedule('actions', this, () => {
this.crumbs = [...this.crumbs, crumb];
});
}
@action deregisterBreadcrumb(crumb) {
2022-01-20 15:39:02 +00:00
const newCrumbs = this.crumbs.filter((c) => c !== crumb);
this.crumbs = newCrumbs;
}
}