11import { ReactElement , useMemo , useState } from 'react' ;
22import { CheckIcon , GitCompareIcon } from 'lucide-react' ;
33import { useQuery } from 'urql' ;
4+ import { NotFoundContent } from '@/components/common/not-found-content' ;
45import {
56 ChangesBlock ,
67 CompositionErrorsSection ,
@@ -15,7 +16,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/comp
1516import { DiffEditor , TimeAgo } from '@/components/v2' ;
1617import { FragmentType , graphql , useFragment } from '@/gql' ;
1718import { ProjectType , SeverityLevelType } from '@/gql/graphql' ;
18- import { cn } from '@/lib/utils' ;
19+ import { cn , isValidUUID } from '@/lib/utils' ;
1920import {
2021 CheckCircledIcon ,
2122 CrossCircledIcon ,
@@ -242,15 +243,11 @@ const DefaultSchemaVersionView_SchemaVersionFragment = graphql(`
242243 log {
243244 ... on PushedSchemaLog {
244245 id
245- author
246- service
247- commit
248246 serviceSdl
249247 previousServiceSdl
250248 }
251249 ... on DeletedSchemaLog {
252250 id
253- deletedService
254251 previousServiceSdl
255252 }
256253 }
@@ -443,9 +440,6 @@ function DefaultSchemaVersionView(props: {
443440const ContractVersionView_ContractVersionFragment = graphql ( `
444441 fragment ContractVersionView_ContractVersionFragment on ContractVersion {
445442 id
446- contractName
447- isComposable
448- hasSchemaChanges
449443 isFirstComposableVersion
450444 supergraphSDL
451445 compositeSchemaSDL
@@ -640,6 +634,8 @@ function ActiveSchemaVersion(props: {
640634 projectSlug : string ;
641635 targetSlug : string ;
642636} ) {
637+ const isValidVersionId = isValidUUID ( props . versionId ) ;
638+
643639 const [ query ] = useQuery ( {
644640 query : ActiveSchemaVersion_SchemaVersionQuery ,
645641 variables : {
@@ -648,6 +644,7 @@ function ActiveSchemaVersion(props: {
648644 targetSlug : props . targetSlug ,
649645 versionId : props . versionId ,
650646 } ,
647+ pause : ! isValidVersionId ,
651648 } ) ;
652649
653650 const { error } = query ;
@@ -657,7 +654,28 @@ function ActiveSchemaVersion(props: {
657654 const schemaVersion = project ?. target ?. schemaVersion ;
658655 const projectType = query . data ?. project ?. type ;
659656
660- if ( isLoading || ! schemaVersion || ! projectType ) {
657+ // Order of these conditionals is important...relocate carefully!
658+ if ( ! isValidVersionId ) {
659+ return (
660+ < NotFoundContent
661+ heading = "Invalid version ID"
662+ subheading = "The provided version ID is not a valid UUID format."
663+ includeBackButton = { false }
664+ />
665+ ) ;
666+ }
667+
668+ if ( ! isLoading && ! schemaVersion ) {
669+ return (
670+ < NotFoundContent
671+ heading = "Version ID does not exist"
672+ subheading = "The provided version ID is not in our database."
673+ includeBackButton = { false }
674+ />
675+ ) ;
676+ }
677+
678+ if ( isLoading || ! projectType ) {
661679 return (
662680 < div className = "flex size-full flex-col items-center justify-center self-center text-sm text-gray-500" >
663681 < Spinner className = "mb-3 size-8" />
0 commit comments