diff --git a/src/components/TeamcityLogPage/TeamcityLogPage.tsx b/src/components/TeamcityLogPage/TeamcityLogPage.tsx index bc34fdd..c10dfad 100644 --- a/src/components/TeamcityLogPage/TeamcityLogPage.tsx +++ b/src/components/TeamcityLogPage/TeamcityLogPage.tsx @@ -1,67 +1,67 @@ -import { - Box, - Card, - Paper, - Typography, -} from '@material-ui/core'; +import {Box, Card, Typography,} from '@material-ui/core'; + import React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; -import { buildLogsRouteRef } from '../../plugin'; -import { Breadcrumbs, Content, Link, Progress } from '@backstage/core-components'; +import {makeStyles} from '@material-ui/core/styles'; +import {buildLogsRouteRef} from '../../plugin'; +import {Breadcrumbs, Content, Link, LogViewer, Progress} from '@backstage/core-components'; import Alert from '@material-ui/lab/Alert'; -import { useApi, configApiRef, useRouteRefParams } from '@backstage/core-plugin-api'; +import {configApiRef, useApi, useRouteRefParams} from '@backstage/core-plugin-api'; import useAsync from 'react-use/lib/useAsync'; const useStyles = makeStyles({ - paper: { - maxHeight: 800, - overflow: 'auto', - whiteSpace: 'pre' - }, - card: { - padding: '10px 20px' - }, + card: { + padding: '10px 20px' + }, + // logviewer has enabled line numbers by default, we have to hide them + logViewer: { + '& a[class*="lineNumber"]': { + display: 'none' + }, + }, }); + const TeamcityLogPage = () => { - const classes = useStyles(); - const { buildName, buildId, buildRunId } = useRouteRefParams(buildLogsRouteRef); - const config = useApi(configApiRef); - const { value, loading, error } = useAsync(async (): Promise => { + const classes = useStyles(); + const {buildName, buildId, buildRunId} = useRouteRefParams(buildLogsRouteRef); + const config = useApi(configApiRef); + const {value, loading, error} = useAsync(async (): Promise => { const backendUrl = config.getString('backend.baseUrl'); const response = await fetch(`${backendUrl}/api/proxy/teamcity-proxy/downloadBuildLog.html?buildId=${buildRunId}`); - const data = await response.text(); - - return data; - }, []); + return await response.text(); + }, []); - if (loading) { - return ; - } else if (error) { - return {error.message}; - } + if (loading) { + return ; + } else if (error) { + return {error.message}; + } - return ( -
- - Builds - {buildName} ({buildId}) - Logs - - - - - {value} - - -
- ); + return ( +
+ + Builds + {buildName} ({buildId}) + Logs + + + + {/* Since the LogViewer uses windowing to avoid rendering all contents at once, the + log is sized automatically to fill the available vertical space. This means + it may often be needed to wrap the LogViewer in a container that provides it + with a fixed amount of space. */} +
+ +
+
+
+ ) }; const Page = () => ( - - - + + + ); export default Page; -export { TeamcityLogPage }; \ No newline at end of file +export {TeamcityLogPage};