Skip to content

Commit

Permalink
ImagesTable: Fix version filter
Browse files Browse the repository at this point in the history
This fixes the "All versions" / "Newest" filter in the blueprint images table.
  • Loading branch information
regexowl committed Jan 8, 2025
1 parent 34b4f24 commit 2e1ff9c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Components/ImagesTable/ImagesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
ComposesResponseItem,
ComposeStatus,
GetBlueprintComposesApiArg,
GetBlueprintsApiArg,
useGetBlueprintComposesQuery,
useGetComposesQuery,
useGetComposeStatusQuery,
Expand All @@ -89,12 +90,17 @@ const ImagesTable = () => {
const blueprintsOffset = useAppSelector(selectOffset) || PAGINATION_OFFSET;
const blueprintsLimit = useAppSelector(selectLimit) || PAGINATION_LIMIT;

const searchParamsGetBlueprints: GetBlueprintsApiArg = {
limit: blueprintsLimit,
offset: blueprintsOffset,
};

if (blueprintSearchInput) {
searchParamsGetBlueprints.search = blueprintSearchInput;
}

const { selectedBlueprintVersion } = useGetBlueprintsQuery(
{
search: blueprintSearchInput,
limit: blueprintsLimit,
offset: blueprintsOffset,
},
searchParamsGetBlueprints,
{
selectFromResult: ({ data }) => ({
selectedBlueprintVersion: data?.data?.find(
Expand All @@ -110,22 +116,23 @@ const ImagesTable = () => {
setPerPage(perPage);
};

const searchParams: GetBlueprintComposesApiArg = {
const searchParamsGetBlueprintComposes: GetBlueprintComposesApiArg = {
id: selectedBlueprintId as string,
limit: perPage,
offset: perPage * (page - 1),
};

if (blueprintVersionFilterAPI) {
searchParams.blueprintVersion = blueprintVersionFilterAPI;
searchParamsGetBlueprintComposes.blueprintVersion =
blueprintVersionFilterAPI;
}

const {
data: blueprintsComposes,
isSuccess: isBlueprintsSuccess,
isLoading: isLoadingBlueprintsCompose,
isError: isBlueprintsError,
} = useGetBlueprintComposesQuery(searchParams, {
} = useGetBlueprintComposesQuery(searchParamsGetBlueprintComposes, {
skip: !selectedBlueprintId,
});

Expand Down

0 comments on commit 2e1ff9c

Please sign in to comment.