2024-01-23 22:29:53 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
|
|
*/
|
|
|
|
|
2024-01-29 23:38:21 +00:00
|
|
|
import Service, { inject as service } from '@ember/service';
|
2024-01-23 22:29:53 +00:00
|
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
|
|
|
|
const LOCAL_STORAGE_KEY = 'consul:hideHcpLinkBanner';
|
|
|
|
|
|
|
|
export default class HcpLinkStatus extends Service {
|
2024-01-29 23:38:21 +00:00
|
|
|
@service('env') env;
|
2024-01-23 22:29:53 +00:00
|
|
|
@tracked
|
|
|
|
userDismissedBanner = false;
|
|
|
|
|
|
|
|
get shouldDisplayBanner() {
|
2024-01-29 23:38:21 +00:00
|
|
|
const hcpLinkEnabled = this.env.var('CONSUL_HCP_LINK_ENABLED');
|
|
|
|
return !this.userDismissedBanner && hcpLinkEnabled;
|
2024-01-23 22:29:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
|
|
|
this.userDismissedBanner = !!localStorage.getItem(LOCAL_STORAGE_KEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
userHasLinked() {
|
|
|
|
// TODO: CC-7145 - once can fetch the link status from the backend, fetch it and set it here
|
|
|
|
}
|
|
|
|
|
|
|
|
dismissHcpLinkBanner() {
|
|
|
|
localStorage.setItem(LOCAL_STORAGE_KEY, true);
|
|
|
|
this.userDismissedBanner = true;
|
|
|
|
}
|
|
|
|
}
|