diff --git a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss index 36ff012c7..e1c140b6c 100644 --- a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss +++ b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@import 'src/utils/utils'; .customSubheader { height: 10vh; @@ -111,3 +112,45 @@ width: 130px; justify-content: space-between !important; } + +.scrollDownBtn { + position: absolute; + padding: 8px !important; + bottom: 35px; + right: 30px; + + & > :global(.bp3-icon) { + padding: 0 !important; + } + + & > :global(.bp3-button-text) { + width: 0; + padding-left: 0; + overflow: hidden; + display: inline-block; + } + + &:hover > :global(.bp3-button-text) { + width: auto; + padding-left: 4px; + } +} + +.consoleContainer { + min-height: 120px !important; + max-height: 70vh !important; + overflow: scroll; + align-items: start !important; + padding-top: var(--spacing-large) !important; + padding-bottom: var(--spacing-large) !important; + padding-left: var(--spacing-xlarge) !important; + background-color: var(--black) !important; + color: var(--white) !important; + pre { + background-color: var(--black) !important; + color: var(--white) !important; + text-align: start !important; + font-size: 12px; + font-family: var(--font-family-mono) !important; + } +} diff --git a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss.d.ts b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss.d.ts index 45ca0eb26..483d9e9d7 100644 --- a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss.d.ts +++ b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.module.scss.d.ts @@ -18,6 +18,7 @@ // This is an auto-generated file export declare const accordionnCustomSummary: string export declare const cardContainer: string +export declare const consoleContainer: string export declare const containerlogsTitle: string export declare const copyBtn: string export declare const customSubheader: string @@ -25,4 +26,5 @@ export declare const gitspaceIcon: string export declare const gitspaceIdContainer: string export declare const pageMain: string export declare const popover: string +export declare const scrollDownBtn: string export declare const titleContainer: string diff --git a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.tsx b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.tsx index b7b49ef00..bd0e66f25 100644 --- a/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.tsx +++ b/web/src/cde-gitness/pages/GitspaceDetails/GitspaceDetails.tsx @@ -26,7 +26,8 @@ import { Page, Text, useToaster, - AccordionHandle + AccordionHandle, + ButtonSize } from '@harnessio/uicore' import { Play } from 'iconoir-react' import { useHistory, useParams } from 'react-router-dom' @@ -53,12 +54,10 @@ import { useGitspaceDetails } from 'cde-gitness/hooks/useGitspaceDetails' import { useGitspaceEvents } from 'cde-gitness/hooks/useGitspaceEvents' import { useGitspaceActions } from 'cde-gitness/hooks/useGitspaceActions' import { useDeleteGitspaces } from 'cde-gitness/hooks/useDeleteGitspaces' -import { useGitspacesLogs } from 'cde-gitness/hooks/useGitspaceLogs' import { useOpenVSCodeBrowserURL } from 'cde-gitness/hooks/useOpenVSCodeBrowserURL' import { ErrorCard } from 'cde-gitness/components/ErrorCard/ErrorCard' 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 css from './GitspaceDetails.module.scss' const GitspaceDetails = () => { @@ -67,11 +66,15 @@ const GitspaceDetails = () => { const { routes, standalone } = useAppContext() const { showError, showSuccess } = useToaster() const history = useHistory() + const containerRef = useRef(null) const [startTriggred, setStartTriggred] = useState(false) const [triggerPollingOnStart, setTriggerPollingOnStart] = useState() const { gitspaceId = '' } = useParams<{ gitspaceId?: string }>() + const logCardId = 'logsCard' + const [expandedTab, setExpandedTab] = useState('') const [isStreamingLogs, setIsStreamingLogs] = useState(false) + const [isBottom, setIsBottom] = useState(false) const [startPolling, setStartPolling] = useState(undefined) @@ -79,14 +82,6 @@ const GitspaceDetails = () => { const { data: eventData, refetch: refetchEventData } = useGitspaceEvents({ gitspaceId }) - const { - data: responseData, - refetch: refetchLogsData, - response, - error: streamLogsError, - loading: logsLoading - } = useGitspacesLogs({ gitspaceId }) - const { mutate: actionMutate, loading: mutateLoading } = useGitspaceActions({ gitspaceId }) const { mutate: deleteGitspace, loading: deleteLoading } = useDeleteGitspaces({ gitspaceId }) @@ -111,15 +106,13 @@ const GitspaceDetails = () => { defaultTo(item?.timestamp, 0) >= defaultTo(data?.instance?.updated, 0) ) if (disabledActionButtons && filteredEvent?.length && !isStreamingLogs) { - refetchLogsData() setIsStreamingLogs(true) - } else if ( - (filteredEvent?.length && !disabledActionButtons && isStreamingLogs) || - (isStreamingLogs && streamLogsError) - ) { + viewLogs() + } else if (filteredEvent?.length && !disabledActionButtons && isStreamingLogs) { setIsStreamingLogs(false) + viewLogs() } - }, [eventData, data?.instance?.updated, disabledActionButtons, streamLogsError]) + }, [eventData, data?.instance?.updated, disabledActionButtons]) usePolling( async () => { @@ -135,19 +128,6 @@ const GitspaceDetails = () => { } ) - usePolling( - async () => { - if (!standalone) { - await refetchLogsData() - } - }, - { - pollingInterval: 10000, - startCondition: (eventData?.[eventData?.length - 1]?.event as string) === 'agent_gitspace_creation_start', - stopCondition: pollingCondition - } - ) - useEffect(() => { const startTrigger = async () => { if (redirectFrom && !startTriggred && !mutateLoading) { @@ -171,8 +151,6 @@ const GitspaceDetails = () => { } }, [data?.state, redirectFrom, mutateLoading, startTriggred]) - const formattedlogsdata = useGetLogStream(standalone ? { response } : { response: undefined }) - const confirmDelete = useConfirmAct() const handleDelete = async (e: React.MouseEvent) => { @@ -203,14 +181,6 @@ const GitspaceDetails = () => { const myRef = useRef(null) const selectedIde = getIDEOption(data?.ide, getString) - useEffect(() => { - if (standalone ? formattedlogsdata.data : responseData) { - accordionRef.current?.open('logsCard') - } else { - accordionRef.current?.close('logsCard') - } - }, [standalone, responseData, formattedlogsdata.data]) - const triggerGitspace = async () => { try { setStartPolling(GitspaceActionType.START) @@ -227,6 +197,19 @@ const GitspaceDetails = () => { const viewLogs = () => { myRef.current?.scrollIntoView() accordionRef.current?.open('logsCard') + setExpandedTab('logsCard') + } + + const handleClick = () => { + const logContainer = containerRef.current as HTMLDivElement + const scrollParent = logContainer?.parentElement as HTMLDivElement + if (!isBottom) { + scrollParent.scrollTop = scrollParent.scrollHeight + setIsBottom(true) + } else if (isBottom) { + scrollParent.scrollTop = 0 + setIsBottom(false) + } } return ( @@ -451,16 +434,20 @@ const GitspaceDetails = () => { - - + { + setExpandedTab(e) + }}> @@ -469,10 +456,27 @@ const GitspaceDetails = () => { {getString('cde.details.containerLogsSubText')} } - id="logsCard" + id={logCardId} details={ - - + + +