1
- import { ReactElement } from 'react' ;
1
+ import { ReactElement , ReactNode } from 'react' ;
2
2
import magnifier from '../../../public/images/figures/magnifier.svg?url' ;
3
+ import { ProjectType } from '@/gql/graphql' ;
3
4
import { cn } from '@/lib/utils' ;
4
5
import { Card } from './card' ;
6
+ import { Code } from './code' ;
5
7
import { DocsLink } from './docs-note' ;
6
8
import { Heading } from './heading' ;
7
9
@@ -10,15 +12,17 @@ export const EmptyList = ({
10
12
description,
11
13
docsUrl,
12
14
className,
15
+ children,
13
16
} : {
14
17
title : string ;
15
18
description : string ;
16
19
docsUrl ?: string | null ;
20
+ children ?: ReactNode | null ;
17
21
className ?: string ;
18
22
} ) : ReactElement => {
19
23
return (
20
24
< 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 ) }
22
26
data-cy = "empty-list"
23
27
>
24
28
< img
@@ -30,6 +34,7 @@ export const EmptyList = ({
30
34
/>
31
35
< Heading className = "text-center" > { title } </ Heading >
32
36
< span className = "text-center text-sm font-medium text-gray-500" > { description } </ span >
37
+ { children }
33
38
{ docsUrl && < DocsLink href = { docsUrl } > Read about it in the documentation</ DocsLink > }
34
39
</ Card >
35
40
) ;
@@ -43,13 +48,61 @@ export const noSchema = (
43
48
/>
44
49
) ;
45
50
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
+ } ;
53
106
54
107
export const noValidSchemaVersion = (
55
108
< EmptyList
0 commit comments