Skip to content

Commit 4808b3d

Browse files
authored
Added a link "Raw" to open raw artifact file in a new tab (#6622)
1 parent e735671 commit 4808b3d

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

changelog/6513.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- On artifact details page, added a link "Raw" to open raw artifact file in a new tab.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { focusVisibleStyle } from "@/shared/components/style-rac";
2+
import { classNames } from "@/shared/utils/common";
3+
import { Button as AriaButton, ButtonProps as AriaButtonProps } from "react-aria-components";
4+
5+
export function ArtifactFileButton({ className, ...props }: AriaButtonProps) {
6+
return (
7+
<AriaButton
8+
className={classNames(
9+
focusVisibleStyle,
10+
"border border-transparent p-1 hover:bg-neutral-600 rounded-lg text-sm",
11+
className
12+
)}
13+
{...props}
14+
/>
15+
);
16+
}
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
import { focusVisibleStyle } from "@/shared/components/style-rac";
1+
import { ArtifactFileButton } from "@/entities/artifacts/ui/artifact-file-button";
22
import { useCopyToClipboard } from "@/shared/hooks/useCopyToClipboard";
3-
import { classNames } from "@/shared/utils/common";
43
import { CopyCheckIcon, CopyIcon } from "lucide-react";
5-
import { Button } from "react-aria-components";
64

75
export function ArtifactFileCopy({ value }: { value: string }) {
86
const { isCopied, copyToClipboard } = useCopyToClipboard();
97

108
return (
11-
<Button
12-
onPress={() => copyToClipboard(value)}
13-
className={classNames(
14-
focusVisibleStyle,
15-
"border border-transparent p-1 hover:bg-neutral-600 rounded-lg"
16-
)}
17-
>
9+
<ArtifactFileButton onPress={() => copyToClipboard(value)}>
1810
{isCopied ? <CopyCheckIcon className="size-4" /> : <CopyIcon className="size-4" />}
19-
</Button>
11+
</ArtifactFileButton>
2012
);
2113
}
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1+
import { ArtifactFileButton } from "@/entities/artifacts/ui/artifact-file-button";
12
import { Download, DownloadProps } from "@/shared/components/download";
2-
import { focusVisibleStyle } from "@/shared/components/ui/style";
3-
import { classNames } from "@/shared/utils/common";
43
import { DownloadIcon } from "lucide-react";
54

65
export const ArtifactFileDownload = ({ className, ...props }: DownloadProps) => {
76
return (
8-
<Download
9-
className={classNames(
10-
focusVisibleStyle,
11-
"border border-transparent p-1 hover:bg-neutral-600 rounded-lg",
12-
className
13-
)}
14-
{...props}
15-
>
16-
<DownloadIcon className="size-4" />
7+
<Download className="inline-flex" {...props}>
8+
<ArtifactFileButton className={className}>
9+
<DownloadIcon className="size-4" />
10+
</ArtifactFileButton>
1711
</Download>
1812
);
1913
};

frontend/app/src/entities/artifacts/ui/artifact-file.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ArtifactContentType } from "@/entities/artifacts/types";
2+
import { ArtifactFileButton } from "@/entities/artifacts/ui/artifact-file-button";
23
import { ArtifactFileCopy } from "@/entities/artifacts/ui/artifact-file-copy";
34
import { ArtifactFileDownload } from "@/entities/artifacts/ui/artifact-file-download";
45
import { fetchStream } from "@/shared/api/rest/fetch";
@@ -44,12 +45,14 @@ function FileLayout({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
4445
export interface FileHeaderProps extends HTMLAttributes<HTMLDivElement> {
4546
artifactId: string;
4647
fileContent: string;
48+
fileUrl: string;
4749
contentType: ArtifactContentType;
4850
}
4951

5052
function FileHeader({
5153
artifactId,
5254
fileContent,
55+
fileUrl,
5356
contentType = "text/plain",
5457
className,
5558
...props
@@ -59,6 +62,9 @@ function FileHeader({
5962
return (
6063
<div className={classNames("flex items-center gap-1", className)} {...props}>
6164
<span className="grow font-medium px-1">{config.label}</span>
65+
<a href={fileUrl} target="_blank" rel="noopener noreferrer">
66+
<ArtifactFileButton className="leading-4">Raw</ArtifactFileButton>
67+
</a>
6268
<ArtifactFileDownload
6369
contentType={contentType}
6470
fileName={`${artifactId}.${config.extension}`}
@@ -143,7 +149,12 @@ export const ArtifactFile = ({ artifactId, url, contentType }: ArtifactFileProps
143149

144150
return (
145151
<FileLayout>
146-
<FileHeader artifactId={artifactId} fileContent={fileContent} contentType={contentType} />
152+
<FileHeader
153+
artifactId={artifactId}
154+
fileUrl={url}
155+
fileContent={fileContent}
156+
contentType={contentType}
157+
/>
147158
<FileContent contentType={contentType} fileContent={fileContent} />
148159
</FileLayout>
149160
);

0 commit comments

Comments
 (0)