Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI v2] feat: Refines flow run card in replacement for flow run data table #17242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function useBuildTabOptions(deployment: Deployment) {
),
ViewComponent: () => (
<TabsContent value="Upcoming">
<DeploymentDetailsUpcomingTab deploymentId={deployment.id} />
<DeploymentDetailsUpcomingTab deployment={deployment} />
</TabsContent>
),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import { getRouteApi } from "@tanstack/react-router";

import { Deployment } from "@/api/deployments";
import { usePaginateFlowRunswithFlows } from "@/api/flow-runs/use-paginate-flow-runs-with-flows";
import { FlowRunState, SortFilters } from "@/components/flow-runs/data-table";
import {
FlowRunState,
FlowRunsFilters,
FlowRunsList,
FlowRunsPagination,
FlowRunsRowCount,
type PaginationState,
SortFilters,
} from "@/components/flow-runs/flow-runs-list";
import { useCallback, useMemo, useState } from "react";

const routeApi = getRouteApi("/deployments/deployment/$id");

type DeploymentDetailsUpcomingTabProps = {
deploymentId: string;
deployment: Deployment;
};

export const DeploymentDetailsUpcomingTab = ({
deploymentId,
deployment,
}: DeploymentDetailsUpcomingTabProps) => {
const [selectedRows, setSelectedRows] = useState<Set<string>>(new Set());
const [pagination, onChangePagination] = usePagination();
Expand All @@ -30,7 +32,7 @@ export const DeploymentDetailsUpcomingTab = ({
const { data } = usePaginateFlowRunswithFlows({
deployments: {
operator: "and_",
id: { any_: [deploymentId] },
id: { any_: [deployment.id] },
},
flow_runs: {
name: { like_: search || undefined },
Expand All @@ -45,10 +47,15 @@ export const DeploymentDetailsUpcomingTab = ({
sort,
});

const handleResetFilters = () => {
resetFilters();
setSelectedRows(new Set());
};
const dataWithDeployment = useMemo(() => {
if (!data) {
return undefined;
}
return {
...data,
results: data.results.map((flowRun) => ({ ...flowRun, deployment })),
};
}, [data, deployment]);

const addRow = (id: string) =>
setSelectedRows((curr) => new Set(curr).add(id));
Expand All @@ -67,12 +74,19 @@ export const DeploymentDetailsUpcomingTab = ({
}
};

const handleResetFilters = !resetFilters
? undefined
: () => {
resetFilters();
setSelectedRows(new Set());
};

return (
<div className="flex flex-col gap-2">
<div className="flex items-center justify-between">
<FlowRunsRowCount
count={data?.count}
results={data?.results}
count={dataWithDeployment?.count}
results={dataWithDeployment?.results}
selectedRows={selectedRows}
setSelectedRows={setSelectedRows}
/>
Expand All @@ -87,24 +101,26 @@ export const DeploymentDetailsUpcomingTab = ({
</div>

<FlowRunsList
flowRuns={data?.results}
flowRuns={dataWithDeployment?.results}
selectedRows={selectedRows}
onSelect={handleSelectRow}
onClearFilters={handleResetFilters}
/>

{data && data.results.length > 0 && (
{dataWithDeployment && dataWithDeployment.results.length > 0 && (
<FlowRunsPagination
count={dataWithDeployment.count}
pagination={pagination}
onChangePagination={onChangePagination}
pages={data.pages}
pages={dataWithDeployment.pages}
/>
)}
</div>
);
};

function useResetFilters() {
const { upcoming } = routeApi.useSearch();
const navigate = routeApi.useNavigate();
const resetFilters = useCallback(() => {
void navigate({
Expand All @@ -116,7 +132,9 @@ function useResetFilters() {
replace: true,
});
}, [navigate]);
return resetFilters;
const hasFiltersApplied = useMemo(() => Boolean(upcoming), [upcoming]);

return hasFiltersApplied ? resetFilters : undefined;
}

function usePagination() {
Expand Down
116 changes: 0 additions & 116 deletions ui-v2/src/components/flow-runs/data-table/data-table-filters.tsx

This file was deleted.

144 changes: 0 additions & 144 deletions ui-v2/src/components/flow-runs/data-table/data-table.stories.tsx

This file was deleted.

Loading