Files
threshold-ui/ui/admin/app/services/feature-edition.js
T
hashicorp-copywrite[bot]andCarlos Alcaide Corvo f17b7d54d8 [COMPLIANCE] Add Copyright and License Headers (#1660)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com>
2023-03-28 12:50:34 -05:00

48 lines
985 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Service from '@ember/service';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import config from 'admin/config/environment';
const { selectedEdition, featureEditions } = config;
export default class FeatureEditionService extends Service {
// =services
@service features;
// =attributes
@tracked edition;
// array of edition strings
get editions() {
return Object.keys(featureEditions);
}
// =methods
/**
* Initializes the selected edition from the config.
*/
initialize() {
this.setEdition(selectedEdition);
}
setEdition(edition) {
const editionFlags = featureEditions[edition];
Object.keys(editionFlags).forEach((flag) => {
if (editionFlags[flag]) {
this.features.enable(flag);
} else {
this.features.disable(flag);
}
});
this.edition = edition;
}
}