Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com>
48 lines
985 B
JavaScript
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;
|
|
}
|
|
}
|