1- import { ReactElement } from 'react' ;
1+ import { ReactElement , ReactNode } from 'react' ;
22import magnifier from '../../../public/images/figures/magnifier.svg?url' ;
3+ import { ProjectType } from '@/gql/graphql' ;
34import { cn } from '@/lib/utils' ;
45import { Card } from './card' ;
6+ import { Code } from './code' ;
57import { DocsLink } from './docs-note' ;
68import { Heading } from './heading' ;
79
@@ -10,15 +12,17 @@ export const EmptyList = ({
1012 description,
1113 docsUrl,
1214 className,
15+ children,
1316} : {
1417 title : string ;
1518 description : string ;
1619 docsUrl ?: string | null ;
20+ children ?: ReactNode | null ;
1721 className ?: string ;
1822} ) : ReactElement => {
1923 return (
2024 < Card
21- className = { cn ( 'flex grow cursor-default flex-col items-center gap-y-2 py -4' , className ) }
25+ className = { cn ( 'flex grow cursor-default flex-col items-center gap-y-2 p -4' , className ) }
2226 data-cy = "empty-list"
2327 >
2428 < img
@@ -30,6 +34,7 @@ export const EmptyList = ({
3034 />
3135 < Heading className = "text-center" > { title } </ Heading >
3236 < span className = "text-center text-sm font-medium text-gray-500" > { description } </ span >
37+ { children }
3338 { docsUrl && < DocsLink href = { docsUrl } > Read about it in the documentation</ DocsLink > }
3439 </ Card >
3540 ) ;
@@ -43,13 +48,61 @@ export const noSchema = (
4348 />
4449) ;
4550
46- export const noSchemaVersion = (
47- < EmptyList
48- title = "Hive is waiting for your first schema"
49- description = "You can publish a schema with Hive CLI and Hive Client"
50- docsUrl = "/features/schema-registry#publish-a-schema"
51- />
52- ) ;
51+ export const NoSchemaVersion = ( {
52+ projectType = null ,
53+ recommendedAction = 'none' ,
54+ } : {
55+ projectType : ProjectType | null ;
56+ recommendedAction : 'publish' | 'check' | 'none' ;
57+ } ) : ReactElement => {
58+ let children : ReactElement | null = null ;
59+ if ( recommendedAction !== 'none' ) {
60+ const isDistributed =
61+ projectType === ProjectType . Federation || projectType === ProjectType . Stitching ;
62+
63+ if ( recommendedAction === 'check' ) {
64+ children = (
65+ < >
66+ < div className = "flex w-full justify-center py-2 text-xs text-gray-500" >
67+ It's recommended to check that the schema is valid and compatible with the state of the
68+ registry before publishing.
69+ </ div >
70+ < div className = "flex w-full justify-center" >
71+ < Code >
72+ { `hive schema:check ${ isDistributed ? '--service <service-name> --url <url> ' : '' } --target "<org>/<project>/<target>" <path/schema.graphql>` }
73+ </ Code >
74+ </ div >
75+ </ >
76+ ) ;
77+ } else if ( recommendedAction === 'publish' ) {
78+ children = (
79+ < >
80+ { isDistributed && (
81+ < div className = "flex w-full justify-center py-2 text-xs text-gray-500" >
82+ For distributed systems, it's recommended to publish the schema after the service is
83+ deployed.
84+ </ div >
85+ ) }
86+ < div className = "flex w-full justify-center" >
87+ < Code >
88+ { `hive schema:publish ${ isDistributed ? '--service <service-name> --url <url> ' : '' } --target "<org>/<project>/<target>" <path/schema.graphql>` }
89+ </ Code >
90+ </ div >
91+ </ >
92+ ) ;
93+ }
94+ }
95+
96+ return (
97+ < EmptyList
98+ title = "Hive is waiting for your first schema"
99+ description = "You can publish a schema with Hive CLI and Hive Client"
100+ docsUrl = "/features/schema-registry#publish-a-schema"
101+ >
102+ { children }
103+ </ EmptyList >
104+ ) ;
105+ } ;
53106
54107export const noValidSchemaVersion = (
55108 < EmptyList
0 commit comments