@@ -3,7 +3,9 @@ import { ProjectsContext } from '@odh-dashboard/internal/concepts/projects/Proje
33import { useExtensions , useResolvedExtensions } from '@odh-dashboard/plugin-core' ;
44import { Bullseye , Spinner } from '@patternfly/react-core' ;
55import { useNavigate , useParams } from 'react-router-dom' ;
6+ import ApplicationsPage from '@odh-dashboard/internal/pages/ApplicationsPage' ;
67import GlobalDeploymentsView from './components/global/GlobalDeploymentsView' ;
8+ import NoProjectsPage from './components/global/NoProjectsPage' ;
79import { ModelDeploymentsProvider } from './concepts/ModelDeploymentsContext' ;
810import { ModelServingPlatformProvider } from './concepts/ModelServingPlatformContext' ;
911import {
@@ -17,14 +19,20 @@ const GlobalModelsPage: React.FC = () => (
1719 </ ModelServingPlatformProvider >
1820) ;
1921
22+ type ApplicationPageProps = React . ComponentProps < typeof ApplicationsPage > ;
23+ type EmptyStateProps = 'emptyStatePage' | 'empty' ;
24+ type ApplicationPageRenderState = Pick < ApplicationPageProps , EmptyStateProps > ;
25+
2026const GlobalModelsPageCoreLoader : React . FC = ( ) => {
2127 const availablePlatforms = useExtensions ( isModelServingPlatformExtension ) ;
2228 const [ deploymentWatchers ] = useResolvedExtensions ( isModelServingPlatformWatchDeployments ) ;
29+
2330 const {
2431 projects,
2532 loaded : projectsLoaded ,
2633 preferredProject : currentProject ,
2734 } = React . useContext ( ProjectsContext ) ;
35+
2836 const selectedProject = currentProject
2937 ? projects . find ( ( project ) => project . metadata . name === currentProject . metadata . name )
3038 : null ;
@@ -34,9 +42,12 @@ const GlobalModelsPageCoreLoader: React.FC = () => {
3442
3543 React . useEffect ( ( ) => {
3644 if ( ! namespace && currentProject ) {
37- navigate ( `/modelServing /${ currentProject . metadata . name } ` , { replace : true } ) ;
45+ navigate ( `/model-serving /${ currentProject . metadata . name } ` , { replace : true } ) ;
3846 }
3947 } , [ namespace , currentProject , navigate ] ) ;
48+ let renderStateProps : ApplicationPageRenderState & { children ?: React . ReactNode } = {
49+ empty : false ,
50+ } ;
4051
4152 if ( ! projectsLoaded ) {
4253 return (
@@ -45,16 +56,21 @@ const GlobalModelsPageCoreLoader: React.FC = () => {
4556 </ Bullseye >
4657 ) ;
4758 }
59+
4860 if ( projects . length === 0 ) {
49- return < div > No projects found component</ div > ;
61+ renderStateProps = {
62+ empty : true ,
63+ emptyStatePage : < NoProjectsPage /> ,
64+ } ;
5065 }
66+
5167 return (
5268 < ModelDeploymentsProvider
5369 modelServingPlatforms = { availablePlatforms }
5470 projects = { projectsToShow }
5571 deploymentWatchers = { deploymentWatchers }
5672 >
57- < GlobalDeploymentsView currentProject = { selectedProject } />
73+ < GlobalDeploymentsView { ... renderStateProps } currentProject = { selectedProject } />
5874 </ ModelDeploymentsProvider >
5975 ) ;
6076} ;
0 commit comments