Hamid Ghaf e55c18ed12
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

43 lines
1.0 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
import ListRoute from 'core/mixins/list-route';
import { inject as service } from '@ember/service';
export default Route.extend(ListRoute, {
store: service(),
secretMountPath: service(),
pathHelp: service(),
scope() {
return this.paramsFor('scope').scope_name;
},
beforeModel() {
return this.pathHelp.getNewModel('kmip/role', this.secretMountPath.currentPath);
},
model(params) {
return this.store
.lazyPaginatedQuery('kmip/role', {
backend: this.secretMountPath.currentPath,
scope: this.scope(),
responsePath: 'data.keys',
page: params.page,
pageFilter: params.pageFilter,
})
.catch((err) => {
if (err.httpStatus === 404) {
return [];
} else {
throw err;
}
});
},
setupController(controller) {
this._super(...arguments);
controller.set('scope', this.scope());
},
});