claire bontempo 217380cf87
UI: Ember data upgrade prep: cleanup store and lazyPaginatedQuery (#28690)
* revert hacks necessary for ember-data 4.11

* remove stubbed unloadAll and unloadRecord methods

* remove clearAllDatasets and just use clearDataset()
2024-10-11 14:18:56 -07:00

44 lines
977 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Route from '@ember/routing/route';
import { service } from '@ember/service';
import ListRoute from 'core/mixins/list-route';
export default Route.extend(ListRoute, {
store: service(),
secretMountPath: service(),
model(params) {
return this.store
.lazyPaginatedQuery('kmip/scope', {
backend: this.secretMountPath.currentPath,
responsePath: 'data.keys',
page: params.page,
pageFilter: params.pageFilter,
})
.catch((err) => {
if (err.httpStatus === 404) {
return [];
} else {
throw err;
}
});
},
actions: {
willTransition(transition) {
window.scrollTo(0, 0);
if (transition.targetName !== this.routeName) {
this.store.clearDataset();
}
return true;
},
reload() {
this.store.clearDataset();
this.refresh();
},
},
});