feat: [CDE-348]: updated logs container behaviour (#2739)

* feat: [CDE-348]: updated logs container behaviour
This commit is contained in:
Deepesh Kumar 2024-09-25 10:50:45 +00:00 committed by Harness
parent 8f2744668c
commit 51020b71e7
4 changed files with 33 additions and 10 deletions

View File

@ -17,7 +17,7 @@
@import 'src/utils/utils'; @import 'src/utils/utils';
.consoleContainer { .consoleContainer {
min-height: 500px !important; min-height: 120px !important;
max-height: 70vh !important; max-height: 70vh !important;
overflow: scroll; overflow: scroll;
align-items: start !important; align-items: start !important;

View File

@ -84,3 +84,8 @@
} }
} }
} }
.containerlogsTitle {
width: 130px;
justify-content: space-between !important;
}

View File

@ -18,6 +18,7 @@
// This is an auto-generated file // This is an auto-generated file
export declare const accordionnCustomSummary: string export declare const accordionnCustomSummary: string
export declare const cardContainer: string export declare const cardContainer: string
export declare const containerlogsTitle: string
export declare const customSubheader: string export declare const customSubheader: string
export declare const pageMain: string export declare const pageMain: string
export declare const popover: string export declare const popover: string

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import React, { useEffect, useState } from 'react' import React, { useEffect, useRef, useState } from 'react'
import { import {
Breadcrumbs, Breadcrumbs,
Button, Button,
@ -25,7 +25,8 @@ import {
Accordion, Accordion,
Page, Page,
Text, Text,
useToaster useToaster,
AccordionHandle
} from '@harnessio/uicore' } from '@harnessio/uicore'
import { Play } from 'iconoir-react' import { Play } from 'iconoir-react'
import { useHistory, useParams } from 'react-router-dom' import { useHistory, useParams } from 'react-router-dom'
@ -82,12 +83,15 @@ const GitspaceDetails = () => {
data: responseData, data: responseData,
refetch: refetchLogsData, refetch: refetchLogsData,
response, response,
error: streamLogsError error: streamLogsError,
loading: logsLoading
} = useGitspacesLogs({ gitspaceId }) } = useGitspacesLogs({ gitspaceId })
if (streamLogsError) { useEffect(() => {
if (streamLogsError?.message) {
showError(streamLogsError.message) showError(streamLogsError.message)
} }
}, [streamLogsError?.message])
const { mutate: actionMutate, loading: mutateLoading } = useGitspaceActions({ gitspaceId }) const { mutate: actionMutate, loading: mutateLoading } = useGitspaceActions({ gitspaceId })
@ -201,6 +205,16 @@ const GitspaceDetails = () => {
const { refetchToken, setSelectedRowUrl } = useOpenVSCodeBrowserURL() const { refetchToken, setSelectedRowUrl } = useOpenVSCodeBrowserURL()
const accordionRef = useRef<AccordionHandle | null>(null)
useEffect(() => {
if (standalone ? formattedlogsdata.data : responseData) {
accordionRef.current?.open('logsCard')
} else {
accordionRef.current?.close('logsCard')
}
}, [standalone, responseData, formattedlogsdata.data])
return ( return (
<> <>
<Page.Header <Page.Header
@ -402,13 +416,16 @@ const GitspaceDetails = () => {
</Card> </Card>
<Card className={css.cardContainer}> <Card className={css.cardContainer}>
<Accordion activeId="logsCard"> <Accordion activeId={''} ref={accordionRef}>
<Accordion.Panel <Accordion.Panel
shouldRender
className={css.accordionnCustomSummary} className={css.accordionnCustomSummary}
summary={ summary={
<Layout.Vertical spacing="small"> <Layout.Vertical spacing="small">
<Text font={{ variation: FontVariation.CARD_TITLE }} margin={{ left: 'large' }}> <Text
rightIcon={isStreamingLogs || logsLoading ? 'steps-spinner' : undefined}
className={css.containerlogsTitle}
font={{ variation: FontVariation.CARD_TITLE }}
margin={{ left: 'large' }}>
{getString('cde.details.containerLogs')} {getString('cde.details.containerLogs')}
</Text> </Text>
<Text margin={{ left: 'large' }}>{getString('cde.details.containerLogsSubText')} </Text> <Text margin={{ left: 'large' }}>{getString('cde.details.containerLogsSubText')} </Text>