VAULT-13220 use decorator instead of extending overview route (#19294)

This commit is contained in:
Kianna
2023-02-23 08:35:07 -08:00
committed by GitHub
parent 0d3c0c09c8
commit 354af62b1d
6 changed files with 57 additions and 24 deletions

View File

@@ -1,24 +1,14 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { withConfig } from 'pki/decorators/check-config';
import { hash } from 'rsvp';
@withConfig()
export default class PkiOverviewRoute extends Route {
@service secretMountPath;
@service auth;
@service store;
hasConfig() {
// When the engine is configured, it creates a default issuer.
// If the issuers list is empty, we know it hasn't been configured
return (
this.store
.query('pki/issuer', { backend: this.secretMountPath.currentPath })
.then(() => true)
// this endpoint is unauthenticated, so we're not worried about permissions errors
.catch(() => false)
);
}
async fetchAllRoles() {
try {
return await this.store.query('pki/role', { backend: this.secretMountPath.currentPath });
@@ -37,7 +27,7 @@ export default class PkiOverviewRoute extends Route {
async model() {
return hash({
hasConfig: this.hasConfig(),
hasConfig: this.shouldPromptConfig,
engine: this.modelFor('application'),
roles: this.fetchAllRoles(),
issuers: this.fetchAllIssuers(),