From db8e51f5dc61e3ed231d8d40b40c0d3b8ba62a90 Mon Sep 17 00:00:00 2001 From: Dipanshu Gupta Date: Fri, 1 Sep 2023 22:46:52 +0530 Subject: [PATCH] Update --- .../detail/ProjectDetailsComponents.tsx | 25 +------- .../data-connections/DataConnectionsList.tsx | 59 +++++++++++-------- .../screens/detail/notebooks/NotebookList.tsx | 58 ++++++++++-------- .../detail/pipelines/PipelinesSection.tsx | 56 +++++++++++------- .../screens/detail/storage/StorageList.tsx | 59 +++++++++++-------- 5 files changed, 141 insertions(+), 116 deletions(-) diff --git a/frontend/src/pages/projects/screens/detail/ProjectDetailsComponents.tsx b/frontend/src/pages/projects/screens/detail/ProjectDetailsComponents.tsx index 258366353c..819130f635 100644 --- a/frontend/src/pages/projects/screens/detail/ProjectDetailsComponents.tsx +++ b/frontend/src/pages/projects/screens/detail/ProjectDetailsComponents.tsx @@ -1,12 +1,10 @@ import * as React from 'react'; -import { Divider, PageSection, Stack, StackItem } from '@patternfly/react-core'; +import { PageSection, Stack, StackItem } from '@patternfly/react-core'; import GenericSidebar from '~/components/GenericSidebar'; import { useAppContext } from '~/app/AppContext'; import ServingRuntimeList from '~/pages/modelServing/screens/projects/ServingRuntimeList'; -import { ProjectDetailsContext } from '~/pages/projects/ProjectDetailsContext'; import { featureFlagEnabled } from '~/utilities/utils'; import PipelinesSection from '~/pages/projects/screens/detail/pipelines/PipelinesSection'; -import usePipelines from '~/concepts/pipelines/apiHooks/usePipelines'; import NotebooksList from './notebooks/NotebookList'; import { ProjectSectionID } from './types'; import StorageList from './storage/StorageList'; @@ -17,21 +15,10 @@ import useCheckLogoutParams from './useCheckLogoutParams'; type SectionType = { id: ProjectSectionID; component: React.ReactNode; - isEmpty: boolean; }; const ProjectDetailsComponents: React.FC = () => { const { dashboardConfig } = useAppContext(); - const { - notebooks: { data: notebookStates, loaded: notebookStatesLoaded }, - pvcs: { data: pvcs, loaded: pvcsLoaded }, - dataConnections: { data: connections, loaded: connectionsLoaded }, - servingRuntimes: { data: modelServers, loaded: modelServersLoaded }, - } = React.useContext(ProjectDetailsContext); - - // Limit set to 1 for checking pipeline emptiness - const [pipelines, pipelinesLoaded] = usePipelines(1); - const modelServingEnabled = featureFlagEnabled( dashboardConfig.spec.dashboardConfig.disableModelServing, ); @@ -44,24 +31,20 @@ const ProjectDetailsComponents: React.FC = () => { { id: ProjectSectionID.WORKBENCHES, component: , - isEmpty: notebookStatesLoaded && notebookStates.length === 0, }, { id: ProjectSectionID.CLUSTER_STORAGES, component: , - isEmpty: pvcsLoaded && pvcs.length === 0, }, { id: ProjectSectionID.DATA_CONNECTIONS, component: , - isEmpty: connectionsLoaded && connections.length === 0, }, ...(pipelinesEnabled ? [ { id: ProjectSectionID.PIPELINES, component: , - isEmpty: pipelinesLoaded && pipelines.length === 0, }, ] : []), @@ -70,7 +53,6 @@ const ProjectDetailsComponents: React.FC = () => { { id: ProjectSectionID.MODEL_SERVER, component: , - isEmpty: modelServersLoaded && modelServers.length === 0, }, ] : []), @@ -84,7 +66,7 @@ const ProjectDetailsComponents: React.FC = () => { maxWidth={175} > - {sections.map(({ id, component, isEmpty }, index) => ( + {sections.map(({ id, component }) => ( { > {component} - {index !== sections.length - 1 && isEmpty && ( - - )} ))} diff --git a/frontend/src/pages/projects/screens/detail/data-connections/DataConnectionsList.tsx b/frontend/src/pages/projects/screens/detail/data-connections/DataConnectionsList.tsx index 18d23c0fe7..5bcb15c599 100644 --- a/frontend/src/pages/projects/screens/detail/data-connections/DataConnectionsList.tsx +++ b/frontend/src/pages/projects/screens/detail/data-connections/DataConnectionsList.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Button } from '@patternfly/react-core'; +import { Button, Divider, Stack, StackItem } from '@patternfly/react-core'; import EmptyDetailsList from '~/pages/projects/screens/detail/EmptyDetailsList'; import { ProjectSectionID } from '~/pages/projects/screens/detail/types'; import DetailsSection from '~/pages/projects/screens/detail/DetailsSection'; @@ -15,32 +15,43 @@ const DataConnectionsList: React.FC = () => { } = React.useContext(ProjectDetailsContext); const [open, setOpen] = React.useState(false); + const emptyDataConnections = connections.length === 0; + return ( <> - setOpen(true)} + + + setOpen(true)} + > + Add data connection + , + ]} + isLoading={!loaded} + isEmpty={emptyDataConnections} + loadError={error} + emptyState={ + + } > - Add data connection - , - ]} - isLoading={!loaded} - isEmpty={connections.length === 0} - loadError={error} - emptyState={ - - } - > - - + + + + + {emptyDataConnections && ( + + + + )} { diff --git a/frontend/src/pages/projects/screens/detail/notebooks/NotebookList.tsx b/frontend/src/pages/projects/screens/detail/notebooks/NotebookList.tsx index 0396239c96..9ba7f07b1b 100644 --- a/frontend/src/pages/projects/screens/detail/notebooks/NotebookList.tsx +++ b/frontend/src/pages/projects/screens/detail/notebooks/NotebookList.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Button } from '@patternfly/react-core'; +import { Button, Divider, Stack, StackItem } from '@patternfly/react-core'; import { useNavigate } from 'react-router-dom'; import EmptyDetailsList from '~/pages/projects/screens/detail/EmptyDetailsList'; import { ProjectSectionID } from '~/pages/projects/screens/detail/types'; @@ -17,6 +17,7 @@ const NotebookList: React.FC = () => { } = React.useContext(ProjectDetailsContext); const navigate = useNavigate(); const projectName = currentProject.metadata.name; + const emptyNotebooks = notebookStates.length === 0; React.useEffect(() => { let interval: ReturnType; @@ -27,30 +28,39 @@ const NotebookList: React.FC = () => { }, [notebookStates, refreshNotebooks]); return ( - navigate(`/projects/${projectName}/spawner`)} - variant="secondary" + + + navigate(`/projects/${projectName}/spawner`)} + variant="secondary" + > + Create workbench + , + ]} + isLoading={!loaded} + loadError={loadError} + isEmpty={emptyNotebooks} + emptyState={ + + } > - Create workbench - , - ]} - isLoading={!loaded} - loadError={loadError} - isEmpty={notebookStates.length === 0} - emptyState={ - - } - > - - + + + + {emptyNotebooks && ( + + + + )} + ); }; diff --git a/frontend/src/pages/projects/screens/detail/pipelines/PipelinesSection.tsx b/frontend/src/pages/projects/screens/detail/pipelines/PipelinesSection.tsx index ed36a91cd9..65b48ebb1e 100644 --- a/frontend/src/pages/projects/screens/detail/pipelines/PipelinesSection.tsx +++ b/frontend/src/pages/projects/screens/detail/pipelines/PipelinesSection.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import { Divider, Stack, StackItem } from '@patternfly/react-core'; import { ProjectSectionID } from '~/pages/projects/screens/detail/types'; import { ProjectSectionTitles } from '~/pages/projects/screens/detail/const'; import DetailsSection from '~/pages/projects/screens/detail/DetailsSection'; @@ -7,35 +8,48 @@ import NoPipelineServer from '~/concepts/pipelines/NoPipelineServer'; import ImportPipelineButton from '~/concepts/pipelines/content/import/ImportPipelineButton'; import PipelinesList from '~/pages/projects/screens/detail/pipelines/PipelinesList'; import EnsureAPIAvailability from '~/concepts/pipelines/EnsureAPIAvailability'; +import usePipelines from '~/concepts/pipelines/apiHooks/usePipelines'; const PipelinesSection: React.FC = () => { const { pipelinesServer: { initializing, installed, timedOut }, } = usePipelinesAPI(); + const [pipelines] = usePipelines(1); + const pipelinesEmpty = !installed || pipelines.length === 0; + return ( - , - ]} - isLoading={initializing} - isEmpty={!installed} - emptyState={} - > - {timedOut ? ( - - ) : ( - - - + + + , + ]} + isLoading={initializing} + isEmpty={!installed} + emptyState={} + > + {timedOut ? ( + + ) : ( + + + + )} + + + {pipelinesEmpty && ( + + + )} - + ); }; diff --git a/frontend/src/pages/projects/screens/detail/storage/StorageList.tsx b/frontend/src/pages/projects/screens/detail/storage/StorageList.tsx index 439f8f86b8..90f247b19d 100644 --- a/frontend/src/pages/projects/screens/detail/storage/StorageList.tsx +++ b/frontend/src/pages/projects/screens/detail/storage/StorageList.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Button } from '@patternfly/react-core'; +import { Button, Divider, Stack, StackItem } from '@patternfly/react-core'; import EmptyDetailsList from '~/pages/projects/screens/detail/EmptyDetailsList'; import DetailsSection from '~/pages/projects/screens/detail/DetailsSection'; import { ProjectSectionID } from '~/pages/projects/screens/detail/types'; @@ -15,32 +15,43 @@ const StorageList: React.FC = () => { refreshAllProjectData: refresh, } = React.useContext(ProjectDetailsContext); + const emptyPvsc = pvcs.length === 0; + return ( <> - setOpen(true)} - key={`action-${ProjectSectionID.CLUSTER_STORAGES}`} - variant="secondary" + + + setOpen(true)} + key={`action-${ProjectSectionID.CLUSTER_STORAGES}`} + variant="secondary" + > + Add cluster storage + , + ]} + isLoading={!loaded} + isEmpty={emptyPvsc} + loadError={loadError} + emptyState={ + + } > - Add cluster storage - , - ]} - isLoading={!loaded} - isEmpty={pvcs.length === 0} - loadError={loadError} - emptyState={ - - } - > - setOpen(true)} /> - + setOpen(true)} /> + + + {emptyPvsc && ( + + + + )} + {