From b00b3ed67b27e2be339626ff7a2b245fed4e9008 Mon Sep 17 00:00:00 2001 From: gitdallas <5322142+gitdallas@users.noreply.github.com> Date: Sun, 7 Apr 2024 08:02:48 -0500 Subject: [PATCH] factoring sharedstates into their own componeonts Signed-off-by: gitdallas <5322142+gitdallas@users.noreply.github.com> squash Signed-off-by: gitdallas <5322142+gitdallas@users.noreply.github.com> sq Signed-off-by: gitdallas <5322142+gitdallas@users.noreply.github.com> --- .../components/LoadingState.tsx | 8 ++++++++ .../{SharedStates.tsx => NoWorkloadState.tsx} | 14 +++----------- .../projectMetrics/sections/RequestedResources.tsx | 2 +- .../sections/TopResourceConsumingWorkloads.tsx | 6 ++---- .../sections/WorkloadResourceMetricsTable.tsx | 6 ++---- .../workloadStatus/DWStatusOverviewDonutChart.tsx | 2 +- .../global/workloadStatus/DWWorkloadsTable.tsx | 2 +- 7 files changed, 18 insertions(+), 22 deletions(-) create mode 100644 frontend/src/pages/distributedWorkloads/components/LoadingState.tsx rename frontend/src/pages/distributedWorkloads/components/{SharedStates.tsx => NoWorkloadState.tsx} (72%) diff --git a/frontend/src/pages/distributedWorkloads/components/LoadingState.tsx b/frontend/src/pages/distributedWorkloads/components/LoadingState.tsx new file mode 100644 index 0000000000..56848cb7a7 --- /dev/null +++ b/frontend/src/pages/distributedWorkloads/components/LoadingState.tsx @@ -0,0 +1,8 @@ +import { Bullseye, Spinner } from '@patternfly/react-core'; +import React from 'react'; + +export const LoadingState: React.FC = () => ( + + + +); diff --git a/frontend/src/pages/distributedWorkloads/components/SharedStates.tsx b/frontend/src/pages/distributedWorkloads/components/NoWorkloadState.tsx similarity index 72% rename from frontend/src/pages/distributedWorkloads/components/SharedStates.tsx rename to frontend/src/pages/distributedWorkloads/components/NoWorkloadState.tsx index 4d8ffb33c1..1c9af16fe9 100644 --- a/frontend/src/pages/distributedWorkloads/components/SharedStates.tsx +++ b/frontend/src/pages/distributedWorkloads/components/NoWorkloadState.tsx @@ -1,13 +1,11 @@ -import * as React from 'react'; import { - Bullseye, - Spinner, EmptyState, - EmptyStateBody, EmptyStateHeader, EmptyStateIcon, + EmptyStateBody, } from '@patternfly/react-core'; -import { CubesIcon, ExclamationTriangleIcon } from '@patternfly/react-icons'; +import { ExclamationTriangleIcon, CubesIcon } from '@patternfly/react-icons'; +import React from 'react'; export const NoWorkloadState: React.FC<{ title?: string; subTitle?: string; warn?: boolean }> = ({ title = 'No distributed workloads', @@ -23,9 +21,3 @@ export const NoWorkloadState: React.FC<{ title?: string; subTitle?: string; warn {subTitle} ); - -export const LoadingState: React.FC = () => ( - - - -); diff --git a/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/RequestedResources.tsx b/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/RequestedResources.tsx index c85288b9f6..45ff1369c8 100644 --- a/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/RequestedResources.tsx +++ b/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/RequestedResources.tsx @@ -14,7 +14,7 @@ import { } from '~/concepts/distributedWorkloads/utils'; import { bytesAsPreciseGiB, roundNumber } from '~/utilities/number'; import EmptyStateErrorMessage from '~/components/EmptyStateErrorMessage'; -import { LoadingState } from '~/pages/distributedWorkloads/components/SharedStates'; +import { LoadingState } from '~/pages/distributedWorkloads/components/LoadingState'; type RequestedResourcesBulletChartProps = { title: string; diff --git a/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/TopResourceConsumingWorkloads.tsx b/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/TopResourceConsumingWorkloads.tsx index cea55a5914..1134a26aa6 100644 --- a/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/TopResourceConsumingWorkloads.tsx +++ b/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/TopResourceConsumingWorkloads.tsx @@ -4,10 +4,8 @@ import { ChartLegend, ChartLabel, ChartDonut, ChartThemeColor } from '@patternfl import { DistributedWorkloadsContext } from '~/concepts/distributedWorkloads/DistributedWorkloadsContext'; import { WorkloadStatusType, getStatusInfo } from '~/concepts/distributedWorkloads/utils'; import EmptyStateErrorMessage from '~/components/EmptyStateErrorMessage'; -import { - LoadingState, - NoWorkloadState, -} from '~/pages/distributedWorkloads/components/SharedStates'; +import { LoadingState } from '~/pages/distributedWorkloads/components/LoadingState'; +import { NoWorkloadState } from '~/pages/distributedWorkloads/components/NoWorkloadState'; //TODO: next 4 utility functions to be replaced or moved into a utility class const memoryBytesToGibStr = (bytes: number, excludeUnit = false): string => { diff --git a/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/WorkloadResourceMetricsTable.tsx b/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/WorkloadResourceMetricsTable.tsx index ea0a3b4c08..f4f9c9965e 100644 --- a/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/WorkloadResourceMetricsTable.tsx +++ b/frontend/src/pages/distributedWorkloads/global/projectMetrics/sections/WorkloadResourceMetricsTable.tsx @@ -12,10 +12,8 @@ import { import { bytesAsPreciseGiB } from '~/utilities/number'; import { WorkloadKind } from '~/k8sTypes'; import EmptyStateErrorMessage from '~/components/EmptyStateErrorMessage'; -import { - LoadingState, - NoWorkloadState, -} from '~/pages/distributedWorkloads/components/SharedStates'; +import { LoadingState } from '~/pages/distributedWorkloads/components/LoadingState'; +import { NoWorkloadState } from '~/pages/distributedWorkloads/components/NoWorkloadState'; export const WorkloadResourceMetricsTable: React.FC = () => { const { workloads, projectCurrentMetrics } = React.useContext(DistributedWorkloadsContext); diff --git a/frontend/src/pages/distributedWorkloads/global/workloadStatus/DWStatusOverviewDonutChart.tsx b/frontend/src/pages/distributedWorkloads/global/workloadStatus/DWStatusOverviewDonutChart.tsx index 65ec8a3f0d..edd6228912 100644 --- a/frontend/src/pages/distributedWorkloads/global/workloadStatus/DWStatusOverviewDonutChart.tsx +++ b/frontend/src/pages/distributedWorkloads/global/workloadStatus/DWStatusOverviewDonutChart.tsx @@ -7,7 +7,7 @@ import { WorkloadStatusType, getStatusCounts, } from '~/concepts/distributedWorkloads/utils'; -import { LoadingState } from '~/pages/distributedWorkloads/components/SharedStates'; +import { LoadingState } from '~/pages/distributedWorkloads/components/LoadingState'; export const DWStatusOverviewDonutChart: React.FC = () => { const { workloads } = React.useContext(DistributedWorkloadsContext); diff --git a/frontend/src/pages/distributedWorkloads/global/workloadStatus/DWWorkloadsTable.tsx b/frontend/src/pages/distributedWorkloads/global/workloadStatus/DWWorkloadsTable.tsx index eb0b9f8853..dceb57d731 100644 --- a/frontend/src/pages/distributedWorkloads/global/workloadStatus/DWWorkloadsTable.tsx +++ b/frontend/src/pages/distributedWorkloads/global/workloadStatus/DWWorkloadsTable.tsx @@ -7,7 +7,7 @@ import { SortableData, Table } from '~/components/table'; import { WorkloadKind } from '~/k8sTypes'; import { getStatusInfo } from '~/concepts/distributedWorkloads/utils'; import { WorkloadStatusLabel } from '~/pages/distributedWorkloads/components/WorkloadStatusLabel'; -import { NoWorkloadState } from '~/pages/distributedWorkloads/components/SharedStates'; +import { NoWorkloadState } from '~/pages/distributedWorkloads/components/NoWorkloadState'; export const DWWorkloadsTable: React.FC = () => { const { workloads } = React.useContext(DistributedWorkloadsContext);