From 1115ec7c2b5c00d3165c94fc06e9064271bc1304 Mon Sep 17 00:00:00 2001 From: yzamir Date: Thu, 4 Apr 2024 23:09:47 +0300 Subject: [PATCH] Fix suspend Signed-off-by: yzamir --- .../Plans/views/details/components/Suspend.tsx | 16 +++++++--------- .../details/tabs/Resources/PlanResources.tsx | 13 +++++++++---- .../details/tabs/Details/ProviderDetails.tsx | 9 +++++++-- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/Suspend.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/Suspend.tsx index 78909deb7..ae46fd4fb 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/views/details/components/Suspend.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/components/Suspend.tsx @@ -24,15 +24,13 @@ export type SuspendProps = { * @returns {JSX.Element} The JSX element containing the children or a loading indicator. */ export const Suspend: React.FC = ({ obj, loaded, loadError, children }) => { + if (obj && loaded && !loadError) { + return <>{children}; + } + return ( - - - - } - > - {obj && loaded && !loadError && children} - + + + ); }; diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Resources/PlanResources.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Resources/PlanResources.tsx index c8d57f560..adc16d95d 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Resources/PlanResources.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/Resources/PlanResources.tsx @@ -14,8 +14,9 @@ import { VSphereVM, } from '@kubev2v/types'; import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk'; +import { Bullseye } from '@patternfly/react-core'; -import { Suspend } from '../../components'; +import { Loading, Suspend } from '../../components'; import { OpenshiftPlanResources } from './OpenshiftPlanResources'; import { OpenstackPlanResources } from './OpenstackPlanResources'; @@ -34,7 +35,7 @@ export const PlanResources: React.FC<{ name: string; namespace: string }> = ({ namespace, }); - const [provider] = useK8sWatchResource({ + const [provider, providerLoaded, providerLodeError] = useK8sWatchResource({ groupVersionKind: ProviderModelGroupVersionKind, namespaced: true, name: plan?.spec?.provider?.source?.name, @@ -44,7 +45,7 @@ export const PlanResources: React.FC<{ name: string; namespace: string }> = ({ const inventoryOptions: UseProviderInventoryParams = { provider: provider, subPath: 'vms?detail=4', - disabled: !loaded || loadError, + disabled: !loaded || loadError || !providerLoaded || providerLodeError, }; const { @@ -90,6 +91,10 @@ export const PlanResources: React.FC<{ name: string; namespace: string }> = ({ ); default: - return <>; + return ( + + + + ); } }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Details/ProviderDetails.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Details/ProviderDetails.tsx index 20f98deb4..9b3701579 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Details/ProviderDetails.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/tabs/Details/ProviderDetails.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Link } from 'react-router-dom'; import { RouteComponentProps } from 'react-router-dom'; import { SectionHeading } from 'src/components/headers/SectionHeading'; +import { Loading } from 'src/modules/Plans/views/details'; import { useGetDeleteAndEditAccessReview, useProviderInventory } from 'src/modules/Providers/hooks'; import { getResourceUrl, ProviderData } from 'src/modules/Providers/utils'; import { ForkliftTrans, useForkliftTranslation } from 'src/utils/i18n'; @@ -14,7 +15,7 @@ import { V1beta1Provider, } from '@kubev2v/types'; import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk'; -import { Alert, PageSection } from '@patternfly/react-core'; +import { Alert, Bullseye, PageSection } from '@patternfly/react-core'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; import { @@ -37,7 +38,11 @@ export const ProviderDetails: React.FC = ({ obj, loaded, l const { provider, inventory } = obj; if (!loaded || loadError || !provider?.metadata?.name) { - return <>; + return ( + + + + ); } const providerURL = getResourceUrl({