-
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 parameters cell to flow run table
- Loading branch information
1 parent
701e7f4
commit abbecc4
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
ui-v2/src/components/flow-runs/data-table/parameters-cell.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,61 @@ | ||
import { | ||
type FlowRunWithDeploymentAndFlow, | ||
type FlowRunWithFlow, | ||
} from "@/api/flow-runs"; | ||
import { Button } from "@/components/ui/button"; | ||
import { DialogHeader } from "@/components/ui/dialog"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@/components/ui/dialog"; | ||
import { Icon } from "@/components/ui/icons"; | ||
import { JsonInput } from "@/components/ui/json-input"; | ||
import { pluralize } from "@/utils"; | ||
import type { CellContext } from "@tanstack/react-table"; | ||
|
||
type ParametersCellProps = CellContext< | ||
FlowRunWithFlow | FlowRunWithDeploymentAndFlow, | ||
Record<string, unknown> | undefined | ||
>; | ||
|
||
export const ParametersCell = (props: ParametersCellProps) => { | ||
const flowRunName = props.row.original.name; | ||
const parameters = props.getValue() ?? {}; | ||
return ( | ||
<div className="flex items-center"> | ||
<Icon id="SlidersVertical" className="h-4 w-4" /> | ||
<ParametersDialog flowRunName={flowRunName} parameters={parameters} /> | ||
</div> | ||
); | ||
}; | ||
|
||
type ParametersDialogProps = { | ||
flowRunName: string | undefined; | ||
parameters: Record<string, unknown>; | ||
}; | ||
|
||
export const ParametersDialog = ({ | ||
flowRunName, | ||
parameters, | ||
}: ParametersDialogProps) => { | ||
const numParameters = Object.keys(parameters).length; | ||
return ( | ||
<Dialog> | ||
<DialogTrigger asChild> | ||
<Button variant="link" size="sm" disabled={numParameters < 1}> | ||
{numParameters} {pluralize(numParameters, "Parameter")} | ||
</Button> | ||
</DialogTrigger> | ||
<DialogContent aria-describedby={undefined}> | ||
<DialogHeader> | ||
<DialogTitle> | ||
Flow run parameters for {flowRunName ?? "Flow run"} | ||
</DialogTitle> | ||
</DialogHeader> | ||
<JsonInput value={JSON.stringify(parameters, null, 2)} disabled /> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; |
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