Angel Garbarino 7c974beee4
PKI: Fix small routing issues with SecretListHeader (#17526)
* fix routing issues with SecretListHeader

* clean up
2022-10-13 10:57:18 -06:00

29 lines
861 B
JavaScript

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class PkiCertificatesIndexRoute extends Route {
@service store;
@service secretMountPath;
@service pathHelp;
beforeModel() {
// Must call this promise before the model hook otherwise it doesn't add OpenApi to record.
return this.pathHelp.getNewModel('pki/pki-certificate-engine', 'pki');
}
model() {
return this.store
.query('pki/pki-certificate-engine', { backend: this.secretMountPath.currentPath })
.then((certificateModel) => {
return { certificateModel, parentModel: this.modelFor('certificates') };
})
.catch((err) => {
if (err.httpStatus === 404) {
return { parentModel: this.modelFor('certificates') };
} else {
throw err;
}
});
}
}