Skip to content

Commit e7df45b

Browse files
author
Trey Ivy
committed
ephemeral download buttons
1 parent b18f2cc commit e7df45b

File tree

12 files changed

+215
-25
lines changed

12 files changed

+215
-25
lines changed

frontend/src/app/bazel-invocations/[invocationID]/index.graphql.ts

+1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ fragment BlobReferenceInfo on BlobReference {
302302
name
303303
sizeInBytes
304304
downloadURL
305+
ephemeralURL
305306
}
306307
`)
307308

frontend/src/components/Problems/LogOutput/index.tsx

+40
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import React, {useEffect, useState} from 'react';
22
import {util} from 'zod';
33
import {BlobReference} from '@/graphql/__generated__/graphql';
44
import {LogViewerCard} from "@/components/LogViewer";
5+
import { env } from 'next-runtime-env';
6+
import { Button, Card, Space, Tooltip } from 'antd';
7+
import ButtonGroup from 'antd/es/button/button-group';
8+
import { DownloadOutlined, WarningOutlined } from '@ant-design/icons';
9+
import Link from 'next/link';
10+
import styles from "@/components/LogViewer/index.module.css"
11+
import DownloadButton from '@/components/DownloadButton';
512

613
interface Props {
714
blobReference: BlobReference;
@@ -10,8 +17,26 @@ interface Props {
1017

1118
const DEFAULT_TAIL_BYTES = 10_000;
1219

20+
21+
1322
/* eslint-disable consistent-return */
1423
const LogOutput: React.FC<Props> = ({blobReference, tailBytes = DEFAULT_TAIL_BYTES}) => {
24+
// if (blobReference.ephemeralURL != "" && env('NEXT_PUBLIC_BROWSER_URL')) {
25+
// const url = new URL(blobReference.ephemeralURL, env('NEXT_PUBLIC_BROWSER_URL'))
26+
// var logDownload = <Space direction="horizontal" size="small">
27+
// <Card>
28+
// <ButtonGroup>
29+
// <Button>
30+
// <DownloadOutlined/>
31+
// <Link href={url.toString()} download="test.log" target="_self">Download Log File</Link>
32+
// </Button>
33+
// <Tooltip title="Depending on the configuration of your remote cache, this link may point to ephemeral content and it could disappear.">
34+
// <Button icon={<WarningOutlined/>} danger/>
35+
// </Tooltip>
36+
// </ButtonGroup>
37+
// </Card>
38+
// </Space>
39+
// }
1540
const [contents, setContents] = useState<string>("");
1641
useEffect(() => {
1742
fetch(blobReference.downloadURL, {
@@ -39,6 +64,21 @@ const LogOutput: React.FC<Props> = ({blobReference, tailBytes = DEFAULT_TAIL_BYT
3964
validContent = selectedLines.join('\n')
4065
}
4166

67+
if (blobReference.ephemeralURL != "" && env('NEXT_PUBLIC_BROWSER_URL')) {
68+
console.log("blobReference.ephemeralURL=", blobReference.ephemeralURL)
69+
const url = new URL(blobReference.ephemeralURL, env('NEXT_PUBLIC_BROWSER_URL'))
70+
return <Space direction="horizontal" size="small">
71+
<Card>
72+
<ButtonGroup>
73+
<DownloadButton url={url.toString()} enabled={true} buttonLabel="Download Log File" fileName="output.log" />
74+
<Tooltip title="Depending on the configuration of your remote cache, this link may point to ephemeral content and it could disappear.">
75+
<Button icon={<WarningOutlined/>} danger />
76+
</Tooltip>
77+
</ButtonGroup>
78+
</Card>
79+
</Space>
80+
}
81+
4282
return <LogViewerCard log={validContent}/>;
4383
};
4484

frontend/src/components/Problems/TestResultContainer/index.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {TestProblem} from "@/graphql/__generated__/graphql";
2-
import {Space} from "antd";
1+
import { TestProblem } from "@/graphql/__generated__/graphql";
2+
import { Space } from "antd";
33
import React from "react";
44
import ErrorAlert from "@/components/ErrorAlert";
55
import themeStyles from '@/theme/theme.module.css';
6-
import {SectionWithTestStatus} from "@/components/Problems/BuildProblem";
6+
import { SectionWithTestStatus } from "@/components/Problems/BuildProblem";
77
import LogOutput from "@/components/Problems/LogOutput";
88

99
interface Props {
@@ -12,6 +12,7 @@ interface Props {
1212
testProblem: TestProblem;
1313
}
1414

15+
1516
const TestResultContainer: React.FC<Props> = ({ id, problemLabel, testProblem }) => {
1617
const testResult = testProblem.results.find(r => r.id == id)
1718
if (!testResult) {
@@ -23,12 +24,15 @@ const TestResultContainer: React.FC<Props> = ({ id, problemLabel, testProblem })
2324
);
2425
}
2526

27+
var contents = <LogOutput blobReference={testResult.actionLogOutput} />
28+
29+
2630
return (
2731
<>
2832
<SectionWithTestStatus testProblem={testProblem} />
2933
{/* Display spin behind the actions, making UI stable when query is being executed. */}
3034
<Space direction="vertical" size="middle" className={themeStyles.space}>
31-
<LogOutput blobReference={testResult.actionLogOutput} />
35+
{contents}
3236
</Space>
3337
</>
3438
);

frontend/src/graphql/__generated__/gql.ts

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)