diff --git a/packages/console/src/pages/Applications/components/Guide/index.module.scss b/packages/console/src/pages/Applications/components/Guide/index.module.scss index 855121e7c..a6d35b1a5 100644 --- a/packages/console/src/pages/Applications/components/Guide/index.module.scss +++ b/packages/console/src/pages/Applications/components/Guide/index.module.scss @@ -55,6 +55,14 @@ margin-top: _.unit(6); } +.notFound { + width: 100%; + + svg { + margin-top: 10%; + } +} + .actionBar { position: absolute; inset: auto 0 0 0; diff --git a/packages/console/src/pages/Applications/components/Guide/index.tsx b/packages/console/src/pages/Applications/components/Guide/index.tsx index 478fd8478..2f488f71e 100644 --- a/packages/console/src/pages/Applications/components/Guide/index.tsx +++ b/packages/console/src/pages/Applications/components/Guide/index.tsx @@ -12,6 +12,7 @@ import CodeEditor from '@/ds-components/CodeEditor'; import TextLink from '@/ds-components/TextLink'; import useCustomDomain from '@/hooks/use-custom-domain'; import DetailsSummary from '@/mdx-components/DetailsSummary'; +import NotFound from '@/pages/NotFound'; import GuideHeader from '../GuideHeader'; import StepsSkeleton from '../StepsSkeleton'; @@ -50,7 +51,7 @@ export const GuideContext = createContext({ type Props = { className?: string; guideId: string; - app?: ApplicationResponse; + app: ApplicationResponse; isCompact?: boolean; onClose: () => void; }; @@ -61,28 +62,26 @@ function Guide({ className, guideId, app, isCompact, onClose }: Props) { const isCustomDomainActive = customDomain?.status === DomainStatus.Active; const guide = guides.find(({ id }) => id === guideId); - if (!app || !guide) { - throw new Error('Invalid app or guide'); - } - - const GuideComponent = guide.Component; + const GuideComponent = guide?.Component; const memorizedContext = useMemo( () => - ({ - metadata: guide.metadata, - Logo: guide.Logo, - app, - endpoint: tenantEndpoint?.toString() ?? '', - alternativeEndpoint: conditional(isCustomDomainActive && tenantEndpoint?.toString()), - redirectUris: app.oidcClientMetadata.redirectUris, - postLogoutRedirectUris: app.oidcClientMetadata.postLogoutRedirectUris, - isCompact: Boolean(isCompact), - sampleUrls: { - origin: 'http://localhost:3001/', - callback: 'http://localhost:3001/callback', - }, - }) satisfies GuideContextType, + conditional( + !!guide && { + metadata: guide.metadata, + Logo: guide.Logo, + app, + endpoint: tenantEndpoint?.toString() ?? '', + alternativeEndpoint: conditional(isCustomDomainActive && tenantEndpoint?.toString()), + redirectUris: app.oidcClientMetadata.redirectUris, + postLogoutRedirectUris: app.oidcClientMetadata.postLogoutRedirectUris, + isCompact: Boolean(isCompact), + sampleUrls: { + origin: 'http://localhost:3001/', + callback: 'http://localhost:3001/callback', + }, + } + ) satisfies GuideContextType | undefined, [guide, app, tenantEndpoint, isCustomDomainActive, isCompact] ); @@ -90,39 +89,43 @@ function Guide({ className, guideId, app, isCompact, onClose }: Props) {
{!isCompact && }
- - { - const [, language] = /language-(\w+)/.exec(String(className ?? '')) ?? []; + {memorizedContext ? ( + + { + const [, language] = /language-(\w+)/.exec(String(className ?? '')) ?? []; - return language ? ( - - ) : ( - {String(children).trimEnd()} - ); - }, - a: ({ children, ...props }) => ( - - {children} - - ), - details: DetailsSummary, - }} - > - }> - {tenantEndpoint && } - - - - {!isCompact && ( + return language ? ( + + ) : ( + {String(children).trimEnd()} + ); + }, + a: ({ children, ...props }) => ( + + {children} + + ), + details: DetailsSummary, + }} + > + }> + {tenantEndpoint && GuideComponent && } + + + + ) : ( + + )} + {!isCompact && memorizedContext && (