diff --git a/public/app/features/alerting/unified/triage/Workbench.tsx b/public/app/features/alerting/unified/triage/Workbench.tsx index 86ff6c03a1e..64e39d64775 100644 --- a/public/app/features/alerting/unified/triage/Workbench.tsx +++ b/public/app/features/alerting/unified/triage/Workbench.tsx @@ -133,8 +133,10 @@ export function Workbench({ domain, data, queryRunner, groupBy }: WorkbenchProps }); // this will measure the size of the left most column of the splitter, so we can use it to set the width of the group items - const [ref, rect] = useMeasure(); - const leftColumnWidth = rect.width; + const [leftColumnRef, leftColumnRect] = useMeasure(); + const leftColumnWidth = leftColumnRect.width; + const [rightColumnRef, rightColumnRect] = useMeasure(); + const rightColumnWidth = rightColumnRect.width; const itemsToRender = pageIndex * DEFAULT_PER_PAGE_PAGINATION; const dataSlice = take(data, itemsToRender); @@ -145,11 +147,11 @@ export function Workbench({ domain, data, queryRunner, groupBy }: WorkbenchProps {/* dummy splitter to handle flex width of group items */}
-
+
-
+
{/* content goes here */} @@ -160,7 +162,12 @@ export function Workbench({ domain, data, queryRunner, groupBy }: WorkbenchProps
{/* Render actual data */}
- + {isLoading ? ( <> diff --git a/public/app/features/alerting/unified/triage/WorkbenchContext.tsx b/public/app/features/alerting/unified/triage/WorkbenchContext.tsx index 620455d9af6..77f65200eba 100644 --- a/public/app/features/alerting/unified/triage/WorkbenchContext.tsx +++ b/public/app/features/alerting/unified/triage/WorkbenchContext.tsx @@ -6,6 +6,7 @@ import { Domain } from './types'; interface WorkbenchContextValue { leftColumnWidth: number; + rightColumnWidth: number; domain: Domain; queryRunner: SceneQueryRunner; } @@ -22,13 +23,22 @@ export function useWorkbenchContext(): WorkbenchContextValue { interface WorkbenchProviderProps { leftColumnWidth: number; + rightColumnWidth: number; domain: Domain; queryRunner: SceneQueryRunner; children: React.ReactNode; } -export function WorkbenchProvider({ leftColumnWidth, domain, queryRunner, children }: WorkbenchProviderProps) { +export function WorkbenchProvider({ + leftColumnWidth, + rightColumnWidth, + domain, + queryRunner, + children, +}: WorkbenchProviderProps) { return ( - {children} + + {children} + ); } diff --git a/public/app/features/alerting/unified/triage/instance-details/InstanceDetailsDrawer.tsx b/public/app/features/alerting/unified/triage/instance-details/InstanceDetailsDrawer.tsx index 617f097ce89..faeeef7c3dd 100644 --- a/public/app/features/alerting/unified/triage/instance-details/InstanceDetailsDrawer.tsx +++ b/public/app/features/alerting/unified/triage/instance-details/InstanceDetailsDrawer.tsx @@ -17,6 +17,7 @@ import { EventState } from '../../components/rules/central-state-history/EventLi import { LogRecord, historyDataFrameToLogRecords } from '../../components/rules/state-history/common'; import { isAlertQueryOfAlertData } from '../../rule-editor/formProcessing'; import { stringifyErrorLike } from '../../utils/misc'; +import { useWorkbenchContext } from '../WorkbenchContext'; import { InstanceDetailsDrawerTitle } from './InstanceDetailsDrawerTitle'; import { QueryVisualization } from './QueryVisualization'; @@ -25,6 +26,13 @@ import { convertStateHistoryToAnnotations } from './stateHistoryUtils'; const { useGetAlertRuleQuery } = alertRuleApi; const { useGetRuleHistoryQuery } = stateHistoryApi; +function calculateDrawerWidth(rightColumnWidth: number): number { + //first add the padding from the Page (32px) + const calculatedWidth = rightColumnWidth + 32; + // now clamp the width to a max of 1400px + return Math.min(calculatedWidth, 1400); +} + interface InstanceDetailsDrawerProps { ruleUID: string; instanceLabels: Labels; @@ -34,6 +42,9 @@ interface InstanceDetailsDrawerProps { export function InstanceDetailsDrawer({ ruleUID, instanceLabels, onClose }: InstanceDetailsDrawerProps) { const [ref, { width: loadingBarWidth }] = useMeasure(); const [timeRange] = useTimeRange(); + const { rightColumnWidth } = useWorkbenchContext(); + + const drawerWidth = calculateDrawerWidth(rightColumnWidth); const { data: rule, isLoading: loading, error } = useGetAlertRuleQuery({ uid: ruleUID }); @@ -66,7 +77,11 @@ export function InstanceDetailsDrawer({ ruleUID, instanceLabels, onClose }: Inst if (error) { return ( - } onClose={onClose} size="md"> + } + onClose={onClose} + width={drawerWidth} + > ); @@ -74,7 +89,11 @@ export function InstanceDetailsDrawer({ ruleUID, instanceLabels, onClose }: Inst if (loading || !rule) { return ( - } onClose={onClose} size="md"> + } + onClose={onClose} + width={drawerWidth} + > ); @@ -84,7 +103,7 @@ export function InstanceDetailsDrawer({ ruleUID, instanceLabels, onClose }: Inst } onClose={onClose} - size="md" + width={drawerWidth} > diff --git a/public/app/features/alerting/unified/triage/rows/GenericRow.tsx b/public/app/features/alerting/unified/triage/rows/GenericRow.tsx index edc475fbfe1..b2a158f40e3 100644 --- a/public/app/features/alerting/unified/triage/rows/GenericRow.tsx +++ b/public/app/features/alerting/unified/triage/rows/GenericRow.tsx @@ -117,7 +117,7 @@ export const getStyles = (theme: GrafanaTheme2) => { css({ padding: 5, width: '100%', - paddingLeft: depth ? `calc(${theme.spacing(depth)} + 5px)` : 5, + addingLeft: depth ? `calc(${theme.spacing(depth)} + 5px)` : 5, }), groupItemWrapper: (width: number) => css({