mirror of
https://github.com/harness/drone.git
synced 2025-05-03 10:22:26 +08:00
feat: [CDE-755]: Fix gitness UI redirection is broken, and logs are not loading (#3625)
* fix: fixed gitness breaking changes
<img width="1691" alt="Screenshot 2025-04-29 at 7 49 56 PM"
src="https://github.com/user-attachments/assets/07a858d5-cc7f-4cb8-8c9b-2e723ba6a120"
/>
(cherry picked from commit cd395e8406
)
Co-authored-by: Deepesh Kumar <deepesh.kumar@harness.io>
This commit is contained in:
parent
8d0c8b2f1e
commit
fe2b2dfc26
@ -54,9 +54,12 @@ import { useGitspaceDetails } from 'cde-gitness/hooks/useGitspaceDetails'
|
|||||||
import { useGitspaceEvents } from 'cde-gitness/hooks/useGitspaceEvents'
|
import { useGitspaceEvents } from 'cde-gitness/hooks/useGitspaceEvents'
|
||||||
import { useGitspaceActions } from 'cde-gitness/hooks/useGitspaceActions'
|
import { useGitspaceActions } from 'cde-gitness/hooks/useGitspaceActions'
|
||||||
import { useDeleteGitspaces } from 'cde-gitness/hooks/useDeleteGitspaces'
|
import { useDeleteGitspaces } from 'cde-gitness/hooks/useDeleteGitspaces'
|
||||||
|
import { useGitspacesLogs } from 'cde-gitness/hooks/useGitspaceLogs'
|
||||||
import { useOpenVSCodeBrowserURL } from 'cde-gitness/hooks/useOpenVSCodeBrowserURL'
|
import { useOpenVSCodeBrowserURL } from 'cde-gitness/hooks/useOpenVSCodeBrowserURL'
|
||||||
import { ErrorCard } from 'cde-gitness/components/ErrorCard/ErrorCard'
|
import { ErrorCard } from 'cde-gitness/components/ErrorCard/ErrorCard'
|
||||||
import CopyButton from 'cde-gitness/components/CopyButton/CopyButton'
|
import CopyButton from 'cde-gitness/components/CopyButton/CopyButton'
|
||||||
|
import ContainerLogs from '../../components/ContainerLogs/ContainerLogs'
|
||||||
|
import { useGetLogStream } from '../../hooks/useGetLogStream'
|
||||||
import Logger from './Logger/Logger'
|
import Logger from './Logger/Logger'
|
||||||
import css from './GitspaceDetails.module.scss'
|
import css from './GitspaceDetails.module.scss'
|
||||||
|
|
||||||
@ -82,6 +85,13 @@ const GitspaceDetails = () => {
|
|||||||
|
|
||||||
const { data: eventData, refetch: refetchEventData } = useGitspaceEvents({ gitspaceId })
|
const { data: eventData, refetch: refetchEventData } = useGitspaceEvents({ gitspaceId })
|
||||||
|
|
||||||
|
const {
|
||||||
|
refetch: refetchLogsData,
|
||||||
|
response,
|
||||||
|
error: streamLogsError,
|
||||||
|
loading: logsLoading
|
||||||
|
} = useGitspacesLogs({ gitspaceId })
|
||||||
|
|
||||||
const { mutate: actionMutate, loading: mutateLoading } = useGitspaceActions({ gitspaceId })
|
const { mutate: actionMutate, loading: mutateLoading } = useGitspaceActions({ gitspaceId })
|
||||||
|
|
||||||
const { mutate: deleteGitspace, loading: deleteLoading } = useDeleteGitspaces({ gitspaceId })
|
const { mutate: deleteGitspace, loading: deleteLoading } = useDeleteGitspaces({ gitspaceId })
|
||||||
@ -105,14 +115,27 @@ const GitspaceDetails = () => {
|
|||||||
(item.event === 'agent_gitspace_creation_start' || item.event === 'agent_gitspace_deletion_start') &&
|
(item.event === 'agent_gitspace_creation_start' || item.event === 'agent_gitspace_deletion_start') &&
|
||||||
defaultTo(item?.timestamp, 0) >= defaultTo(data?.instance?.updated, 0)
|
defaultTo(item?.timestamp, 0) >= defaultTo(data?.instance?.updated, 0)
|
||||||
)
|
)
|
||||||
if (disabledActionButtons && filteredEvent?.length && !isStreamingLogs) {
|
const refetchLogs = disabledActionButtons && filteredEvent?.length && !isStreamingLogs
|
||||||
|
if (standalone) {
|
||||||
|
if (refetchLogs) {
|
||||||
|
refetchLogsData()
|
||||||
|
setIsStreamingLogs(true)
|
||||||
|
} else if (
|
||||||
|
(filteredEvent?.length && !disabledActionButtons && isStreamingLogs) ||
|
||||||
|
(isStreamingLogs && streamLogsError)
|
||||||
|
) {
|
||||||
|
setIsStreamingLogs(false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (refetchLogs) {
|
||||||
setIsStreamingLogs(true)
|
setIsStreamingLogs(true)
|
||||||
viewLogs()
|
viewLogs()
|
||||||
} else if (filteredEvent?.length && !disabledActionButtons && isStreamingLogs) {
|
} else if (filteredEvent?.length && !disabledActionButtons && isStreamingLogs) {
|
||||||
setIsStreamingLogs(false)
|
setIsStreamingLogs(false)
|
||||||
viewLogs()
|
viewLogs()
|
||||||
}
|
}
|
||||||
}, [eventData, data?.instance?.updated, disabledActionButtons])
|
}
|
||||||
|
}, [eventData, data?.instance?.updated, disabledActionButtons, streamLogsError])
|
||||||
|
|
||||||
usePolling(
|
usePolling(
|
||||||
async () => {
|
async () => {
|
||||||
@ -173,6 +196,8 @@ const GitspaceDetails = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formattedlogsdata = useGetLogStream({ response })
|
||||||
|
|
||||||
const [accountIdentifier, orgIdentifier, projectIdentifier] = data?.space_path?.split('/') || []
|
const [accountIdentifier, orgIdentifier, projectIdentifier] = data?.space_path?.split('/') || []
|
||||||
|
|
||||||
const { refetchToken, setSelectedRowUrl } = useOpenVSCodeBrowserURL()
|
const { refetchToken, setSelectedRowUrl } = useOpenVSCodeBrowserURL()
|
||||||
@ -181,6 +206,16 @@ const GitspaceDetails = () => {
|
|||||||
const myRef = useRef<any | null>(null)
|
const myRef = useRef<any | null>(null)
|
||||||
const selectedIde = getIDEOption(data?.ide, getString)
|
const selectedIde = getIDEOption(data?.ide, getString)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (standalone) {
|
||||||
|
if (formattedlogsdata.data) {
|
||||||
|
accordionRef.current?.open('logsCard')
|
||||||
|
} else {
|
||||||
|
accordionRef.current?.close('logsCard')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [standalone, formattedlogsdata.data])
|
||||||
|
|
||||||
const triggerGitspace = async () => {
|
const triggerGitspace = async () => {
|
||||||
try {
|
try {
|
||||||
setStartPolling(GitspaceActionType.START)
|
setStartPolling(GitspaceActionType.START)
|
||||||
@ -197,8 +232,10 @@ const GitspaceDetails = () => {
|
|||||||
const viewLogs = () => {
|
const viewLogs = () => {
|
||||||
myRef.current?.scrollIntoView()
|
myRef.current?.scrollIntoView()
|
||||||
accordionRef.current?.open('logsCard')
|
accordionRef.current?.open('logsCard')
|
||||||
|
if (!standalone) {
|
||||||
setExpandedTab('logsCard')
|
setExpandedTab('logsCard')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
const logContainer = containerRef.current as HTMLDivElement
|
const logContainer = containerRef.current as HTMLDivElement
|
||||||
@ -447,7 +484,7 @@ const GitspaceDetails = () => {
|
|||||||
summary={
|
summary={
|
||||||
<Layout.Vertical spacing="small">
|
<Layout.Vertical spacing="small">
|
||||||
<Text
|
<Text
|
||||||
rightIcon={isStreamingLogs ? 'steps-spinner' : undefined}
|
rightIcon={isStreamingLogs || logsLoading ? 'steps-spinner' : undefined}
|
||||||
className={css.containerlogsTitle}
|
className={css.containerlogsTitle}
|
||||||
font={{ variation: FontVariation.CARD_TITLE }}
|
font={{ variation: FontVariation.CARD_TITLE }}
|
||||||
margin={{ left: 'large' }}>
|
margin={{ left: 'large' }}>
|
||||||
@ -458,6 +495,9 @@ const GitspaceDetails = () => {
|
|||||||
}
|
}
|
||||||
id={logCardId}
|
id={logCardId}
|
||||||
details={
|
details={
|
||||||
|
standalone ? (
|
||||||
|
<ContainerLogs data={formattedlogsdata.data} />
|
||||||
|
) : (
|
||||||
<Container width="100%" className={css.consoleContainer}>
|
<Container width="100%" className={css.consoleContainer}>
|
||||||
<Logger
|
<Logger
|
||||||
value={data?.name ?? ''}
|
value={data?.name ?? ''}
|
||||||
@ -478,6 +518,7 @@ const GitspaceDetails = () => {
|
|||||||
className={css.scrollDownBtn}
|
className={css.scrollDownBtn}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
Loading…
Reference in New Issue
Block a user