11import * as React from 'react' ;
2- import type { ReactElement , ElementType } from 'react' ;
2+ import type { ReactNode , ElementType } from 'react' ;
33import {
44 Card ,
55 type ComponentsOverrides ,
@@ -12,8 +12,10 @@ import clsx from 'clsx';
1212import { useShowContext , useResourceDefinition } from 'ra-core' ;
1313import { ShowActions } from './ShowActions' ;
1414import { Title } from '../layout' ;
15+ import { Offline } from '../Offline' ;
1516
1617const defaultActions = < ShowActions /> ;
18+ const defaultOffline = < Offline /> ;
1719
1820export const ShowView = ( inProps : ShowViewProps ) => {
1921 const props = useThemeProps ( {
@@ -27,13 +29,30 @@ export const ShowView = (inProps: ShowViewProps) => {
2729 className,
2830 component : Content = Card ,
2931 emptyWhileLoading = false ,
32+ offline = defaultOffline ,
3033 title,
3134 ...rest
3235 } = props ;
3336
34- const { resource, defaultTitle, record } = useShowContext ( ) ;
37+ const { resource, defaultTitle, isPaused , record } = useShowContext ( ) ;
3538 const { hasEdit } = useResourceDefinition ( ) ;
3639
40+ if ( isPaused && offline ) {
41+ return (
42+ < Root className = { clsx ( 'show-page' , className ) } { ...rest } >
43+ < div
44+ className = { clsx (
45+ ShowClasses . main ,
46+ ShowClasses . noActions ,
47+ ShowClasses . offline
48+ ) }
49+ >
50+ { offline }
51+ </ div >
52+ </ Root >
53+ ) ;
54+ }
55+
3756 const finalActions =
3857 typeof actions === 'undefined' && hasEdit ? defaultActions : actions ;
3958
@@ -64,11 +83,12 @@ export const ShowView = (inProps: ShowViewProps) => {
6483
6584export interface ShowViewProps
6685 extends Omit < React . HTMLAttributes < HTMLDivElement > , 'id' | 'title' > {
67- actions ?: ReactElement | false ;
68- aside ?: ReactElement ;
86+ actions ?: ReactNode ;
87+ aside ?: ReactNode ;
6988 component ?: ElementType ;
7089 emptyWhileLoading ?: boolean ;
71- title ?: string | ReactElement | false ;
90+ offline ?: ReactNode ;
91+ title ?: ReactNode ;
7292 sx ?: SxProps < Theme > ;
7393}
7494
@@ -78,6 +98,7 @@ export const ShowClasses = {
7898 main : `${ PREFIX } -main` ,
7999 noActions : `${ PREFIX } -noActions` ,
80100 card : `${ PREFIX } -card` ,
101+ offline : `${ PREFIX } -offline` ,
81102} ;
82103
83104const Root = styled ( 'div' , {
@@ -90,6 +111,10 @@ const Root = styled('div', {
90111 [ `& .${ ShowClasses . noActions } ` ] : {
91112 marginTop : '1em' ,
92113 } ,
114+ [ `& .${ ShowClasses . offline } ` ] : {
115+ flexDirection : 'column' ,
116+ alignItems : 'unset' ,
117+ } ,
93118 [ `& .${ ShowClasses . card } ` ] : {
94119 flex : '1 1 auto' ,
95120 } ,
0 commit comments