FEATURE: Add pagination to API keys page (#14777)

This commit is contained in:
Bianca Nenciu
2021-11-09 12:18:23 +02:00
committed by GitHub
parent 42f65b4c48
commit b203e316ac
4 changed files with 126 additions and 78 deletions

View File

@ -1,14 +1,39 @@
import Controller from "@ember/controller";
import { action } from "@ember/object";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Controller.extend({
actions: {
revokeKey(key) {
key.revoke().catch(popupAjaxError);
},
loading: false,
undoRevokeKey(key) {
key.undoRevoke().catch(popupAjaxError);
},
@action
revokeKey(key) {
key.revoke().catch(popupAjaxError);
},
@action
undoRevokeKey(key) {
key.undoRevoke().catch(popupAjaxError);
},
@action
loadMore() {
if (this.loading || this.model.loaded) {
return;
}
const limit = 50;
this.set("loading", true);
this.store
.findAll("api-key", { offset: this.model.length, limit })
.then((keys) => {
this.model.addObjects(keys);
if (keys.length < limit) {
this.model.set("loaded", true);
}
})
.finally(() => {
this.set("loading", false);
});
},
});