mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #29946 from overleaf/dp-reopened-error
Fix go to code location on re-opened errors GitOrigin-RevId: e7a91ae45ac44453c974c7af8ad938d21c95f410
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { memo, MouseEventHandler, useCallback } from 'react'
|
||||
import { memo } from 'react'
|
||||
import PreviewLogEntryHeader from '../../preview/components/preview-log-entry-header'
|
||||
import PdfLogEntryContent from './pdf-log-entry-content'
|
||||
import HumanReadableLogsHints from '../../../ide/human-readable-logs/HumanReadableLogsHints'
|
||||
import getMeta from '@/utils/meta'
|
||||
import { ErrorLevel, LogEntry, SourceLocation } from '../util/types'
|
||||
import NewLogEntry from '@/features/ide-redesign/components/error-logs/log-entry'
|
||||
import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics'
|
||||
import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
|
||||
import useHandleLogEntryClick from '../hooks/use-handle-log-entry-click'
|
||||
|
||||
function PdfLogEntry({
|
||||
autoExpand,
|
||||
@@ -46,7 +46,6 @@ function PdfLogEntry({
|
||||
id?: string
|
||||
}) {
|
||||
const showAiErrorAssistant = getMeta('ol-showAiErrorAssistant')
|
||||
const { sendEvent } = useEditorAnalytics()
|
||||
|
||||
if (ruleId && HumanReadableLogsHints[ruleId]) {
|
||||
const hint = HumanReadableLogsHints[ruleId]
|
||||
@@ -54,22 +53,12 @@ function PdfLogEntry({
|
||||
extraInfoURL = hint.extraInfoURL
|
||||
}
|
||||
|
||||
const handleLogEntryLinkClick: MouseEventHandler<HTMLButtonElement> =
|
||||
useCallback(
|
||||
event => {
|
||||
event.preventDefault()
|
||||
|
||||
if (onSourceLocationClick && sourceLocation) {
|
||||
onSourceLocationClick(sourceLocation)
|
||||
|
||||
const parts = sourceLocation?.file?.split('.')
|
||||
const extension =
|
||||
parts?.length && parts?.length > 1 ? parts.pop() : ''
|
||||
sendEvent('log-entry-link-click', { level, ruleId, extension })
|
||||
}
|
||||
},
|
||||
[level, onSourceLocationClick, ruleId, sourceLocation, sendEvent]
|
||||
)
|
||||
const handleLogEntryLinkClick = useHandleLogEntryClick({
|
||||
level,
|
||||
ruleId,
|
||||
sourceLocation,
|
||||
onSourceLocationClick,
|
||||
})
|
||||
|
||||
const newEditor = useIsNewEditorEnabled()
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { MouseEventHandler, useCallback } from 'react'
|
||||
import { useEditorAnalytics } from '@/shared/hooks/use-editor-analytics'
|
||||
import { ErrorLevel, SourceLocation } from '../util/types'
|
||||
|
||||
const useHandleLogEntryClick = ({
|
||||
level,
|
||||
ruleId,
|
||||
sourceLocation,
|
||||
onSourceLocationClick,
|
||||
}: {
|
||||
level: ErrorLevel | undefined
|
||||
ruleId: string | undefined
|
||||
sourceLocation: SourceLocation | undefined
|
||||
onSourceLocationClick?: (location: SourceLocation) => void
|
||||
}) => {
|
||||
const { sendEvent } = useEditorAnalytics()
|
||||
|
||||
const handleLogEntryLinkClick: MouseEventHandler<HTMLButtonElement> =
|
||||
useCallback(
|
||||
event => {
|
||||
event.preventDefault()
|
||||
|
||||
if (onSourceLocationClick && sourceLocation) {
|
||||
onSourceLocationClick(sourceLocation)
|
||||
|
||||
const parts = sourceLocation?.file?.split('.')
|
||||
const extension =
|
||||
parts?.length && parts?.length > 1 ? parts.pop() : ''
|
||||
sendEvent('log-entry-link-click', { level, ruleId, extension })
|
||||
}
|
||||
},
|
||||
[level, onSourceLocationClick, ruleId, sourceLocation, sendEvent]
|
||||
)
|
||||
|
||||
return handleLogEntryLinkClick
|
||||
}
|
||||
|
||||
export default useHandleLogEntryClick
|
||||
Reference in New Issue
Block a user