-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UI v2] feat: Adds Next run section to run tab (#17245)
- Loading branch information
1 parent
ab2634c
commit 9f97cee
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
ui-v2/src/components/deployments/deployment-details-runs-tab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Deployment } from "@/api/deployments"; | ||
import { useFilterFlowRunswithFlows } from "@/api/flow-runs/use-filter-flow-runs-with-flows"; | ||
import { FlowRunCard } from "@/components/flow-runs/flow-run-card"; | ||
import { Typography } from "@/components/ui/typography"; | ||
import { useMemo } from "react"; | ||
|
||
type DeploymentDetailsRunsTabProps = { | ||
deployment: Deployment; | ||
}; | ||
|
||
export const DeploymentDetailsRunsTab = ({ | ||
deployment, | ||
}: DeploymentDetailsRunsTabProps) => { | ||
const nextRun = useGetNextRun(deployment); | ||
|
||
return ( | ||
<div className="flex flex-col"> | ||
{nextRun && ( | ||
<div className="flex flex-col gap-2 border-b py-2"> | ||
<Typography variant="bodyLarge">Next Run</Typography> | ||
<FlowRunCard flowRun={nextRun} /> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
function useGetNextRun(deployment: Deployment) { | ||
const { data } = useFilterFlowRunswithFlows({ | ||
deployments: { id: { any_: [deployment.id] }, operator: "and_" }, | ||
flow_runs: { | ||
state: { name: { any_: ["Scheduled"] }, operator: "and_" }, | ||
operator: "and_", | ||
}, | ||
sort: "NAME_ASC", | ||
limit: 1, | ||
offset: 0, | ||
}); | ||
|
||
return useMemo(() => { | ||
if (!data || !data[0]) { | ||
return undefined; | ||
} | ||
return { | ||
...data[0], | ||
deployment, | ||
}; | ||
}, [data, deployment]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters