-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
143 additions
and
32 deletions.
There are no files selected for viewing
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
11 changes: 11 additions & 0 deletions
11
core/app/c/[communitySlug]/activity/actions/ActionRunsTable.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,11 @@ | ||
"use client"; | ||
|
||
import * as React from "react"; | ||
|
||
import { DataTable } from "~/app/components/DataTable"; | ||
import { ActionRun, getActionRunsTableColumns } from "./getActionRunsTableColumns"; | ||
|
||
export const ActionRunsTable = ({ actionRuns }: { actionRuns: ActionRun[] }) => { | ||
const actionRunsColumns = getActionRunsTableColumns(); | ||
return <DataTable columns={actionRunsColumns} data={actionRuns} searchBy="id" />; | ||
}; |
70 changes: 70 additions & 0 deletions
70
core/app/c/[communitySlug]/activity/actions/getActionRunsTableColumns.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,70 @@ | ||
"use client"; | ||
|
||
import type { ColumnDef } from "@tanstack/react-table"; | ||
|
||
import { Badge } from "ui/badge"; | ||
import { DataTableColumnHeader } from "ui/data-table"; | ||
|
||
import { PubTitle } from "~/app/components/PubTitle"; | ||
|
||
export type ActionRun = { | ||
id: string; | ||
createdAt: Date; | ||
actionInstance: { name: string; action: string }; | ||
stage: { id: string; name: string }; | ||
pub: { | ||
id: string; | ||
values: { field: { slug: string }; value: unknown }[] | Record<string, unknown>; | ||
createdAt: Date; | ||
}; | ||
}; | ||
|
||
export const getActionRunsTableColumns = () => | ||
[ | ||
{ | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Action" />, | ||
accessorKey: "actionInstance.name", | ||
}, | ||
{ | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Event" />, | ||
accessorKey: "event", | ||
cell: ({ getValue }) => { | ||
switch (getValue()) { | ||
case "pubEnteredStage": | ||
return "Entered stage"; | ||
case "pubLeftStage": | ||
return "Left stage"; | ||
default: | ||
// TODO: Display user who triggered the action | ||
return "Manual"; | ||
} | ||
}, | ||
}, | ||
{ | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Stage" />, | ||
accessorKey: "stage.name", | ||
}, | ||
{ | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Pub" />, | ||
accessorKey: "pub", | ||
cell: ({ getValue }) => <PubTitle pub={getValue<ActionRun["pub"]>()} />, | ||
}, | ||
{ | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Time" />, | ||
accessorKey: "createdAt", | ||
}, | ||
{ | ||
header: ({ column }) => <DataTableColumnHeader column={column} title="Status" />, | ||
accessorKey: "status", | ||
cell: ({ getValue }) => { | ||
switch (getValue()) { | ||
case "success": | ||
return <Badge color="green">success</Badge>; | ||
case "failure": | ||
return <Badge color="red">failure</Badge>; | ||
default: | ||
return <Badge variant="outline">unknown</Badge>; | ||
} | ||
}, | ||
}, | ||
] as const satisfies ColumnDef<ActionRun, unknown>[]; |
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
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
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
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
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