open-vault/ui/app/services/version.js
claire bontempo 5768ae4f9b
UI: add enterprise only pki/config/crl parameters to edit configuration form (#20479)
* update version service

* render enterprise groups

* render enterprise params

* move group headers to within loop

* cleanup template

* update form tests

* change version service references to hasFeature to hasControlGroups getter

* add params to details view

* update version service test
2023-05-03 09:48:08 -07:00

74 lines
1.6 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Service, { inject as service } from '@ember/service';
import { keepLatestTask, task } from 'ember-concurrency';
import { tracked } from '@glimmer/tracking';
export default class VersionService extends Service {
@service store;
@tracked features = [];
@tracked version = null;
get hasPerfReplication() {
return this.features.includes('Performance Replication');
}
get hasDRReplication() {
return this.features.includes('DR Replication');
}
get hasSentinel() {
return this.features.includes('Sentinel');
}
get hasNamespaces() {
return this.features.includes('Namespaces');
}
get hasControlGroups() {
return this.features.includes('Control Groups');
}
get isEnterprise() {
if (!this.version) return false;
return this.version.includes('+');
}
get isOSS() {
return !this.isEnterprise;
}
@task
*getVersion() {
if (this.version) return;
const response = yield this.store.adapterFor('cluster').health();
this.version = response.version;
return;
}
@keepLatestTask
*getFeatures() {
if (this.features?.length || this.isOSS) {
return;
}
try {
const response = yield this.store.adapterFor('cluster').features();
this.features = response.features;
return;
} catch (err) {
// if we fail here, we're likely in DR Secondary mode and don't need to worry about it
}
}
fetchVersion() {
return this.getVersion.perform();
}
fetchFeatures() {
return this.getFeatures.perform();
}
}