chore: debug info use query
This commit is contained in:
parent
6fcebf3ecd
commit
edc2fe050a
@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React, { useEffect } from 'react'
|
import React from 'react'
|
||||||
import {
|
import {
|
||||||
RiArrowRightUpLine,
|
RiArrowRightUpLine,
|
||||||
RiBugLine,
|
RiBugLine,
|
||||||
@ -9,19 +9,16 @@ import { useTranslation } from 'react-i18next'
|
|||||||
import KeyValueItem from '../base/key-value-item'
|
import KeyValueItem from '../base/key-value-item'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import type { DebugInfo as DebugInfoTypes } from '../types'
|
import { useDebugKey } from '@/service/use-plugins'
|
||||||
import { fetchDebugKey } from '@/service/plugins'
|
|
||||||
|
|
||||||
const i18nPrefix = 'plugin.debugInfo'
|
const i18nPrefix = 'plugin.debugInfo'
|
||||||
|
|
||||||
const DebugInfo: FC = () => {
|
const DebugInfo: FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [info, setInfo] = React.useState<DebugInfoTypes | null>(null)
|
const { data: info, isLoading } = useDebugKey()
|
||||||
useEffect(() => {
|
|
||||||
fetchDebugKey().then((res) => {
|
if (isLoading) return null
|
||||||
setInfo(res)
|
|
||||||
})
|
|
||||||
}, [])
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
triggerMethod='click'
|
triggerMethod='click'
|
||||||
@ -37,7 +34,7 @@ const DebugInfo: FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className='space-y-0.5'>
|
<div className='space-y-0.5'>
|
||||||
<KeyValueItem
|
<KeyValueItem
|
||||||
label={'Port'}
|
label={'URL'}
|
||||||
value={`${info?.host}:${info?.port}`}
|
value={`${info?.host}:${info?.port}`}
|
||||||
/>
|
/>
|
||||||
<KeyValueItem
|
<KeyValueItem
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { InstalledPluginListResponse } from '@/app/components/plugins/types'
|
import type { DebugInfo as DebugInfoTypes, InstalledPluginListResponse } from '@/app/components/plugins/types'
|
||||||
import { get } from './base'
|
import { get } from './base'
|
||||||
import {
|
import {
|
||||||
useQueryClient,
|
useQueryClient,
|
||||||
@ -27,3 +27,10 @@ export const useInvalidateInstalledPluginList = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const useDebugKey = () => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: [NAME_SPACE, 'debugKey'],
|
||||||
|
queryFn: () => get<DebugInfoTypes>('/workspaces/current/plugin/debugging-key'),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user