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 Dec 11, 2024
1 parent ff4c602 commit 843ad04
Show file tree
Hide file tree
Showing 11 changed files with 4,305 additions and 6,996 deletions.
3 changes: 3 additions & 0 deletions cypress/support/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const intl = createIntl(
cache
);
export const rulesTableColumns = [
{
title: 'Data expansion table header cell',
},
{
title: intl.formatMessage(messages.name),
},
Expand Down
11,218 changes: 4,242 additions & 6,976 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 @@ -66,6 +66,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 (

Check warning on line 25 in src/PresentationalComponents/Inventory/InventoryDetails.js

View check run for this annotation

Codecov / codecov/patch

src/PresentationalComponents/Inventory/InventoryDetails.js#L24-L25

Added lines #L24 - L25 were not covered by tests
<>
<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)} variant="compact" />

Check warning on line 391 in src/PresentationalComponents/PathwaysTable/PathwaysTable.js

View check run for this annotation

Codecov / codecov/patch

src/PresentationalComponents/PathwaysTable/PathwaysTable.js#L391

Added line #L391 was not covered by tests
) : isError ? (
<Table>
<ErrorState />
Expand Down
2 changes: 1 addition & 1 deletion src/PresentationalComponents/RulesTable/RulesTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ describe('sorting', () => {
'impacted_count',
'playbook_count',
],
TABLE_HEADERS
TABLE_HEADERS.filter((h) => h !== 'Data expansion table header cell')
).forEach(([category, label]) => {
let sortingParameter = category;
SORTING_ORDERS.forEach((order) => {
Expand Down
8 changes: 6 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,11 @@ const RulesTable = ({ isTabActive, pathway }) => {
activeFiltersConfig={activeFiltersConfig}
/>
{isFetching ? (
<Loading />
<SkeletonTable
columns={cols.map((c) => c.title)}

Check warning on line 290 in src/PresentationalComponents/RulesTable/RulesTable.js

View check run for this annotation

Codecov / codecov/patch

src/PresentationalComponents/RulesTable/RulesTable.js#L289-L290

Added lines #L289 - L290 were not covered by tests
isExpandable
variant="compact"
/>
) : 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 />
<>

Check warning on line 140 in src/PresentationalComponents/TopicsTable/TopicsTable.js

View check run for this annotation

Codecov / codecov/patch

src/PresentationalComponents/TopicsTable/TopicsTable.js#L140

Added line #L140 was not covered by tests
<PrimaryToolbar
filterConfig={{ items: filterConfigItems }}
activeFiltersConfig={activeFiltersConfig}
/>
<SkeletonTable columns={cols.map((c) => c.title)} />

Check warning on line 145 in src/PresentationalComponents/TopicsTable/TopicsTable.js

View check run for this annotation

Codecov / codecov/patch

src/PresentationalComponents/TopicsTable/TopicsTable.js#L145

Added line #L145 was not covered by tests
</>
) : !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="xl" />
</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

Check warning on line 104 in src/SmartComponents/Recs/List.js

View check run for this annotation

Codecov / codecov/patch

src/SmartComponents/Recs/List.js#L104

Added line #L104 was not covered by tests
fallback={
<Bullseye>
<Spinner size="xl" />
</Bullseye>
}
>
<PathwaysTable isTabActive={activeTab === PATHWAYS_TAB} />
</Suspense>
)}
Expand Down
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 '@patternfly/react-component-groups';

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)} variant="compact" />

Check warning on line 465 in src/SmartComponents/SystemAdvisor/SystemAdvisor.js

View check run for this annotation

Codecov / codecov/patch

src/SmartComponents/SystemAdvisor/SystemAdvisor.js#L465

Added line #L465 was not covered by tests
)}
{inventoryReportFetchStatus === 'fulfilled' && (
<Fragment>
Expand Down

0 comments on commit 843ad04

Please sign in to comment.