open-nomad/ui/app/services/breadcrumbs.js
2023-04-10 15:36:59 +00:00

26 lines
595 B
JavaScript

/**
* 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) {
const newCrumbs = this.crumbs.filter((c) => c !== crumb);
this.crumbs = newCrumbs;
}
}