From 203c0243b3a98f6432b07d2c66209858ecb7eeab Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Wed, 1 Nov 2023 09:38:02 +0300 Subject: [PATCH 1/2] refactor: add missing keys and remove unused variables --- .../JobsHistory/JobsHistoryDetails.tsx | 17 ++++++++------ .../notificationsTableColumns.tsx | 22 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/components/JobsHistory/JobsHistoryDetails.tsx b/src/components/JobsHistory/JobsHistoryDetails.tsx index 4255e7ca8..1f40fc52b 100644 --- a/src/components/JobsHistory/JobsHistoryDetails.tsx +++ b/src/components/JobsHistory/JobsHistoryDetails.tsx @@ -2,12 +2,6 @@ import { Modal } from "../Modal"; import { JobHistory } from "./JobsHistoryTable"; import clsx from "clsx"; -type JobsHistoryDetailsProps = { - job?: JobHistory; - isModalOpen: boolean; - setIsModalOpen: (value: boolean) => void; -}; - interface CellProps { children: React.ReactNode; className?: string; @@ -25,6 +19,12 @@ function Cell({ children, className }: CellProps) { ); } +type JobsHistoryDetailsProps = { + job?: Pick; + isModalOpen: boolean; + setIsModalOpen: (value: boolean) => void; +}; + export function JobsHistoryDetails({ job, isModalOpen, @@ -56,7 +56,10 @@ export function JobsHistoryDetails({ {job.details?.errors?.map((error, index) => ( - + {error} diff --git a/src/components/Notifications/notificationsTableColumns.tsx b/src/components/Notifications/notificationsTableColumns.tsx index 003ebd170..5f378dc2d 100644 --- a/src/components/Notifications/notificationsTableColumns.tsx +++ b/src/components/Notifications/notificationsTableColumns.tsx @@ -156,17 +156,15 @@ export const notificationsTableColumns: ColumnDef[] = [ {custom_services && custom_services.length > 0 && - custom_services.map( - ({ connection, name, filters, properties, url }) => ( -
- - {name} -
- ) - )} + custom_services.map(({ connection, name }) => ( +
+ + {name} +
+ ))} ); } @@ -182,7 +180,7 @@ export const notificationsTableColumns: ColumnDef[] = [ return (
{value.map((event) => ( -
+
))} From 17734e8c17b3420aa539f0b93ca641ff72df174d Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Wed, 1 Nov 2023 09:58:25 +0300 Subject: [PATCH 2/2] fix: show error message on click notification job status Closes #1387 --- .../JobsHistory/JobHistoryStatusColumn.tsx | 22 ++++++++++---- .../notificationsTableColumns.tsx | 29 +++++++++++++++++-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/components/JobsHistory/JobHistoryStatusColumn.tsx b/src/components/JobsHistory/JobHistoryStatusColumn.tsx index 93bff3e68..685731ebc 100644 --- a/src/components/JobsHistory/JobHistoryStatusColumn.tsx +++ b/src/components/JobsHistory/JobHistoryStatusColumn.tsx @@ -4,9 +4,10 @@ import { FaDotCircle } from "react-icons/fa"; type Props = { status?: JobHistoryStatus; + onClick?: () => void; }; -export default function JobHistoryStatusColumn({ status }: Props) { +export default function JobHistoryStatusColumn({ status, onClick }: Props) { const className = useMemo(() => { if (status) { return classNameMaps.get(status); @@ -18,9 +19,20 @@ export default function JobHistoryStatusColumn({ status }: Props) { } return ( - <> - - {status} - +
{ + if (!onClick) { + return; + } + e.preventDefault(); + e.stopPropagation(); + onClick(); + }} + > + + {status} +
); } diff --git a/src/components/Notifications/notificationsTableColumns.tsx b/src/components/Notifications/notificationsTableColumns.tsx index 5f378dc2d..6aeb9abc3 100644 --- a/src/components/Notifications/notificationsTableColumns.tsx +++ b/src/components/Notifications/notificationsTableColumns.tsx @@ -1,10 +1,12 @@ import { CellContext, ColumnDef } from "@tanstack/react-table"; +import { useState } from "react"; import { Team, User } from "../../api/types/users"; import { DateCell } from "../../ui/table"; import { Avatar } from "../Avatar"; import { Badge } from "../Badge"; import { Icon } from "../Icon"; import JobHistoryStatusColumn from "../JobsHistory/JobHistoryStatusColumn"; +import { JobsHistoryDetails } from "../JobsHistory/JobsHistoryDetails"; import { JobHistoryStatus } from "../JobsHistory/JobsHistoryTable"; export const notificationEvents = [ @@ -90,14 +92,31 @@ export const notificationEvents = [ } ].sort((a, b) => a.label.localeCompare(b.label)); -export function JobStatusColumn({ cell }: CellContext) { +export function StatusColumn({ cell }: CellContext) { + const [isModalOpen, setIsModalOpen] = useState(false); const value = cell.row.original.job_status; - return ; + return ( + <> + setIsModalOpen(true)} + /> + + + ); } export type Notification = { id: string; + title: string; events: string[]; template: string; filter?: string; @@ -118,6 +137,10 @@ export type Notification = { person?: User; team?: Team; job_status?: JobHistoryStatus; + job_name?: string; + job_details?: { + errors?: string[]; + }; }; export type NewNotification = Omit< @@ -215,7 +238,7 @@ export const notificationsTableColumns: ColumnDef[] = [ { header: "Status", id: "job_status", - cell: JobStatusColumn + cell: StatusColumn }, { header: "Created At",