Skip to content

Commit

Permalink
feat: show agent on actions
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jan 9, 2025
1 parent 6966981 commit ed86b3d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/api/services/playbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export async function getPlaybookRun(id: string) {
"status",
"start_time",
"end_time",
"agent:agent_id(id,name)",
"scheduled_time"
].join(",");

Expand Down Expand Up @@ -184,7 +185,7 @@ export async function getPlaybookRuns({
sort?: SortingState;
}) {
const searchParams = new URLSearchParams();
searchParams.append("parent_id", "is.null");
// searchParams.append("parent_id", "is.null");

if (componentId) {
searchParams.append("component_id", `eq.${componentId}`);
Expand Down
1 change: 1 addition & 0 deletions src/api/traits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface Deletable {

export interface Agent {
agent_id?: string;
name?: string;
}

export interface Namespaced {
Expand Down
1 change: 1 addition & 0 deletions src/api/types/playbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type PlaybookRunActionStatus =
export type PlaybookRunAction = {
id: string;
name: string;
agent?: Agent;
status: PlaybookRunActionStatus;
playbook_run_id: string;
start_time: string;
Expand Down
17 changes: 14 additions & 3 deletions src/components/Playbooks/Runs/Actions/PlaybookRunsActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import dayjs from "dayjs";
import { Tooltip } from "react-tooltip";
import { PlaybookRunAction } from "../../../../api/types/playbooks";
import { PlaybookStatusIcon } from "../../../../ui/Icons/PlaybookStatusIcon";
import { Agent } from "@flanksource-ui/api/traits";

type PlaybookRunsActionItemProps = {
agent?: Agent;
action: Pick<
PlaybookRunAction,
"status" | "name" | "start_time" | "end_time" | "id" | "scheduled_time"
Expand All @@ -19,6 +21,7 @@ type PlaybookRunsActionItemProps = {
export default function PlaybookRunsActionItem({
action,
onClick = () => {},
agent,
isSelected = false,
stepNumber
}: PlaybookRunsActionItemProps) {
Expand All @@ -40,13 +43,21 @@ export default function PlaybookRunsActionItem({
)}
data-tooltip-content={action.status}
>
<div className="flex flex-col">
<div className="flex flex-col gap-0.5">
<div className="flex flex-row gap-2 text-sm text-gray-600">
<PlaybookStatusIcon status={action.status} />
{action.name || `Step ${stepNumber}`}
<div className="flex flex-col gap-0.5">
<span>{action.name || `Step ${stepNumber}`}</span>
{agent && (
<span className="text-xs text-gray-400">
{"ran on: "}
{agent?.name}
</span>
)}
</div>
</div>
<div className={`flex flex-row items-center gap-1 text-xs`}></div>
</div>

<div className="flex flex-row gap-2">
<div className="text-sm text-gray-600">
{action.status === "sleeping" ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export default function PlaybookRunsActions({
)}
{data.actions.map((action, index) => (
<PlaybookRunsActionItem
agent={action?.agent}
isSelected={
selectedAction?.type === "Action" &&
selectedAction.data?.id === action.id
Expand Down

0 comments on commit ed86b3d

Please sign in to comment.