Skip to content

Commit

Permalink
store/cockpitApi: blueprint pagination
Browse files Browse the repository at this point in the history
Add blueprint list pagination support
  • Loading branch information
kingsleyzissou committed Jan 13, 2025
1 parent b2a2619 commit 041fd72
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/store/cockpitApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({
>({
queryFn: async (queryArgs) => {
try {
const { name, search } = queryArgs;
const { name, search, offset, limit } = queryArgs;

const blueprintsDir = await getBlueprintsPath();

Expand Down Expand Up @@ -92,6 +92,11 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({
return true;
});

let paginatedBlueprints = blueprints;
if (offset !== undefined && limit !== undefined) {
paginatedBlueprints = blueprints.slice(offset, offset + limit);
}

let first = '';
let last = '';

Expand All @@ -109,7 +114,7 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({
first: first,
last: last,
},
data: blueprints,
data: paginatedBlueprints,
},
};
} catch (error) {
Expand Down

0 comments on commit 041fd72

Please sign in to comment.