Skip to content

Commit

Permalink
fix(RHINENG-11976): fix loading states across app
Browse files Browse the repository at this point in the history
  • Loading branch information
xmicha82 committed Nov 12, 2024
1 parent b2cdd1c commit a58a349
Show file tree
Hide file tree
Showing 10 changed files with 4,173 additions and 6,871 deletions.
10,970 changes: 4,118 additions & 6,852 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@babel/runtime": "^7.24.6",
"@patternfly/patternfly": "^5.3.1",
"@patternfly/react-charts": "^7.4.0",
"@patternfly/react-component-groups": "^5.5.3",
"@patternfly/react-core": "^5.3.3",
"@patternfly/react-icons": "^5.3.2",
"@patternfly/react-table": "^5.3.3",
Expand Down
16 changes: 15 additions & 1 deletion src/PresentationalComponents/Inventory/InventoryDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ import { useIntl } from 'react-intl';
import SystemAdvisor from '../../SmartComponents/SystemAdvisor';
import { useParams } from 'react-router-dom';
import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
import { Skeleton } from '@patternfly/react-core';

const InventoryHeadFallback = () => {
return (
<>
<Skeleton width="70%" fontSize="xl" />
<br />
<Skeleton width="40%" fontSize="md" />
<br />
<Skeleton width="55%" fontSize="md" />
<br />
</>
);
};

