chore: add open log dir to troubleshooting modal (#2605)
This commit is contained in:
parent
931f1da28e
commit
52654b1055
@ -2,14 +2,16 @@ import React, { useEffect, useState } from 'react'
|
|||||||
|
|
||||||
import { Button } from '@janhq/uikit'
|
import { Button } from '@janhq/uikit'
|
||||||
|
|
||||||
import { CopyIcon, CheckIcon } from 'lucide-react'
|
import { CopyIcon, CheckIcon, FolderIcon } from 'lucide-react'
|
||||||
|
|
||||||
import { useClipboard } from '@/hooks/useClipboard'
|
import { useClipboard } from '@/hooks/useClipboard'
|
||||||
import { useLogs } from '@/hooks/useLogs'
|
import { useLogs } from '@/hooks/useLogs'
|
||||||
|
import { usePath } from '@/hooks/usePath'
|
||||||
|
|
||||||
const AppLogs = () => {
|
const AppLogs = () => {
|
||||||
const { getLogs } = useLogs()
|
const { getLogs } = useLogs()
|
||||||
const [logs, setLogs] = useState<string[]>([])
|
const [logs, setLogs] = useState<string[]>([])
|
||||||
|
const { onRevealInFinder } = usePath()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getLogs('app').then((log) => {
|
getLogs('app').then((log) => {
|
||||||
@ -26,6 +28,19 @@ const AppLogs = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="absolute -top-11 right-2">
|
<div className="absolute -top-11 right-2">
|
||||||
|
<div className="flex w-full flex-row gap-2">
|
||||||
|
<Button
|
||||||
|
themes="outline"
|
||||||
|
className="bg-white dark:bg-secondary/50"
|
||||||
|
onClick={() => onRevealInFinder('Logs')}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<>
|
||||||
|
<FolderIcon size={14} />
|
||||||
|
<span>Open</span>
|
||||||
|
</>
|
||||||
|
</div>
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
themes="outline"
|
themes="outline"
|
||||||
className="bg-white dark:bg-secondary/50"
|
className="bg-white dark:bg-secondary/50"
|
||||||
@ -48,6 +63,7 @@ const AppLogs = () => {
|
|||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div className="overflow-hidden">
|
<div className="overflow-hidden">
|
||||||
{logs.length > 1 ? (
|
{logs.length > 1 ? (
|
||||||
<div className="h-full overflow-auto">
|
<div className="h-full overflow-auto">
|
||||||
|
|||||||
@ -6,11 +6,13 @@ import React from 'react'
|
|||||||
import { Button } from '@janhq/uikit'
|
import { Button } from '@janhq/uikit'
|
||||||
import { useAtomValue } from 'jotai'
|
import { useAtomValue } from 'jotai'
|
||||||
|
|
||||||
import { CopyIcon, CheckIcon } from 'lucide-react'
|
import { CopyIcon, CheckIcon, FolderIcon } from 'lucide-react'
|
||||||
|
|
||||||
import { useClipboard } from '@/hooks/useClipboard'
|
import { useClipboard } from '@/hooks/useClipboard'
|
||||||
import { useLogs } from '@/hooks/useLogs'
|
import { useLogs } from '@/hooks/useLogs'
|
||||||
|
|
||||||
|
import { usePath } from '@/hooks/usePath'
|
||||||
|
|
||||||
import { serverEnabledAtom } from '@/helpers/atoms/LocalServer.atom'
|
import { serverEnabledAtom } from '@/helpers/atoms/LocalServer.atom'
|
||||||
|
|
||||||
type ServerLogsProps = { limit?: number; withCopy?: boolean }
|
type ServerLogsProps = { limit?: number; withCopy?: boolean }
|
||||||
@ -20,6 +22,7 @@ const ServerLogs = (props: ServerLogsProps) => {
|
|||||||
const { getLogs } = useLogs()
|
const { getLogs } = useLogs()
|
||||||
const serverEnabled = useAtomValue(serverEnabledAtom)
|
const serverEnabled = useAtomValue(serverEnabledAtom)
|
||||||
const [logs, setLogs] = useState<string[]>([])
|
const [logs, setLogs] = useState<string[]>([])
|
||||||
|
const { onRevealInFinder } = usePath()
|
||||||
|
|
||||||
const clipboard = useClipboard({ timeout: 1000 })
|
const clipboard = useClipboard({ timeout: 1000 })
|
||||||
|
|
||||||
@ -55,6 +58,19 @@ const ServerLogs = (props: ServerLogsProps) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="absolute -top-11 right-2">
|
<div className="absolute -top-11 right-2">
|
||||||
|
<div className="flex w-full flex-row gap-2">
|
||||||
|
<Button
|
||||||
|
themes="outline"
|
||||||
|
className="bg-white dark:bg-secondary/50"
|
||||||
|
onClick={() => onRevealInFinder('Logs')}
|
||||||
|
>
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<>
|
||||||
|
<FolderIcon size={14} />
|
||||||
|
<span>Open</span>
|
||||||
|
</>
|
||||||
|
</div>
|
||||||
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
themes="outline"
|
themes="outline"
|
||||||
className="bg-white dark:bg-secondary/50"
|
className="bg-white dark:bg-secondary/50"
|
||||||
@ -77,6 +93,7 @@ const ServerLogs = (props: ServerLogsProps) => {
|
|||||||
</div>
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div className="overflow-hidden">
|
<div className="overflow-hidden">
|
||||||
{logs.length > 1 ? (
|
{logs.length > 1 ? (
|
||||||
<div className="h-full overflow-auto">
|
<div className="h-full overflow-auto">
|
||||||
|
|||||||
@ -31,6 +31,9 @@ export const usePath = () => {
|
|||||||
if (!assistantId) return
|
if (!assistantId) return
|
||||||
filePath = await joinPath(['assistants', assistantId])
|
filePath = await joinPath(['assistants', assistantId])
|
||||||
break
|
break
|
||||||
|
case 'Logs':
|
||||||
|
filePath = 'logs'
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user