Skip to content

Commit 27f25e4

Browse files
committed
Separate check noschema from others; adjust ui per feedback
1 parent 46c4ccf commit 27f25e4

11 files changed

+93
-46
lines changed

packages/web/app/src/components/ui/empty-list.tsx

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ReactElement, ReactNode } from 'react';
22
import magnifier from '../../../public/images/figures/magnifier.svg?url';
33
import { ProjectType } from '@/gql/graphql';
44
import { cn } from '@/lib/utils';
5+
import { InlineCode } from '../v2/inline-code';
56
import { Card } from './card';
67
import { DocsLink } from './docs-note';
78
import { Heading } from './heading';
@@ -48,41 +49,58 @@ export const noSchema = (
4849
/>
4950
);
5051

51-
// @todo consider monolith vs distributed etc
5252
export const NoSchemaVersion = ({
53-
projectType,
53+
projectType = null,
54+
recommendedAction = 'none',
5455
}: {
5556
projectType: ProjectType | null;
57+
recommendedAction: 'publish' | 'check' | 'none';
5658
}): ReactElement => {
57-
const isDistributed =
58-
projectType === ProjectType.Federation || projectType === ProjectType.Stitching;
59+
let children: ReactElement | null = null;
60+
if (recommendedAction !== 'none') {
61+
const isDistributed =
62+
projectType === ProjectType.Federation || projectType === ProjectType.Stitching;
63+
64+
if (recommendedAction === 'check') {
65+
children = (
66+
<>
67+
<div className="flex w-full justify-center py-2 text-xs text-gray-500">
68+
It's recommended to check that the schema is valid and compatible with the state of the
69+
registry before publishing.
70+
</div>
71+
<div className="flex w-full justify-center">
72+
<InlineCode
73+
content={`hive schema:check ${isDistributed ? '--service <service-name> --url <url> ' : ''}<path/schema.graphql>`}
74+
/>
75+
</div>
76+
</>
77+
);
78+
} else if (recommendedAction === 'publish') {
79+
children = (
80+
<>
81+
{isDistributed && (
82+
<div className="flex w-full justify-center py-2 text-xs text-gray-500">
83+
For distributed systems, it's recommended to publish the schema after the service is
84+
deployed.
85+
</div>
86+
)}
87+
<div className="flex w-full justify-center">
88+
<InlineCode
89+
content={`hive schema:publish ${isDistributed ? '--service <service-name> --url <url> ' : ''}<path/schema.graphql>`}
90+
/>
91+
</div>
92+
</>
93+
);
94+
}
95+
}
96+
5997
return (
6098
<EmptyList
6199
title="Hive is waiting for your first schema"
62100
description="You can publish a schema with Hive CLI and Hive Client"
63101
docsUrl="/features/schema-registry#publish-a-schema"
64102
>
65-
<>
66-
<div className="flex w-full justify-center py-2 text-xs text-gray-500">
67-
First check that the schema is valid and compatible with the state of the registry.
68-
</div>
69-
<div className="flex w-full justify-center">
70-
<InputCopy
71-
value={`hive schema:check ${isDistributed ? '--service <service-name> --url <url> ' : ''}<path/schema.graphql>`}
72-
alignment="center"
73-
/>
74-
</div>
75-
<div className="flex w-full justify-center py-2 text-xs text-gray-500">
76-
Then publish the schema. For distributed systems, it's recommended to publish the schema
77-
after the service is deployed.
78-
</div>
79-
<div className="flex w-full justify-center">
80-
<InputCopy
81-
value={`hive schema:publish ${isDistributed ? '--service <service-name> --url <url> ' : ''}<path/schema.graphql>`}
82-
alignment="center"
83-
/>
84-
</div>
85-
</>
103+
{children}
86104
</EmptyList>
87105
);
88106
};

packages/web/app/src/components/ui/input-copy.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button';
44
import { Input } from '@/components/ui/input';
55
import { useClipboard } from '@/lib/hooks';
66

