vault/ui/lib/pki/addon/routes/overview.js
Kianna 11f6aad2b2
ui: VAULT-6511 PKI Overview Page (#18599)
* Inital pki overview page code setup

* Add more properties to pki-overview

* Remove previous selectable card component and update template

* Add capability check for roles and issuers

* Add acceptance tests for overview page

* Update SelectableCardForm component

* Code refactor!

* Add selectable-card-form test

* More code cleanup and move function to test helper file

* Address most feedback. Pending refactor of issue certificate card!

* Add integration test

* Moves form to SelectableCard and add tests

* Add jsdoc props to SelectableCard and fix placeholder

* Move back SelectableCard

* Covert to typescript and finish up tests

* Dont use try catch for hasConfig

* Add overview card test

* More overview card tests

* Address feedback!
2023-01-17 13:30:31 -08:00

61 lines
1.5 KiB
JavaScript

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { hash } from 'rsvp';
export default class PkiOverviewRoute extends Route {
@service secretMountPath;
@service auth;
@service store;
get win() {
return this.window || window;
}
hasConfig() {
// When the engine is configured, it creates a default issuer.
// If the issuers list is empty, we know it hasn't been configured
const endpoint = `${this.win.origin}/v1/${this.secretMountPath.currentPath}/issuers?list=true`;
return this.auth
.ajax(endpoint, 'GET', {})
.then(() => true)
.catch(() => false);
}
async fetchEngine() {
const model = await this.store.query('secret-engine', {
path: this.secretMountPath.currentPath,
});
return model.get('firstObject');
}
async fetchAllRoles() {
try {
return await this.store.query('pki/role', { backend: this.secretMountPath.currentPath });
} catch (e) {
return e.httpStatus;
}
}
async fetchAllIssuers() {
try {
return await this.store.query('pki/issuer', { backend: this.secretMountPath.currentPath });
} catch (e) {
return e.httpStatus;
}
}
async model() {
return hash({
hasConfig: this.hasConfig(),
engine: this.fetchEngine(),
roles: this.fetchAllRoles(),
issuers: this.fetchAllIssuers(),
});
}
setupController(controller, resolvedModel) {
super.setupController(controller, resolvedModel);
}
}