2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2021-11-30 20:21:56 +00:00
|
|
|
import Service from '@ember/service';
|
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
import { schedule } from '@ember/runloop';
|
2018-06-20 01:07:09 +00:00
|
|
|
|
2021-11-30 20:21:56 +00:00
|
|
|
export default class BucketService extends Service {
|
|
|
|
@tracked crumbs = [];
|
2018-06-20 01:07:09 +00:00
|
|
|
|
2021-11-30 20:21:56 +00:00
|
|
|
@action registerBreadcrumb(crumb) {
|
|
|
|
schedule('actions', this, () => {
|
|
|
|
this.crumbs = [...this.crumbs, crumb];
|
2018-06-20 01:07:09 +00:00
|
|
|
});
|
2021-11-30 20:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@action deregisterBreadcrumb(crumb) {
|
2022-01-20 15:39:02 +00:00
|
|
|
const newCrumbs = this.crumbs.filter((c) => c !== crumb);
|
2018-06-20 01:07:09 +00:00
|
|
|
|
2021-11-30 20:21:56 +00:00
|
|
|
this.crumbs = newCrumbs;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|