multiple: set pagination defaults

Set pagination defaults, otherwise these might be `undefined`.
This commit is contained in:
Gianluca Zuccarelli 2024-11-29 13:50:08 +00:00 committed by Lucas Garfield
parent bad77421ae
commit 4125a9cd3b
8 changed files with 36 additions and 15 deletions

View file

@ -44,6 +44,9 @@ import { AwsTarget, Target } from './Target';
import {
AWS_S3_EXPIRATION_TIME_IN_HOURS,
OCI_STORAGE_EXPIRATION_TIME_IN_DAYS,
PAGINATION_LIMIT,
PAGINATION_OFFSET,
SEARCH_INPUT,
STATUS_POLLING_INTERVAL,
} from '../../constants';
import { useGetBlueprintsQuery } from '../../store/backendApi';
@ -76,10 +79,11 @@ const ImagesTable = () => {
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(10);
const selectedBlueprintId = useAppSelector(selectSelectedBlueprintId);
const blueprintSearchInput = useAppSelector(selectBlueprintSearchInput);
const blueprintSearchInput =
useAppSelector(selectBlueprintSearchInput) || SEARCH_INPUT;
const blueprintVersionFilter = useAppSelector(selectBlueprintVersionFilter);
const blueprintsOffset = useAppSelector(selectOffset);
const blueprintsLimit = useAppSelector(selectLimit);
const blueprintsOffset = useAppSelector(selectOffset) || PAGINATION_OFFSET;
const blueprintsLimit = useAppSelector(selectLimit) || PAGINATION_LIMIT;
const { selectedBlueprintVersion } = useGetBlueprintsQuery(
{

View file

@ -28,6 +28,7 @@ import BlueprintVersionFilter from '../Blueprints/BlueprintVersionFilter';
import { BuildImagesButton } from '../Blueprints/BuildImagesButton';
import { DeleteBlueprintModal } from '../Blueprints/DeleteBlueprintModal';
import { EditBlueprintButton } from '../Blueprints/EditBlueprintButton';
import { SEARCH_INPUT } from '../../constants';
interface imagesTableToolbarProps {
itemCount: number;
@ -47,7 +48,8 @@ const ImagesTableToolbar: React.FC<imagesTableToolbarProps> = ({
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [showDiffModal, setShowDiffModal] = useState(false);
const selectedBlueprintId = useAppSelector(selectSelectedBlueprintId);
const blueprintSearchInput = useAppSelector(selectBlueprintSearchInput);
const blueprintSearchInput =
useAppSelector(selectBlueprintSearchInput) || SEARCH_INPUT;
const {
data: blueprintsComposes,

View file

@ -21,7 +21,11 @@ import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome'
import { useLoadModule, useScalprum } from '@scalprum/react-core';
import { useNavigate } from 'react-router-dom';
import { FILE_SYSTEM_CUSTOMIZATION_URL, MODAL_ANCHOR } from '../../constants';
import {
FILE_SYSTEM_CUSTOMIZATION_URL,
MODAL_ANCHOR,
SEARCH_INPUT,
} from '../../constants';
import {
selectSelectedBlueprintId,
selectBlueprintSearchInput,
@ -104,7 +108,8 @@ const ProvisioningLink = ({
);
const selectedBlueprintId = useAppSelector(selectSelectedBlueprintId);
const blueprintSearchInput = useAppSelector(selectBlueprintSearchInput);
const blueprintSearchInput =
useAppSelector(selectBlueprintSearchInput) || SEARCH_INPUT;
const { selectedBlueprintVersion } = useGetBlueprintsQuery(
{ search: blueprintSearchInput },
{