From c12eb808670dee64e0e35fb87e4543e3aee053be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Sun, 29 Dec 2024 22:48:06 +0100 Subject: [PATCH] fix(dashboard): improvements to notifications templates --- .../settings/integrations/page.tsx | 21 ++++---- .../src/components/forms/input-with-label.tsx | 2 +- .../notifications/table/columns.tsx | 28 ++++++---- apps/dashboard/src/components/ui/tooltip.tsx | 7 ++- .../src/modals/add-notification-rule.tsx | 43 +++++++++++++++- .../migration.sql | 5 ++ packages/db/prisma/schema.prisma | 51 ++++++++++--------- .../db/src/services/notification.service.ts | 37 ++++++++++++-- packages/trpc/src/routers/notification.ts | 14 ++--- 9 files changed, 149 insertions(+), 59 deletions(-) create mode 100644 packages/db/prisma/migrations/20241229150840_add_rule_to_notification/migration.sql diff --git a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/integrations/page.tsx b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/integrations/page.tsx index 349ae84c..53851847 100644 --- a/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/integrations/page.tsx +++ b/apps/dashboard/src/app/(app)/[organizationSlug]/[projectId]/settings/integrations/page.tsx @@ -21,17 +21,16 @@ export default function Page({ .withDefault('available') .parseServerSide(searchParams.tab); return ( - - - - Available - - - Installed - - - {tab === 'installed' && } - {tab === 'available' && } + +
+

Your integrations

+ +
+ +
+

Available integrations

+ +
); } diff --git a/apps/dashboard/src/components/forms/input-with-label.tsx b/apps/dashboard/src/components/forms/input-with-label.tsx index 937086da..6e07fa61 100644 --- a/apps/dashboard/src/components/forms/input-with-label.tsx +++ b/apps/dashboard/src/components/forms/input-with-label.tsx @@ -10,7 +10,7 @@ type WithLabel = { children: React.ReactNode; label: string; error?: string | undefined; - info?: string; + info?: React.ReactNode; className?: string; }; type InputWithLabelProps = InputProps & Omit; diff --git a/apps/dashboard/src/components/notifications/table/columns.tsx b/apps/dashboard/src/components/notifications/table/columns.tsx index e4eae86a..d9d78375 100644 --- a/apps/dashboard/src/components/notifications/table/columns.tsx +++ b/apps/dashboard/src/components/notifications/table/columns.tsx @@ -28,7 +28,7 @@ export function useColumns() { const { title, isReadAt } = row.original; return (
- {isReadAt === null && Unread} + {/* {isReadAt === null && Unread} */} {title}
); @@ -46,6 +46,22 @@ export function useColumns() { ); }, }, + { + accessorKey: 'integration', + header: 'Integration', + cell({ row }) { + const integration = row.original.integration; + return
{integration?.name}
; + }, + }, + { + accessorKey: 'notificationRule', + header: 'Rule', + cell({ row }) { + const rule = row.original.notificationRule; + return
{rule?.name}
; + }, + }, { accessorKey: 'country', header: 'Country', @@ -121,16 +137,8 @@ export function useColumns() { header: 'Created at', cell({ row }) { const date = row.original.createdAt; - const rule = row.original.integration?.notificationRules[0]; return ( -
-
{isToday(date) ? formatTime(date) : formatDateTime(date)}
- {rule && ( -
- Rule: {rule.name} -
- )} -
+
{isToday(date) ? formatTime(date) : formatDateTime(date)}
); }, }, diff --git a/apps/dashboard/src/components/ui/tooltip.tsx b/apps/dashboard/src/components/ui/tooltip.tsx index b9865d43..415754fc 100644 --- a/apps/dashboard/src/components/ui/tooltip.tsx +++ b/apps/dashboard/src/components/ui/tooltip.tsx @@ -62,7 +62,12 @@ export function Tooltiper({ if (disabled) return children; return ( - + {children} diff --git a/apps/dashboard/src/modals/add-notification-rule.tsx b/apps/dashboard/src/modals/add-notification-rule.tsx index e5c124fe..79adc791 100644 --- a/apps/dashboard/src/modals/add-notification-rule.tsx +++ b/apps/dashboard/src/modals/add-notification-rule.tsx @@ -164,7 +164,48 @@ export default function AddNotificationRule({ rule }: Props) { +

+ Customize your notification message. You can grab any property + from your event. +

+ +
    +
  • + {'{{name}}'} - The name of the event +
  • +
  • + {'{{rule_name}}'} - The name of the rule +
  • +
  • + {'{{properties.your.property}}'} - Get the value + of a custom property +
  • +
  • +
    + And many more... + profileId + createdAt + country + city + os + osVersion + browser + browserVersion + device + brand + model + path + origin + referrer + referrerName + referrerType +
    +
  • +
+ + } >