From 2da9ea272fbc039cf7470299fd7241576971f5b4 Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Thu, 26 Mar 2026 15:57:39 +0000 Subject: [PATCH] feat: Add "All" option to WorkspaceNotificationSummaryItem and update filtering logic in WorkspaceSummaryTable --- .../Workspace/WorkspaceSummaryTable.tsx | 100 +++++++++++++++--- .../WorkspaceNotificationSummaryService.ts | 3 + .../WorkspaceNotificationSummaryItem.ts | 1 + 3 files changed, 91 insertions(+), 13 deletions(-) diff --git a/App/FeatureSet/Dashboard/src/Components/Workspace/WorkspaceSummaryTable.tsx b/App/FeatureSet/Dashboard/src/Components/Workspace/WorkspaceSummaryTable.tsx index d4dd50f71c..fb3522fa4a 100644 --- a/App/FeatureSet/Dashboard/src/Components/Workspace/WorkspaceSummaryTable.tsx +++ b/App/FeatureSet/Dashboard/src/Components/Workspace/WorkspaceSummaryTable.tsx @@ -50,6 +50,7 @@ import { CustomElementProps } from "Common/UI/Components/Forms/Types/Field"; import OneUptimeDate from "Common/Types/Date"; import PageLoader from "Common/UI/Components/Loader/PageLoader"; import ErrorMessage from "Common/UI/Components/ErrorMessage/ErrorMessage"; +import CheckboxElement from "Common/UI/Components/Checkbox/Checkbox"; export interface ComponentProps { workspaceType: WorkspaceType; @@ -322,13 +323,13 @@ const WorkspaceSummaryTable: FunctionComponent = ( }); } - // Default to all summary items if none selected + // Default to "All" if none selected if ( !values.summaryItems || (Array.isArray(values.summaryItems) && values.summaryItems.length === 0) ) { - values.summaryItems = allSummaryItems; + values.summaryItems = [WorkspaceNotificationSummaryItem.All]; } if (values.isEnabled === undefined || values.isEnabled === null) { @@ -493,18 +494,91 @@ const WorkspaceSummaryTable: FunctionComponent = ( }, title: "What to Include", description: - "Choose which sections appear in the summary. The report will be formatted with headers, statistics, and a detailed list.", - fieldType: FormFieldSchemaType.MultiSelectDropdown, - required: true, + "Choose which sections appear in the summary. Select \"All\" to include everything, or pick specific sections.", + fieldType: FormFieldSchemaType.CustomComponent, + required: false, stepId: "content", - dropdownOptions: allSummaryItems.map( - (item: WorkspaceNotificationSummaryItem) => { - return { - label: item, - value: item, - }; - }, - ), + getCustomElement: ( + value: FormValues, + elementProps: CustomElementProps, + ): ReactElement => { + const currentItems: Array = + (value.summaryItems as Array) || + [WorkspaceNotificationSummaryItem.All]; + + const isAllSelected: boolean = currentItems.includes( + WorkspaceNotificationSummaryItem.All, + ); + + const individualItems: Array = + allSummaryItems.filter( + (item: WorkspaceNotificationSummaryItem) => { + return item !== WorkspaceNotificationSummaryItem.All; + }, + ); + + return ( +
+ { + if (elementProps.onChange) { + if (checked) { + elementProps.onChange([ + WorkspaceNotificationSummaryItem.All, + ]); + } else { + elementProps.onChange([]); + } + } + }} + /> +
+ {individualItems.map( + (item: WorkspaceNotificationSummaryItem) => { + return ( + { + if (elementProps.onChange) { + let newItems: Array = + currentItems.filter( + (i: WorkspaceNotificationSummaryItem) => { + return ( + i !== + WorkspaceNotificationSummaryItem.All && + i !== item + ); + }, + ); + if (checked) { + newItems.push(item); + } + // If all individual items are selected, switch to "All" + if ( + newItems.length === individualItems.length + ) { + newItems = [ + WorkspaceNotificationSummaryItem.All, + ]; + } + elementProps.onChange(newItems); + } + }} + /> + ); + }, + )} +
+
+ ); + }, }, { field: { diff --git a/Common/Server/Services/WorkspaceNotificationSummaryService.ts b/Common/Server/Services/WorkspaceNotificationSummaryService.ts index 6d9f8465c0..3f8c46885f 100644 --- a/Common/Server/Services/WorkspaceNotificationSummaryService.ts +++ b/Common/Server/Services/WorkspaceNotificationSummaryService.ts @@ -241,6 +241,9 @@ export class Service extends DatabaseService { items: Array, item: WorkspaceNotificationSummaryItem, ): boolean { + if (items.includes(WorkspaceNotificationSummaryItem.All)) { + return true; + } return items.includes(item); } diff --git a/Common/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.ts b/Common/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.ts index eeea675588..32dd3bd54d 100644 --- a/Common/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.ts +++ b/Common/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.ts @@ -1,4 +1,5 @@ enum WorkspaceNotificationSummaryItem { + All = "All", TotalCount = "Total Count", ListWithLinks = "List with Links", WhoAcknowledged = "Who Acknowledged",