diff --git a/src/components/cardinal/sidebar/index.tsx b/src/components/cardinal/sidebar/index.tsx index ce2ccc3..791446f 100644 --- a/src/components/cardinal/sidebar/index.tsx +++ b/src/components/cardinal/sidebar/index.tsx @@ -12,9 +12,9 @@ import { worldQueryOptions, } from '@/lib/query-options' -import { SidebarMessages } from './messages' +import { CardinalSidebarMessages } from './messages' import { CreatePersona } from './persona' -import { SidebarQueries } from './queries' +import { CardinalSidebarQueries } from './queries' const builtinMessages = new Set([routeMsgCreatePersona, routeMsgAuthorizePersonaAddress]) const builtinQueries = new Set([routeQryPersonaSigner, routeQryReceiptsList]) @@ -41,8 +41,8 @@ export function CardinalSidebar() { diff --git a/src/components/cardinal/sidebar/messages.tsx b/src/components/cardinal/sidebar/messages.tsx index 31a4b01..cd7bf3b 100644 --- a/src/components/cardinal/sidebar/messages.tsx +++ b/src/components/cardinal/sidebar/messages.tsx @@ -34,12 +34,12 @@ import { errorToast } from '@/lib/utils' import { defaultValues, formSchema, formatName, goTypeToInputComponent } from './utils' -interface SidebarMessagesProps { +interface CardinalSidebarMessagesProps { messages: WorldField[] namespace: string } -export function SidebarMessages({ messages, namespace }: SidebarMessagesProps) { +export function CardinalSidebarMessages({ messages, namespace }: CardinalSidebarMessagesProps) { return ( diff --git a/src/components/cardinal/sidebar/queries.tsx b/src/components/cardinal/sidebar/queries.tsx index bf5d260..7fd029c 100644 --- a/src/components/cardinal/sidebar/queries.tsx +++ b/src/components/cardinal/sidebar/queries.tsx @@ -26,11 +26,11 @@ import { errorToast } from '@/lib/utils' import { defaultValues, formSchema, formatName, goTypeToInputComponent } from './utils' -interface SidebarQueriesProps { +interface CardinalSidebarQueriesProps { queries: WorldField[] } -export function SidebarQueries({ queries }: SidebarQueriesProps) { +export function CardinalSidebarQueries({ queries }: CardinalSidebarQueriesProps) { const cql: WorldField = { name: 'CQL', fields: { diff --git a/src/components/header.tsx b/src/components/header.tsx index 632491e..7be00bd 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -92,11 +92,11 @@ function CardinalUrl() { isCardinalConnected ? 'bg-green-500' : 'bg-red-500', )} /> - + Cardinal URL setCardinalUrl(e.target.value)} @@ -129,11 +129,11 @@ function JaegerUrl() { return ( - + Jaeger URL setJaegerUrl(e.target.value)} @@ -144,7 +144,7 @@ function JaegerUrl() { target="_blank" className={cn(buttonVariants({ variant: 'outline', size: 'icon' }), 'size-8 flex-shrink-0')} title="Open full Jaeger UI" - rel="noreferrer" + rel="noopener noreferrer" > diff --git a/src/components/jaeger/sidebar.tsx b/src/components/jaeger/sidebar.tsx index 801b3a0..1d4e71e 100644 --- a/src/components/jaeger/sidebar.tsx +++ b/src/components/jaeger/sidebar.tsx @@ -128,7 +128,6 @@ export function JaegerSidebar() { ))} - )} @@ -140,7 +139,6 @@ export function JaegerSidebar() { Operation - )} @@ -208,7 +205,6 @@ export function JaegerSidebar() { ))} - )} diff --git a/src/lib/query-options.ts b/src/lib/query-options.ts index df4801f..47b12d5 100644 --- a/src/lib/query-options.ts +++ b/src/lib/query-options.ts @@ -232,21 +232,19 @@ export const jaegerServicesQueryOptions = ({ jaegerUrl }: JaegerQueryOptionProps }, }) -// TODO: validations && clean up -function getDuration(lookback: string) { +function getDurationMicroSeconds(lookback: string) { const lookupSeconds: { [k: string]: number } = { m: 60, h: 60 * 60, d: 60 * 60 * 24, } - const unit = lookback[lookback.length - 1] - const ns = lookupSeconds[unit] * 1_000_000 - return ns + const seconds = lookback[lookback.length - 1] + return lookupSeconds[seconds] * 1_000_000 } // since we're embedding an iframe, instead of fetching the page here, we're just // returning the url with the search params. we're effectively using tanstack query -// as a state managemnt tool instead of putting it in a react context +// as a state management tool instead of putting it in a react context export const jaegerSearchQueryOptions = ({ jaegerUrl, options }: JaegerQueryOptionProps) => ({ queryKey: ['jaegerSearch'], queryFn: () => { @@ -258,8 +256,8 @@ export const jaegerSearchQueryOptions = ({ jaegerUrl, options }: JaegerQueryOpti url.searchParams.append('limit', options.limit.toString()) url.searchParams.append('uiEmbed', 'v0') - const now = Date.now() * 1000 // convert to ns - url.searchParams.append('start', (now - getDuration(options.lookback)).toString()) + const now = Date.now() * 1000 // convert to microseconds + url.searchParams.append('start', (now - getDurationMicroSeconds(options.lookback)).toString()) url.searchParams.append('end', now.toString()) if (options.operation && options.operation.length > 0) { diff --git a/src/routes/_cardinal.tsx b/src/routes/_cardinal.tsx index 1366f80..90c56ec 100644 --- a/src/routes/_cardinal.tsx +++ b/src/routes/_cardinal.tsx @@ -90,6 +90,9 @@ function CardinalLayout() { } } if (isCardinalConnected) sync().catch((e) => console.log(e)) + // NOTE: take caution when adding dependencies here. you shouldn't add `personas` to this + // dependency array as it will result in a weird bug. Linters will always ask for + // exhaustive deps, be sure to test first before autofixing. }, [isCardinalConnected, cardinalUrl, toast, queryClient]) // setup websocket connection to receive events diff --git a/src/routes/_jaeger.jaeger.tsx b/src/routes/_jaeger.jaeger.tsx index fd51cf8..4112362 100644 --- a/src/routes/_jaeger.jaeger.tsx +++ b/src/routes/_jaeger.jaeger.tsx @@ -15,8 +15,12 @@ function Jaeger() { useEffect(() => { const ping = async () => { - const res = await fetch(jaegerUrl) - setIsJaegerRunning(res.ok) + try { + const res = await fetch(jaegerUrl) + setIsJaegerRunning(res.ok) + } catch (_error) { + // no need to do anything as isJaegerRunning false by default + } } ping().then() }, [jaegerUrl]) @@ -35,7 +39,7 @@ function Jaeger() { ) : ( - + )} >