Skip to content

Commit

Permalink
fix(HMS-2247): add spinner to instances table
Browse files Browse the repository at this point in the history
  • Loading branch information
amirfefer authored and lzap committed Aug 2, 2023
1 parent 1d94170 commit 0139551
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Components/InstancesTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import { TableComposable, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
import { Button, ClipboardCopy, Card, Pagination } from '@patternfly/react-core';
import { Button, ClipboardCopy, Card, Pagination, Spinner, Bullseye } from '@patternfly/react-core';
import { useQuery } from 'react-query';

import { SSHUsername } from './helpers';
Expand All @@ -17,7 +17,7 @@ const PER_PAGE_OPTIONS = [
];
const InstancesTable = ({ reservationID, provider, region }) => {
const [paginationOptions, setPaginationOptions] = React.useState({ perPage: 5, page: 1, startIdx: 0, endIdx: 5 });
const { data: instances } = useQuery(['launchInfo', reservationID], () => fetchReservationByProvider(reservationID, provider), {
const { data: instances, isLoading } = useQuery(['launchInfo', reservationID], () => fetchReservationByProvider(reservationID, provider), {
select: (reservation) => reservation?.instances,
});

Expand All @@ -32,6 +32,12 @@ const InstancesTable = ({ reservationID, provider, region }) => {
const instancesPerPage = instances?.slice(paginationOptions.startIdx, paginationOptions.endIdx);
const atLeastOneDetailNotEmpty = instancesPerPage?.some((instance) => instance.detail?.public_dns?.length > 0);

if (isLoading)
return (
<Bullseye>
<Spinner isSVG size="xl" />
</Bullseye>
);
return (
<Card style={{ position: 'relative', marginLeft: '-20%', marginRight: '-20%' }}>
<Pagination
Expand Down

0 comments on commit 0139551

Please sign in to comment.