From d6bcca2f7e0c90222bc141dec4b101a25179e357 Mon Sep 17 00:00:00 2001 From: Lauren <61048546+laurenashleigh@users.noreply.github.com> Date: Thu, 30 Oct 2025 15:14:37 +0000 Subject: [PATCH] Alerting: Hide metadata if grouping by folder (#113216) * Alerting: Hide metadata if grouping by folder * resolve comments * resolve comments 2 --- .../alerting/unified/triage/Workbench.tsx | 30 +++++++++++++++---- .../unified/triage/rows/AlertRuleRow.tsx | 23 +++++++++----- .../unified/triage/scene/Workbench.tsx | 2 +- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/public/app/features/alerting/unified/triage/Workbench.tsx b/public/app/features/alerting/unified/triage/Workbench.tsx index ceb4196ad7f..86ff6c03a1e 100644 --- a/public/app/features/alerting/unified/triage/Workbench.tsx +++ b/public/app/features/alerting/unified/triage/Workbench.tsx @@ -23,7 +23,7 @@ import { Domain, Filter, WorkbenchRow } from './types'; type WorkbenchProps = { domain: Domain; data: WorkbenchRow[]; - groupBy?: string[]; // @TODO proper type + groupBy?: string[]; filterBy?: Filter[]; queryRunner: SceneQueryRunner; }; @@ -36,13 +36,30 @@ function renderWorkbenchRow( leftColumnWidth: number, domain: Domain, key: React.Key, + enableFolderMeta: boolean, depth = 0 ): React.ReactElement { if (row.type === 'alertRule') { - return ; + return ( + + ); } else { const children = row.rows.map((childRow, childIndex) => - renderWorkbenchRow(childRow, leftColumnWidth, domain, `${key}-${generateRowKey(childRow, childIndex)}`, depth + 1) + renderWorkbenchRow( + childRow, + leftColumnWidth, + domain, + `${key}-${generateRowKey(childRow, childIndex)}`, + enableFolderMeta, + depth + 1 + ) ); // Check if this is a grafana_folder group and use FolderGroupRow @@ -99,11 +116,14 @@ function renderWorkbenchRow( │ │ │ │ └─────────────────────────┘ └───────────────────────────────────┘ */ -export function Workbench({ domain, data, queryRunner }: WorkbenchProps) { +export function Workbench({ domain, data, queryRunner, groupBy }: WorkbenchProps) { const styles = useStyles2(getStyles); const isLoading = !queryRunner.isDataReadyToDisplay(); const [pageIndex, setPageIndex] = useState(1); + + // Calculate once: show folder metadata only if not grouping by grafana_folder + const enableFolderMeta = !groupBy?.includes('grafana_folder'); // splitter for template and payload editor const splitter = useSplitter({ direction: 'row', @@ -151,7 +171,7 @@ export function Workbench({ domain, data, queryRunner }: WorkbenchProps) { ) : ( dataSlice.map((row, index) => { const rowKey = generateRowKey(row, index); - return renderWorkbenchRow(row, leftColumnWidth, domain, rowKey); + return renderWorkbenchRow(row, leftColumnWidth, domain, rowKey, enableFolderMeta); }) )} {hasMore && setPageIndex((prevIndex) => prevIndex + 1)} />} diff --git a/public/app/features/alerting/unified/triage/rows/AlertRuleRow.tsx b/public/app/features/alerting/unified/triage/rows/AlertRuleRow.tsx index 539dc2c4ed1..965e9b5ce31 100644 --- a/public/app/features/alerting/unified/triage/rows/AlertRuleRow.tsx +++ b/public/app/features/alerting/unified/triage/rows/AlertRuleRow.tsx @@ -16,9 +16,16 @@ interface AlertRuleRowProps { leftColumnWidth: number; rowKey: React.Key; depth?: number; + enableFolderMeta?: boolean; } -export const AlertRuleRow = ({ row, leftColumnWidth, rowKey, depth = 0 }: AlertRuleRowProps) => { +export const AlertRuleRow = ({ + row, + leftColumnWidth, + rowKey, + depth = 0, + enableFolderMeta = true, +}: AlertRuleRowProps) => { const { ruleUID, folder, title } = row.metadata; const [isDrawerOpen, setIsDrawerOpen] = useState(false); @@ -45,12 +52,14 @@ export const AlertRuleRow = ({ row, leftColumnWidth, rowKey, depth = 0 }: AlertR /> } metadata={ - - - - {folder} - - + enableFolderMeta ? ( + + + + {folder} + + + ) : undefined } content={} depth={depth} diff --git a/public/app/features/alerting/unified/triage/scene/Workbench.tsx b/public/app/features/alerting/unified/triage/scene/Workbench.tsx index f202a5cd0a0..d83908c2e91 100644 --- a/public/app/features/alerting/unified/triage/scene/Workbench.tsx +++ b/public/app/features/alerting/unified/triage/scene/Workbench.tsx @@ -34,7 +34,7 @@ export function WorkbenchRenderer() { const { data } = runner.useState(); const rows = data ? convertToWorkbenchRows(data, groupByKeys) : []; - return ; + return ; } type DataPoint = Record, string> & Record;