Skip to content

Commit 8d87e4f

Browse files
committed
chore: Add Artifact Deletion Warning
1 parent da1c9ec commit 8d87e4f

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskOverview/IOSection/IOSection.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { BlockStack } from "@/components/ui/layout";
55
import { Spinner } from "@/components/ui/spinner";
66
import { Paragraph } from "@/components/ui/typography";
77
import { useBackend } from "@/providers/BackendProvider";
8+
import { useExecutionData } from "@/providers/ExecutionDataProvider";
89
import { getExecutionArtifacts } from "@/services/executionService";
910
import { getBackendStatusString } from "@/utils/backend";
1011
import type { TaskSpec } from "@/utils/componentSpec";
12+
import { isOlderThanDays } from "@/utils/date";
1113

1214
import IOExtras from "./IOExtras";
1315
import IOInputs from "./IOInputs";
@@ -21,6 +23,7 @@ interface IOSectionProps {
2123

2224
const IOSection = ({ taskSpec, executionId, readOnly }: IOSectionProps) => {
2325
const { backendUrl, configured, available } = useBackend();
26+
const { metadata } = useExecutionData();
2427

2528
const {
2629
data: artifacts,
@@ -74,8 +77,18 @@ const IOSection = ({ taskSpec, executionId, readOnly }: IOSectionProps) => {
7477
? ["inputs", "outputs", "other"]
7578
: ["outputs", "inputs", "other"];
7679

80+
const isOlderThan30Days =
81+
metadata?.created_at && isOlderThanDays(metadata.created_at, 30);
82+
7783
return (
7884
<BlockStack gap="4" className="w-full">
85+
{isOlderThan30Days && (
86+
<InfoBox title="Artifact Storage" variant="warning">
87+
Remote artifacts may be unavailable for runs older than 30 days. To
88+
keep an artifact, download it using the provided link before it
89+
expires.
90+
</InfoBox>
91+
)}
7992
{order.map((section) => {
8093
if (section === "inputs") {
8194
return (

src/utils/date.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ export const formatDuration = (startTime: string, endTime: string): string => {
7676
}
7777
};
7878

79+
/**
80+
* Check whether a date is older than a given number of calendar days ago.
81+
* @param date - Date string or object to check
82+
* @param days - Number of calendar days to compare against
83+
* @returns True if the date is older than the specified number of days, false otherwise
84+
*/
85+
export const isOlderThanDays = (date: string | Date, days: number): boolean => {
86+
const today = new Date();
87+
today.setHours(0, 0, 0, 0);
88+
89+
const cutoff = new Date(today);
90+
cutoff.setDate(cutoff.getDate() - days);
91+
92+
const target = new Date(date);
93+
target.setHours(0, 0, 0, 0);
94+
95+
return target < cutoff;
96+
};
97+
7998
/**
8099
* Format relative time between a past date and now
81100
* @param date - past timestamp string

0 commit comments

Comments
 (0)