const InventoryDetails = ({ entity }) => {
const intl = useIntl();
Expand Down Expand Up @@ -46,7 +60,7 @@ const InventoryDetails = ({ entity }) => {
>
<PageHeader className="pf-m-light ins-inventory-detail">
{entity && <Breadcrumbs current={entity.display_name || entity.id} />}
<InventoryDetailHead hideBack fallback="" />
<InventoryDetailHead hideBack fallback={<InventoryHeadFallback />} />
</PageHeader>
<section className="pf-v5-l-page__main-section pf-v5-c-page__main-section">
<Title className="pf-v5-u-mb-lg" headingLevel="h3" size="2xl">
Expand Down
4 changes: 2 additions & 2 deletions src/PresentationalComponents/PathwaysTable/PathwaysTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
import { useDispatch, useSelector } from 'react-redux';

import CategoryLabel from '../Labels/CategoryLabel';
import Loading from '../Loading/Loading';
import MessageState from '../MessageState/MessageState';
import { PrimaryToolbar } from '@redhat-cloud-services/frontend-components/PrimaryToolbar';
import { ErrorState } from '@redhat-cloud-services/frontend-components/ErrorState';
Expand All @@ -48,6 +47,7 @@ import { useGetPathwaysQuery } from '../../Services/Pathways';
import { useIntl } from 'react-intl';
import PropTypes from 'prop-types';
import { conditionalFilterType } from '@redhat-cloud-services/frontend-components/ConditionalFilter';
import { SkeletonTable } from '@patternfly/react-component-groups';

const PathwaysTable = ({ isTabActive }) => {
const intl = useIntl();
Expand Down Expand Up @@ -388,7 +388,7 @@ const PathwaysTable = ({ isTabActive }) => {
activeFiltersConfig={activeFiltersConfig}
/>
{isFetching ? (
<Loading />
<SkeletonTable columns={cols.map((c) => c.title)} />
) : isError ? (
<Table>
<ErrorState />
Expand Down
4 changes: 2 additions & 2 deletions src/PresentationalComponents/RulesTable/RulesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { useDispatch, useSelector } from 'react-redux';

import DisableRule from '../Modals/DisableRule';
import { ErrorState } from '@redhat-cloud-services/frontend-components/ErrorState';
import Loading from '../../PresentationalComponents/Loading/Loading';
import { PrimaryToolbar } from '@redhat-cloud-services/frontend-components/PrimaryToolbar';
import ViewHostAcks from '../../PresentationalComponents/Modals/ViewHostAcks';
import debounce from '../../Utilities/Debounce';
Expand All @@ -50,6 +49,7 @@ import {
import { useActionsResolver } from './useActionsResolver';
import impactingFilter from '../Filters/impactingFilter';
import { AccountStatContext } from '../../ZeroStateWrapper';
import { SkeletonTable } from '@patternfly/react-component-groups';

const RulesTable = ({ isTabActive, pathway }) => {
const intl = useIntl();
Expand Down Expand Up @@ -286,7 +286,7 @@ const RulesTable = ({ isTabActive, pathway }) => {
activeFiltersConfig={activeFiltersConfig}
/>
{isFetching ? (
<Loading />
<SkeletonTable columns={cols.map((c) => c.title)} isExpandable />
) : isError ? (
<Table>
<ErrorState />
Expand Down
10 changes: 8 additions & 2 deletions src/PresentationalComponents/TopicsTable/TopicsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {

import { Label } from '@patternfly/react-core/dist/esm/components/Label/Label';
import Link from '@redhat-cloud-services/frontend-components/InsightsLink';
import Loading from '../../PresentationalComponents/Loading/Loading';
import MessageState from '../../PresentationalComponents/MessageState/MessageState';
import { PrimaryToolbar } from '@redhat-cloud-services/frontend-components/PrimaryToolbar';
import PropTypes from 'prop-types';
Expand All @@ -19,6 +18,7 @@ import messages from '../../Messages';
import { useIntl } from 'react-intl';
import { sortTopics } from '../helper';
import { conditionalFilterType } from '@redhat-cloud-services/frontend-components/ConditionalFilter';
import { SkeletonTable } from '@patternfly/react-component-groups';

const TopicsTable = ({ props }) => {
const intl = useIntl();
Expand Down Expand Up @@ -137,7 +137,13 @@ const TopicsTable = ({ props }) => {
return (
<React.Fragment>
{isLoading || isFetching ? (
<Loading />
<>
<PrimaryToolbar
filterConfig={{ items: filterConfigItems }}
activeFiltersConfig={activeFiltersConfig}
/>
<SkeletonTable columns={cols.map((c) => c.title)} />
</>
) : !isFetching && topics.length > 0 ? (
<React.Fragment>
<PrimaryToolbar
Expand Down
18 changes: 15 additions & 3 deletions src/SmartComponents/HybridInventoryTabs/HybridInventoryTabs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Suspense, Fragment, lazy, useContext } from 'react';
import React, { Suspense, lazy, useContext } from 'react';
import propTypes from 'prop-types';
import AsynComponent from '@redhat-cloud-services/frontend-components/AsyncComponent';
import { useFeatureFlag } from '../../Utilities/Hooks';
Expand Down Expand Up @@ -42,7 +42,13 @@ const HybridInventory = ({
appName="inventory"
module="./HybridInventoryTabs"
ConventionalSystemsTab={
<Suspense fallback={Fragment}>
<Suspense
fallback={
<Bullseye>
<Spinner size="lg" />
</Bullseye>
}
>
{tabProps.isRecommendationDetail ? (
<RecommendationSystems {...tabProps} />
) : (
Expand All @@ -51,7 +57,13 @@ const HybridInventory = ({
</Suspense>
}
ImmutableDevicesTab={
<Suspense fallback={Fragment}>
<Suspense
fallback={
<Bullseye>
<Spinner size="xl" />
</Bullseye>
}
>
<ImmutableDevices {...tabProps} />
</Suspense>
}
Expand Down
11 changes: 9 additions & 2 deletions src/SmartComponents/Recs/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useLocation } from 'react-router-dom';
import useInsightsNavigate from '@redhat-cloud-services/frontend-components-utilities/useInsightsNavigate';

import DownloadExecReport from '../../PresentationalComponents/ExecutiveReport/Download';
import Loading from '../../PresentationalComponents/Loading/Loading';
import { PERMS } from '../../AppConstants';
import { QuestionTooltip } from '../../PresentationalComponents/Common/Common';
import messages from '../../Messages';
Expand All @@ -22,6 +21,8 @@ import {
Stack,
StackItem,
Tooltip,
Spinner,
Bullseye,
} from '@patternfly/react-core';

import { RECOMMENDATIONS_TAB, PATHWAYS_TAB } from '../../AppConstants';
Expand Down Expand Up @@ -100,7 +101,13 @@ const List = () => {
}
>
{activeTab === PATHWAYS_TAB && (
<Suspense fallback={<Loading />}>
<Suspense
fallback={
<Bullseye>
<Spinner size="xl" />
</Bullseye>
}
>
<PathwaysTable isTabActive={activeTab === PATHWAYS_TAB} />
</Suspense>
)}
Expand Down
Empty file.
10 changes: 3 additions & 7 deletions src/SmartComponents/SystemAdvisor/SystemAdvisor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
FILTER_CATEGORIES as FC,
INVENTORY_BASE_URL,
} from '../../AppConstants';
import { Card, CardBody, Spinner } from '@patternfly/react-core';
import { Spinner } from '@patternfly/react-core';
import { useIntl } from 'react-intl';
import React, { Fragment, useEffect, useRef, useState } from 'react';
import { SortByDirection, TableVariant } from '@patternfly/react-table';
Expand All @@ -16,7 +16,6 @@ import {
import { useDispatch, useSelector } from 'react-redux';

import { Get } from '../../Utilities/Api';
import { List } from 'react-content-loader';
import PrimaryToolbar from '@redhat-cloud-services/frontend-components/PrimaryToolbar';
import PropTypes from 'prop-types';
import RemediationButton from '@redhat-cloud-services/frontend-components-remediations/RemediationButton';
Expand All @@ -36,6 +35,7 @@ import { usePermissions } from '@redhat-cloud-services/frontend-components-utili
import * as AppConstants from '../../AppConstants';
import { useParams } from 'react-router-dom';
import useChrome from '@redhat-cloud-services/frontend-components/useChrome';
import { SkeletonTable } from '@redhat-cloud-services/frontend-components/SkeletonTable';

const BaseSystemAdvisor = ({ entity, inventoryId }) => {
const intl = useIntl();
Expand Down Expand Up @@ -462,11 +462,7 @@ const BaseSystemAdvisor = ({ entity, inventoryId }) => {
/>
)}
{inventoryReportFetchStatus === 'pending' && (
<Card>
<CardBody>
<List />
</CardBody>
</Card>
<SkeletonTable columns={cols.map((c) => c.title)} />
)}
{inventoryReportFetchStatus === 'fulfilled' && (
<Fragment>
Expand Down

0 comments on commit a58a349

Please sign in to comment.