7-
export function InputCopy(props: { value: string; alignment?: 'center' | 'left' }) {
7+
export function InputCopy(props: { value: string }) {
88
const [isCopied, setIsCopied] = useState(false);
99
const copyToClipboard = useClipboard();
1010

@@ -31,7 +31,7 @@ export function InputCopy(props: { value: string; alignment?: 'center' | 'left'
3131
type="text"
3232
value={props.value}
3333
readOnly
34-
className={`bg-secondary truncate text-white ${props.alignment === 'center' ? 'text-center' : ''}`}
34+
className="bg-secondary truncate text-white"
3535
onFocus={ev => ev.target.select()}
3636
/>
3737
</div>

packages/web/app/src/pages/target-apps.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ function TargetAppsView(props: {
258258
</div>
259259
</div>
260260
) : !data.data?.target?.latestSchemaVersion ? (
261-
<NoSchemaVersion projectType={data.data?.target?.project?.type ?? null} />
261+
<NoSchemaVersion
262+
recommendedAction="publish"
263+
projectType={data.data?.target?.project?.type ?? null}
264+
/>
262265
) : !data.data.target.appDeployments ? (
263266
<EmptyList
264267
title="Hive is waiting for your first app deployment"

packages/web/app/src/pages/target-checks.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Page, TargetLayout } from '@/components/layouts/target';
44
import { BadgeRounded } from '@/components/ui/badge';
55
import { Button } from '@/components/ui/button';
66
import { DocsLink } from '@/components/ui/docs-note';
7-
import { EmptyList } from '@/components/ui/empty-list';
7+
import { EmptyList, NoSchemaVersion } from '@/components/ui/empty-list';
88
import { Label } from '@/components/ui/label';
99
import { Meta } from '@/components/ui/meta';
1010
import { Subtitle, Title } from '@/components/ui/page';
@@ -196,6 +196,10 @@ const ChecksPageQuery = graphql(`
196196
}
197197
) {
198198
id
199+
project {
200+
id
201+
type
202+
}
199203
schemaChecks(first: 1) {
200204
edges {
201205
node {
@@ -359,7 +363,14 @@ function ChecksPageContent(props: {
359363
) : (
360364
<div>
361365
<div className="cursor-default text-sm">
362-
{hasActiveSchemaCheck ? 'List is empty' : 'Your schema check list is empty'}
366+
{hasActiveSchemaCheck ? (
367+
'List is empty'
368+
) : (
369+
<NoSchemaVersion
370+
projectType={query.data?.target?.project.type ?? null}
371+
recommendedAction="check"
372+
/>
373+
)}
363374
</div>
364375
<DocsLink href="/features/schema-registry#check-a-schema">
365376
{hasActiveSchemaCheck

packages/web/app/src/pages/target-explorer-deprecated.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,10 @@ function DeprecatedSchemaExplorer(props: {
307307
/>
308308
</>
309309
) : (
310-
<NoSchemaVersion projectType={query.data?.target?.project?.type ?? null} />
310+
<NoSchemaVersion
311+
recommendedAction="publish"
312+
projectType={query.data?.target?.project?.type ?? null}
313+
/>
311314
)}
312315
</>
313316
)}

packages/web/app/src/pages/target-explorer-type.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ function TypeExplorerPageContent(props: {
267267
styleDeprecated
268268
/>
269269
) : type ? (
270-
<NoSchemaVersion projectType={query.data?.target?.project?.type ?? null} />
270+
<NoSchemaVersion
271+
recommendedAction="publish"
272+
projectType={query.data?.target?.project?.type ?? null}
273+
/>
271274
) : (
272275
<div>Not found</div>
273276
)}

packages/web/app/src/pages/target-explorer-unused.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ function UnusedSchemaExplorer(props: {
359359
/>
360360
</>
361361
) : (
362-
<NoSchemaVersion projectType={query.data?.target?.project.type} />
362+
<NoSchemaVersion
363+
recommendedAction="publish"
364+
projectType={query.data?.target?.project.type}
365+
/>
363366
)}
364367
</>
365368
)}

packages/web/app/src/pages/target-explorer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ function ExplorerPageContent(props: {
273273
) : latestSchemaVersion ? (
274274
noValidSchemaVersion
275275
) : (
276-
<NoSchemaVersion projectType={query.data?.target?.project.type ?? null} />
276+
<NoSchemaVersion
277+
projectType={query.data?.target?.project.type ?? null}
278+
recommendedAction="publish"
279+
/>
277280
)}
278281
</>
279282
)}

packages/web/app/src/pages/target-history.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,10 @@ function HistoryPageContent(props: {
273273
<Subtitle>Recently published schemas.</Subtitle>
274274
</div>
275275
{query.fetching ? null : (
276-
<NoSchemaVersion projectType={query.data?.target?.project.type ?? null} />
276+
<NoSchemaVersion
277+
recommendedAction="publish"
278+
projectType={query.data?.target?.project.type ?? null}
279+
/>
277280
)}
278281
</div>
279282
);

packages/web/app/src/pages/target.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function SchemaView(props: {
169169

170170
const { latestSchemaVersion } = target;
171171
if (!latestSchemaVersion) {
172-
return <NoSchemaVersion projectType={project.type} />;
172+
return <NoSchemaVersion recommendedAction="publish" projectType={project.type} />;
173173
}
174174

175175
if (!latestSchemaVersion.schemas.nodes.length) {

0 commit comments

Comments
 (0)