Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat(dashboard): redesign panel editor config pane (#13010)

Abhi kumar49a0f7552e6d
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.module.scss
index dfd3330f18..016dcbeb00 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.module.scss
@@ -8,6 +8,7 @@
background-color: var(--l1-background);
overflow-y: auto;
overflow-x: hidden;
+ scrollbar-gutter: stable;
padding-bottom: 44px;
@include custom-scrollbar;
@@ -42,11 +43,12 @@
.eyebrow {
display: block;
- font-size: 11px;
- font-weight: 600;
- padding: 16px;
- letter-spacing: 0.06em;
- color: var(--l1-foreground);
+ padding: 18px 20px 12px;
+ font-family: 'Geist Mono', monospace;
+ font-size: 12px;
+ letter-spacing: 0.1em;
+ text-transform: uppercase;
+ color: var(--l2-foreground);
}
.group {
@@ -73,9 +75,5 @@
.sections {
display: flex;
flex-direction: column;
-
- & > * {
- padding: 0 16px;
- border-top: 1px solid var(--l1-border);
- }
+ border-bottom: 1px solid var(--l1-border);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx
index e2df5ac8ae..c39c0aa920 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/ConfigPane.tsx
@@ -1,3 +1,4 @@
+import { useMemo } from 'react';
import { Input } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import type {
@@ -7,6 +8,7 @@ import type {
import { getPanelDefinition } from 'pages/DashboardPage/DashboardContainer/Panels/registry';
import { SectionKind } from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
import { getSupportedSignals } from 'pages/DashboardPage/DashboardContainer/Panels/capabilities';
+import { buildPluginSpec } from 'pages/DashboardPage/DashboardContainer/Panels/utils/buildPluginSpec';
import { resolveSignal } from 'pages/DashboardPage/DashboardContainer/Panels/utils/getBuilderQueries';
import type { EQueryType } from 'types/common/dashboard';
@@ -22,6 +24,8 @@ import { PanelKind } from '../../Panels/types/panelKind';
interface ConfigPaneProps {
/** The panel spec — the single editing surface (title/description + section slices). */
spec: DashboardtypesPanelSpecDTO;
+ /** Last saved spec, the baseline for each section's changed marker. */
+ savedSpec: DashboardtypesPanelSpecDTO;
onChangeSpec: (next: DashboardtypesPanelSpecDTO) => void;
/** Switch the panel to another visualization kind. */
onChangePanelKind: (kind: PanelKind) => void;
@@ -56,6 +60,7 @@ interface ConfigPaneProps {
*/
function ConfigPane({
spec,
+ savedSpec,
onChangeSpec,
onChangePanelKind,
originalPanelKind,
@@ -78,6 +83,11 @@ function ConfigPane({
(config) => config.kind !== SectionKind.PanelHeader,
);
+ const defaults = useMemo(
+ () => buildPluginSpec(definition.sections),
+ [definition],
+ );
+
const signal = resolveSignal(spec.queries, getSupportedSignals(panelKind)[0]);
// Title/description are just a slice of the spec — edit them through the same
@@ -121,7 +131,9 @@ function ConfigPane({
bare
config={headerSection}
spec={spec}
+ savedSpec={savedSpec}
onChangeSpec={onChangeSpec}
+ defaults={defaults}
legendSeries={legendSeries}
tableColumns={tableColumns}
signal={signal}
@@ -146,7 +158,9 @@ function ConfigPane({
key={config.kind}
config={config}
spec={spec}
+ savedSpec={savedSpec}
onChangeSpec={onChangeSpec}
+ defaults={defaults}
legendSeries={legendSeries}
tableColumns={tableColumns}
signal={signal}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.module.scss
index 7f0c848c71..81da460903 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.module.scss
@@ -1,12 +1,5 @@
@use '../../../../../../styles/scrollbar' as *;
-// Matches ConfigPane's `.field` so the switcher lines up with the title/description fields.
-.field {
- display: flex;
- flex-direction: column;
- gap: 8px;
-}
-
.trigger {
--button-height: 36px;
--button-padding: 0 5px 0 12px;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx
index a943f3abbd..bf5f34ffe8 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/PanelTypeSwitcher/PanelTypeSwitcher.tsx
@@ -2,13 +2,13 @@ import { useCallback, useState } from 'react';
import { ArrowRightLeft, Undo2 } from '@signozhq/icons';
import { Button } from '@signozhq/ui/button';
import { DrawerWrapper } from '@signozhq/ui/drawer';
-import { Typography } from '@signozhq/ui/typography';
import type { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
import type { EQueryType } from 'types/common/dashboard';
import PanelTypeBrowser from '../../../PanelsAndSectionsLayout/Panel/PanelTypeSelectionModal/PanelTypeBrowser';
import { getPanelDefinition } from '../../../Panels/registry';
import type { PanelKind } from '../../../Panels/types/panelKind';
+import ConfigField from '../controls/ConfigField/ConfigField';
import styles from './PanelTypeSwitcher.module.scss';
import { getPanelTypeDisabledReason } from './utils';
@@ -64,8 +64,7 @@ function PanelTypeSwitcher({
};
return (
- <div className={styles.field}>
- <Typography.Text>Panel Type</Typography.Text>
+ <ConfigField label="Panel type">
<Button
variant="outlined"
color="secondary"
@@ -111,7 +110,7 @@ function PanelTypeSwitcher({
getDisabledReason={getDisabledReason}
/>
</DrawerWrapper>
- </div>
+ </ConfigField>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx
index 606be05c46..72cf68a18e 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/SectionSlot.tsx
@@ -6,16 +6,22 @@ import {
type SectionConfig,
SectionKind,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
+import type { SeededPluginSpec } from 'pages/DashboardPage/DashboardContainer/Panels/utils/buildPluginSpec';
import type { SectionEditorContext } from '../sectionContext';
-import { resolveSectionEditor } from '../sectionRegistry';
+import { getSectionDefault, resolveSectionEditor } from '../sectionRegistry';
import SettingsSection from '../SettingsSection/SettingsSection';
+import { isDifferent } from '../utils/changes';
import SectionHeaderQuickAdd from './SectionHeaderQuickAdd';
type SectionSlotProps = {
config: SectionConfig;
spec: DashboardtypesPanelSpecDTO;
+ /** Last saved spec; a section whose slice differs from it is marked changed. */
+ savedSpec: DashboardtypesPanelSpecDTO;
onChangeSpec: (next: DashboardtypesPanelSpecDTO) => void;
+ /** The kind's seeded plugin spec (`buildPluginSpec`). */
+ defaults: SeededPluginSpec;
/** Renders the editor alone, for a section promoted into the Panel Details fields. */
bare?: boolean;
} & Omit<SectionEditorContext, 'yAxisUnit' | 'registerHeaderAction'>;
@@ -51,7 +57,9 @@ const SECTION_HEADER_SLOT: Partial<
function SectionSlot({
config,
spec,
+ savedSpec,
onChangeSpec,
+ defaults,
bare,
legendSeries,
tableColumns,
@@ -104,8 +112,11 @@ function SectionSlot({
return null;
}
- const { title, icon: Icon } = SECTION_METADATA[config.kind];
+ const { title } = SECTION_METADATA[config.kind];
const { Component, get, update } = editor;
+ const value = get(spec);
+ const defaultValue = getSectionDefault(editor, spec, defaults);
+ const savedValue = get(savedSpec);
// Atomic sections carry no `controls`; controlled ones do.
const controls = 'controls' in config ? config.controls : undefined;
// Forwarded to editors that scope to the panel's unit (e.g. the thresholds unit picker).
@@ -114,21 +125,27 @@ function SectionSlot({
const headerSlot = SECTION_HEADER_SLOT[config.kind]?.(triggerHeaderAction);
+ const context: SectionEditorContext = {
+ legendSeries,
+ yAxisUnit,
+ tableColumns,
+ signal,
+ panelKind,
+ onChangePanelKind,
+ originalPanelKind,
+ queryType,
+ stepInterval,
+ metricUnit,
+ };
+
const editorElement = (
<Component
- value={get(spec)}
+ value={value}
+ defaultValue={defaultValue}
+ savedValue={savedValue}
controls={controls}
onChange={(next): void => onChangeSpec(update(spec, next))}
- legendSeries={legendSeries}
- yAxisUnit={yAxisUnit}
- tableColumns={tableColumns}
- signal={signal}
- panelKind={panelKind}
- onChangePanelKind={onChangePanelKind}
- originalPanelKind={originalPanelKind}
- queryType={queryType}
- stepInterval={stepInterval}
- metricUnit={metricUnit}
+ {...context}
registerHeaderAction={registerHeaderAction}
/>
);
@@ -140,7 +157,7 @@ function SectionSlot({
return (
<SettingsSection
title={title}
- icon={<Icon size={15} />}
+ changed={isDifferent(value, savedValue)}
open={open}
onOpenChange={setOpen}
headerSlot={headerSlot}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/__tests__/SectionSlot.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/__tests__/SectionSlot.test.tsx
index e239397719..1a01494cb1 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/__tests__/SectionSlot.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SectionSlot/__tests__/SectionSlot.test.tsx
@@ -24,11 +24,16 @@ function makeSpec(thresholds: unknown[] = []): DashboardtypesPanelSpecDTO {
// Stateful harness so onChange feeds back into the spec (as ConfigPane owns it).
function Harness({ initial = [] }: { initial?: unknown[] } = {}): JSX.Element {
- const [spec, setSpec] = useState<DashboardtypesPanelSpecDTO>(
- makeSpec(initial),
- );
+ const [savedSpec] = useState(() => makeSpec(initial));
+ const [spec, setSpec] = useState<DashboardtypesPanelSpecDTO>(savedSpec);
return (
- <SectionSlot config={THRESHOLDS_CONFIG} spec={spec} onChangeSpec={setSpec} />
+ <SectionSlot
+ config={THRESHOLDS_CONFIG}
+ spec={spec}
+ savedSpec={savedSpec}
+ defaults={{}}
+ onChangeSpec={setSpec}
+ />
);
}
@@ -70,3 +75,49 @@ describe('SectionSlot header action', () => {
expect(screen.getByTestId('threshold-value-0')).toBeInTheDocument();
});
});
+
+describe('SectionSlot changed marker', () => {
+ it('shows no marker when the section matches the saved spec', () => {
+ render(
+ <Harness initial={[{ value: 80, color: '#F5B225', label: 'High' }]} />,
+ );
+
+ expect(screen.queryByTestId('config-changed-dot')).not.toBeInTheDocument();
+ });
+
+ it('marks a section edited since the last save', async () => {
+ const user = userEvent.setup();
+ render(<Harness />);
+
+ await user.click(screen.getByTestId('panel-editor-v2-add-threshold-header'));
+
+ expect(screen.getByTestId('config-changed-dot')).toBeInTheDocument();
+ });
+
+ it('treats an unset saved slice and an explicit empty one as unchanged', () => {
+ const savedSpec = {
+ display: { name: 'CPU' },
+ plugin: { kind: 'signoz/TimeSeriesPanel', spec: {} },
+ queries: [],
+ } as unknown as DashboardtypesPanelSpecDTO;
+ const spec = {
+ ...savedSpec,
+ plugin: {
+ kind: 'signoz/TimeSeriesPanel',
+ spec: { formatting: { unit: '' } },
+ },
+ } as unknown as DashboardtypesPanelSpecDTO;
+
+ render(
+ <SectionSlot
+ config={{ kind: SectionKind.Formatting, controls: { decimals: true } }}
+ spec={spec}
+ savedSpec={savedSpec}
+ defaults={{}}
+ onChangeSpec={jest.fn()}
+ />,
+ );
+
+ expect(screen.queryByTestId('config-changed-dot')).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.module.scss
index 83f0d01be0..688845a56e 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.module.scss
@@ -1,51 +1,42 @@
+.section {
+ border-top: 1px solid var(--l1-border);
+}
+
.header {
display: flex;
align-items: center;
gap: 6px;
- width: 100%;
- height: 44px;
+ padding: 0 20px 0 0;
+
+ &:hover {
+ background: var(--l2-background);
+ }
}
-// Disclosure control (icon tile + title); fills the row so the action slot and chevron sit right.
.toggle {
display: flex;
flex: 1;
align-items: center;
- gap: 11px;
+ gap: 10px;
min-width: 0;
- padding: 0 !important;
+ padding: 18px 0 18px 20px;
border: none;
background: transparent;
+ font: inherit;
cursor: pointer;
- color: var(--text-vanilla-100);
- border-radius: 4px;
-}
-
-.iconTile {
- display: grid;
- place-items: center;
- width: 27px;
- height: 27px;
- flex: none;
- border-radius: 3px;
- background: var(--l3-background);
- color: var(--l3-foreground);
- transition: all 0.15s ease;
-}
-
-.iconTileOpen {
- background: color-mix(in srgb, var(--bg-robin-400) 14%, transparent);
- color: var(--bg-robin-400);
}
.title {
- flex: 1;
- text-align: left;
- font-weight: 600;
- color: var(--l2-foreground);
+ font-size: 13px;
+ font-weight: 400;
+ white-space: nowrap;
+ color: var(--l1-foreground);
}
.chevron {
+ flex: none;
+ color: var(--l3-foreground);
+ cursor: pointer;
transition: transform 0.15s ease;
&.open {
@@ -56,6 +47,6 @@
.body {
display: flex;
flex-direction: column;
- gap: 16px;
- padding: 2px 0 18px;
+ gap: 26px;
+ padding: 4px 20px 26px;
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.tsx
index b699adfcba..6017893f6e 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/SettingsSection/SettingsSection.tsx
@@ -1,18 +1,18 @@
import { type ReactNode, useState } from 'react';
import { ChevronDown } from '@signozhq/icons';
-import { Button } from '@signozhq/ui/button';
-import { Typography } from '@signozhq/ui/typography';
import cx from 'classnames';
+import ChangedDot from '../controls/ChangedDot/ChangedDot';
+
import styles from './SettingsSection.module.scss';
interface SettingsSectionProps {
title: string;
- icon?: ReactNode;
defaultOpen?: boolean;
/** Controlled open state; when set, the section defers to `onOpenChange`. */
open?: boolean;
onOpenChange?: (open: boolean) => void;
+ changed?: boolean;
/** Rendered between the title and the chevron. */
headerSlot?: ReactNode;
children: ReactNode;
@@ -23,10 +23,10 @@ interface SettingsSectionProps {
*/
function SettingsSection({
title,
- icon,
defaultOpen = false,
open,
onOpenChange,
+ changed,
headerSlot,
children,
}: SettingsSectionProps): JSX.Element {
@@ -51,30 +51,17 @@ function SettingsSection({
type="button"
className={styles.toggle}
aria-expanded={isOpen}
+ aria-label={isOpen ? `Collapse ${title}` : `Expand ${title}`}
data-testid={`config-section-${serializedTitle}`}
onClick={toggle}
>
- {icon && (
- <span className={cx(styles.iconTile, { [styles.iconTileOpen]: isOpen })}>
- {icon}
- </span>
- )}
- <Typography.Text className={styles.title}>{title}</Typography.Text>
+ <span className={styles.title}>{title}</span>
+ {changed && <ChangedDot title="Unsaved changes" />}
</button>
{headerSlot}
- <Button
- type="button"
- variant="ghost"
- color="secondary"
- size="icon"
- prefix={
- <ChevronDown
- size={15}
- className={cx(styles.chevron, { [styles.open]: isOpen })}
- />
- }
- aria-label={isOpen ? `Collapse ${title}` : `Expand ${title}`}
- tabIndex={-1}
+ <ChevronDown
+ size={14}
+ className={cx(styles.chevron, { [styles.open]: isOpen })}
onClick={toggle}
/>
</div>
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsx
index 2aa37b3070..00f3db8037 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/__tests__/ConfigPane.test.tsx
@@ -47,6 +47,7 @@ function renderConfigPane(
): React.ComponentProps<typeof ConfigPane> {
const props: React.ComponentProps<typeof ConfigPane> = {
spec: spec(),
+ savedSpec: spec(),
onChangeSpec: jest.fn(),
onChangePanelKind: jest.fn(),
queryType: EQueryType.QUERY_BUILDER,
@@ -108,7 +109,7 @@ describe('ConfigPane', () => {
const toggle = screen.getByTestId('panel-header-hide');
expect(toggle).toBeInTheDocument();
- expect(screen.getByText('Hide header')).toBeInTheDocument();
+ expect(screen.getByText('Hide panel header')).toBeInTheDocument();
// No collapsible wrapper of its own.
expect(screen.queryByText('Panel header')).not.toBeInTheDocument();
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/AlignmentGrid.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/AlignmentGrid.module.scss
new file mode 100644
index 0000000000..cb8f824950
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/AlignmentGrid.module.scss
@@ -0,0 +1,80 @@
+.row {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+}
+
+.grid {
+ display: grid;
+ flex: none;
+ grid-template-columns: repeat(3, 28px);
+ gap: 4px;
+ padding: 6px;
+ border: 1px solid var(--l1-border);
+ border-radius: 4px;
+ background: var(--l2-background);
+}
+
+.cell {
+ position: relative;
+ display: grid;
+ place-items: center;
+ width: 28px;
+ height: 22px;
+ padding: 0;
+ border: 1px solid transparent;
+ border-radius: 3px;
+ background: transparent;
+ cursor: pointer;
+
+ &:hover {
+ background: var(--l3-background);
+ }
+
+ &:has(:focus-visible) {
+ outline: 1px solid var(--bg-robin-500);
+ }
+}
+
+.input {
+ position: absolute;
+ inset: 0;
+ margin: 0;
+ opacity: 0;
+ cursor: pointer;
+}
+
+.mark {
+ width: 10px;
+ height: 3px;
+ border-radius: 2px;
+ background: var(--l3-foreground);
+}
+
+.selected {
+ border-color: var(--bg-robin-500);
+ background: color-mix(in srgb, var(--bg-robin-500) 12%, transparent);
+
+ .mark {
+ width: 14px;
+ background: var(--bg-robin-400);
+ }
+}
+
+.text {
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ min-width: 0;
+}
+
+.label {
+ font-size: 14px;
+ color: var(--l1-foreground);
+}
+
+.description {
+ font-size: 12px;
+ line-height: 17px;
+ color: var(--l2-foreground);
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/AlignmentGrid.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/AlignmentGrid.tsx
new file mode 100644
index 0000000000..e88637debe
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/AlignmentGrid.tsx
@@ -0,0 +1,64 @@
+import { useId } from 'react';
+import cx from 'classnames';
+
+import { type Alignment, ALIGNMENT_CELLS, alignmentLabel } from './alignment';
+
+import styles from './AlignmentGrid.module.scss';
+
+interface AlignmentGridProps {
+ testId: string;
+ value: Alignment;
+ description?: string;
+ onChange: (next: Alignment) => void;
+}
+
+function AlignmentGrid({
+ testId,
+ value,
+ description,
+ onChange,
+}: AlignmentGridProps): JSX.Element {
+ const name = useId();
+
+ return (
+ <div className={styles.row}>
+ <div
+ role="radiogroup"
+ aria-label="Text position"
+ data-testid={testId}
+ className={styles.grid}
+ >
+ {ALIGNMENT_CELLS.map((cell) => {
+ const label = alignmentLabel(cell);
+ const selected =
+ cell.textAlign === value.textAlign &&
+ cell.verticalAlign === value.verticalAlign;
+ return (
+ <label
+ key={label}
+ title={label}
+ data-testid={`${testId}-${cell.verticalAlign}-${cell.textAlign}`}
+ className={cx(styles.cell, { [styles.selected]: selected })}
+ >
+ <input
+ type="radio"
+ className={styles.input}
+ name={name}
+ checked={selected}
+ aria-label={label}
+ onChange={(): void => onChange(cell)}
+ />
+ <span className={styles.mark} />
+ </label>
+ );
+ })}
+ </div>
+ <div className={styles.text}>
+ <span className={styles.label}>{alignmentLabel(value)}</span>
+ {description && <span className={styles.description}>{description}</span>}
+ </div>
+ </div>
+ );
+}
+
+export default AlignmentGrid;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/alignment.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/alignment.ts
new file mode 100644
index 0000000000..26d105df2d
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/AlignmentGrid/alignment.ts
@@ -0,0 +1,37 @@
+import {
+ DashboardtypesTextAlignDTO,
+ DashboardtypesVerticalAlignDTO,
+} from 'api/generated/services/sigNoz.schemas';
+
+const VERTICAL_LABELS: Record<DashboardtypesVerticalAlignDTO, string> = {
+ [DashboardtypesVerticalAlignDTO.top]: 'Top',
+ [DashboardtypesVerticalAlignDTO.center]: 'Middle',
+ [DashboardtypesVerticalAlignDTO.bottom]: 'Bottom',
+};
+
+const HORIZONTAL_LABELS: Record<DashboardtypesTextAlignDTO, string> = {
+ [DashboardtypesTextAlignDTO.left]: 'left',
+ [DashboardtypesTextAlignDTO.center]: 'center',
+ [DashboardtypesTextAlignDTO.right]: 'right',
+};
+
+export interface Alignment {
+ textAlign: DashboardtypesTextAlignDTO;
+ verticalAlign: DashboardtypesVerticalAlignDTO;
+}
+
+export const ALIGNMENT_CELLS: Alignment[] = Object.values(
+ DashboardtypesVerticalAlignDTO,
+).flatMap((verticalAlign) =>
+ Object.values(DashboardtypesTextAlignDTO).map((textAlign) => ({
+ textAlign,
+ verticalAlign,
+ })),
+);
+
+export function alignmentLabel({
+ textAlign,
+ verticalAlign,
+}: Alignment): string {
+ return `${VERTICAL_LABELS[verticalAlign]} ${HORIZONTAL_LABELS[textAlign]}`;
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/BackgroundSwatches.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/BackgroundSwatches.tsx
deleted file mode 100644
index 34cfb9ffff..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/BackgroundSwatches.tsx
+++ /dev/null
@@ -1,119 +0,0 @@
-import { Fragment } from 'react';
-import { Check } from '@signozhq/icons';
-import { TooltipSimple } from '@signozhq/ui/tooltip';
-import cx from 'classnames';
-import {
- TEXT_BACKGROUND_PAIRS,
- TEXT_BACKGROUND_PRESETS,
-} from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/presets';
-import type {
- PanelTheme,
- TextBackgroundPreset,
- TextBackgroundSelection,
-} from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/types';
-import { TextBackgroundKind } from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/types';
-
-import styles from './BackgroundSwatches.module.scss';
-
-const PRESET_TITLES: Record<TextBackgroundPreset, string> = {
- robin: 'Robin',
- purple: 'Purple',
- sakura: 'Sakura',
- cherry: 'Cherry',
- amber: 'Amber',
- forest: 'Forest',
- sienna: 'Sienna',
- slate: 'Slate',
-};
-
-type BaseSelection = TextBackgroundKind.None | TextBackgroundKind.Default;
-
-const BASE_TITLES: Record<BaseSelection, string> = {
- none: 'Transparent',
- default: 'Default panel',
-};
-
-/** Neither base swatch shows a colour, so its tooltip says what it does. */
-const BASE_TOOLTIPS: Record<BaseSelection, string> = {
- none: 'Transparent — no card, border or title bar',
- default: 'Default panel colour',
-};
-
-const OPTIONS: TextBackgroundSelection[] = [
- TextBackgroundKind.None,
- TextBackgroundKind.Default,
- ...TEXT_BACKGROUND_PRESETS,
-];
-
-const DIVIDER_AFTER = 1;
-
-interface BackgroundSwatchesProps {
- testId: string;
- /** Names the group for assistive tech — the row carries no visible label. */
- label: string;
- /** `undefined` while a custom colour is active: no swatch is selected. */
- value: TextBackgroundSelection | undefined;
- /** Swatches paint in this theme's pair, so what the user picks is what they see. */
- theme: PanelTheme;
- onChange: (value: TextBackgroundSelection) => void;
-}
-
-/**
- * The Text panel's background choices as one radio group. Native radios sharing a
- * `name`, so arrow-key movement, the single tab stop and selection-follows-focus
- * are the platform's; each input is transparent and fills its swatch.
- */
-function BackgroundSwatches({
- testId,
- label,
- value,
- theme,
- onChange,
-}: BackgroundSwatchesProps): JSX.Element {
- return (
- <div
- className={styles.row}
- role="radiogroup"
- aria-label={label}
- data-testid={testId}
- >
- {OPTIONS.map((option, index) => {
- const isBase =
- option === TextBackgroundKind.None ||
- option === TextBackgroundKind.Default;
- const pair = isBase ? undefined : TEXT_BACKGROUND_PAIRS[option][theme];
- const title = isBase ? BASE_TITLES[option] : PRESET_TITLES[option];
-
- return (
- <Fragment key={option}>
- <TooltipSimple title={isBase ? BASE_TOOLTIPS[option] : title} arrow>
- <label
- className={cx(styles.swatch, {
- [styles.checkerboard]: option === TextBackgroundKind.None,
- [styles.defaultSurface]: option === TextBackgroundKind.Default,
- [styles.selected]: option === value,
- })}
- style={pair ? { background: pair.surface, color: pair.ink } : undefined}
- data-testid={`${testId}-${option}`}
- >
- <input
- type="radio"
- className={styles.input}
- name={testId}
- value={option}
- checked={option === value}
- aria-label={title}
- onChange={(): void => onChange(option)}
- />
- {option === value && <Check size={14} />}
- </label>
- </TooltipSimple>
- {index === DIVIDER_AFTER && <span className={styles.divider} />}
- </Fragment>
- );
- })}
- </div>
- );
-}
-
-export default BackgroundSwatches;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/CustomBackgroundRow.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/CustomBackgroundRow.module.scss
deleted file mode 100644
index 7f2ca8fcfc..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/CustomBackgroundRow.module.scss
+++ /dev/null
@@ -1,67 +0,0 @@
-.row {
- display: flex;
- width: 100%;
- align-items: center;
- gap: 10px;
- padding: 8px 10px;
- border: 1px solid var(--l2-border);
- border-radius: 4px;
- background: transparent;
- cursor: pointer;
- text-align: left;
-}
-
-.active {
- border-color: var(--bg-robin-500);
-}
-
-.chip {
- flex: none;
- width: 18px;
- height: 18px;
- display: inline-flex;
- align-items: center;
- justify-content: center;
- border: 1px solid var(--l2-border);
- border-radius: 4px;
-}
-
-// No colour to show yet, so the chip advertises that it opens a picker.
-.chipEmpty {
- background: conic-gradient(
- from 0deg,
- var(--bg-cherry-400),
- var(--bg-amber-400),
- var(--bg-forest-400),
- var(--bg-robin-400),
- var(--bg-sakura-400),
- var(--bg-cherry-400)
- );
-}
-
-.label {
- flex: 1;
- font-size: 12px;
- color: var(--l2-foreground);
-}
-
-.hex {
- font-family: var(--font-family-sf-mono);
- font-size: 12px;
- color: var(--text-vanilla-400);
- letter-spacing: 0.02em;
-}
-
-// Appended under the picker's own panel.
-.contrast {
- display: flex;
- align-items: center;
- gap: 6px;
- padding: 8px 4px 2px;
- font-size: 12px;
- color: var(--text-vanilla-400);
-}
-
-.warning {
- color: var(--bg-amber-400);
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/CustomBackgroundRow.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/CustomBackgroundRow.tsx
deleted file mode 100644
index 5ca980a38d..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/CustomBackgroundRow.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import type { ReactNode } from 'react';
-import { Check, ChevronDown, TriangleAlert } from '@signozhq/icons';
-import { Typography } from '@signozhq/ui/typography';
-import { ColorPicker } from 'antd';
-import cx from 'classnames';
-import {
- contrastRatio,
- inkForSurface,
- MIN_CONTRAST_RATIO,
-} from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/contrast';
-
-import styles from './CustomBackgroundRow.module.scss';
-
-const HEX_PLACEHOLDER = '#______';
-
-/** What the picker opens on before a colour is chosen. */
-const INITIAL_COLOR = '#3A2A63';
-
-interface CustomBackgroundRowProps {
- testId: string;
- /** The stored hex while a custom colour is active; `undefined` otherwise. */
- value: string | undefined;
- onChange: (hex: string) => void;
-}
-
-/**
- * The custom colour, as a row rather than a swatch: it opens a picker instead of
- * committing a value in one click. The picker warns below the contrast floor but
- * never blocks the choice.
- */
-function CustomBackgroundRow({
- testId,
- value,
- onChange,
-}: CustomBackgroundRowProps): JSX.Element {
- const color = value ?? INITIAL_COLOR;
- const ratio = contrastRatio(inkForSurface(color), color);
- const isLegible = ratio >= MIN_CONTRAST_RATIO;
-
- const contrastMessage = isLegible
- ? `Contrast ${ratio.toFixed(1)}:1`
- : `Contrast ${ratio.toFixed(1)}:1 — below ${MIN_CONTRAST_RATIO}:1`;
-
- function renderPanel(panel: ReactNode): ReactNode {
- return (
- <>
- {panel}
- <div
- className={cx(styles.contrast, { [styles.warning]: !isLegible })}
- data-testid={`${testId}-contrast`}
- >
- {!isLegible && <TriangleAlert size={12} />}
- <span className="translate-safe">{contrastMessage}</span>
- </div>
- </>
- );
- }
-
- return (
- <ColorPicker
- value={color}
- size="small"
- showText={false}
- trigger="click"
- panelRender={renderPanel}
- onChangeComplete={(next): void => onChange(next.toHexString())}
- >
- <button
- type="button"
- className={cx(styles.row, { [styles.active]: value !== undefined })}
- data-testid={testId}
- >
- <span
- className={cx(styles.chip, { [styles.chipEmpty]: value === undefined })}
- style={
- value ? { background: value, color: inkForSurface(value) } : undefined
- }
- >
- {value !== undefined && <Check size={14} />}
- </span>
- <Typography.Text className={styles.label}>Custom</Typography.Text>
- <span className={cx(styles.hex, 'translate-safe')}>
- {value ?? HEX_PLACEHOLDER}
- </span>
- <ChevronDown size={14} />
- </button>
- </ColorPicker>
- );
-}
-
-export default CustomBackgroundRow;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/__tests__/BackgroundSwatches.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/__tests__/BackgroundSwatches.test.tsx
deleted file mode 100644
index 024ff815ae..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/__tests__/BackgroundSwatches.test.tsx
+++ /dev/null
@@ -1,118 +0,0 @@
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
-import { TooltipProvider } from '@signozhq/ui/tooltip';
-import { TEXT_BACKGROUND_PAIRS } from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/presets';
-import {
- PanelTheme,
- TextBackgroundKind,
- TextBackgroundPreset,
-} from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/types';
-
-import BackgroundSwatches from '../BackgroundSwatches';
-
-function renderRow(
- props: Partial<React.ComponentProps<typeof BackgroundSwatches>> = {},
-): jest.Mock {
- const onChange = jest.fn();
- render(
- <TooltipProvider>
- <BackgroundSwatches
- testId="background"
- label="Panel background"
- theme={PanelTheme.Dark}
- value={TextBackgroundKind.Default}
- onChange={onChange}
- {...props}
- />
- </TooltipProvider>,
- );
- return onChange;
-}
-
-describe('BackgroundSwatches', () => {
- it('offers transparent, the default surface and the eight presets in order', () => {
- renderRow();
-
- expect(
- screen
- .getAllByRole('radio')
- .map((swatch) => swatch.getAttribute('aria-label')),
- ).toStrictEqual([
- 'Transparent',
- 'Default panel',
- 'Robin',
- 'Purple',
- 'Sakura',
- 'Cherry',
- 'Amber',
- 'Forest',
- 'Sienna',
- 'Slate',
- ]);
- });
-
- it('is one labelled group', () => {
- renderRow();
-
- expect(
- screen.getByRole('radiogroup', { name: 'Panel background' }),
- ).toBeInTheDocument();
- });
-
- it.each([
- ['background-none', 'Transparent — no card, border or title bar'],
- ['background-default', 'Default panel colour'],
- ['background-sakura', 'Sakura'],
- ])('explains %s on hover', async (swatchId, copy) => {
- renderRow();
-
- fireEvent.focus(screen.getByTestId(swatchId));
-
- await waitFor(() => {
- expect(screen.getByRole('tooltip')).toHaveTextContent(copy);
- });
- });
-
- it('paints each preset in the given theme', () => {
- renderRow({ theme: PanelTheme.Light });
-
- expect(screen.getByTestId('background-amber')).toHaveStyle({
- background: TEXT_BACKGROUND_PAIRS.amber.light.surface,
- color: TEXT_BACKGROUND_PAIRS.amber.light.ink,
- });
- });
-
- it('marks only the selected swatch, and checks it', () => {
- renderRow({ value: TextBackgroundPreset.Forest });
-
- expect(screen.getByRole('radio', { name: 'Forest' })).toBeChecked();
- expect(
- screen.getByRole('radio', { name: 'Default panel' }),
- ).not.toBeChecked();
- expect(
- screen.getByTestId('background-forest').querySelector('svg'),
- ).toBeInTheDocument();
- expect(
- screen.getByTestId('background-default').querySelector('svg'),
- ).not.toBeInTheDocument();
- });
-
- it('reports the swatch that was clicked', () => {
- const onChange = renderRow();
-
- fireEvent.click(screen.getByRole('radio', { name: 'Sienna' }));
-
- expect(onChange).toHaveBeenCalledWith('sienna');
- });
-
- // jsdom does not implement radio arrow navigation, so the shared name — what
- // makes them one group — is what there is to assert.
- it('groups every swatch under one radio name', () => {
- renderRow();
-
- const names = new Set(
- screen.getAllByRole('radio').map((swatch) => swatch.getAttribute('name')),
- );
-
- expect(names).toStrictEqual(new Set(['background']));
- });
-});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/__tests__/CustomBackgroundRow.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/__tests__/CustomBackgroundRow.test.tsx
deleted file mode 100644
index 0f6ecb2312..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/__tests__/CustomBackgroundRow.test.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-import { fireEvent, render, screen } from '@testing-library/react';
-
-import CustomBackgroundRow from '../CustomBackgroundRow';
-
-function renderRow(value?: string): jest.Mock {
- const onChange = jest.fn();
- render(
- <CustomBackgroundRow testId="custom" value={value} onChange={onChange} />,
- );
- return onChange;
-}
-
-describe('CustomBackgroundRow', () => {
- it('stands in for the hex while no custom colour is set', () => {
- renderRow();
-
- expect(screen.getByTestId('custom')).toHaveTextContent('#______');
- });
-
- it('shows the stored hex once one is set', () => {
- renderRow('#3A2A63');
-
- expect(screen.getByTestId('custom')).toHaveTextContent('#3A2A63');
- });
-
- it('checks the chip only while the custom colour is the selection', () => {
- renderRow('#3A2A63');
-
- expect(screen.getByTestId('custom').querySelector('svg')).toBeInTheDocument();
- });
-
- it('leaves the chip unchecked while no custom colour is set', () => {
- renderRow();
-
- expect(screen.getByTestId('custom').querySelectorAll('svg')).toHaveLength(1);
- });
-
- describe('the picker', () => {
- it('opens on the row', () => {
- renderRow('#3A2A63');
-
- fireEvent.click(screen.getByTestId('custom'));
-
- expect(screen.getByTestId('custom-contrast')).toBeInTheDocument();
- });
-
- it('reports the contrast the colour achieves', () => {
- renderRow('#3A2A63');
-
- fireEvent.click(screen.getByTestId('custom'));
-
- // The derived ink is pure white, not purple's paired ink.
- expect(screen.getByTestId('custom-contrast')).toHaveTextContent(
- 'Contrast 12.4:1',
- );
- });
-
- it('warns when no ink clears the floor, without disabling anything', () => {
- renderRow('#808080');
-
- fireEvent.click(screen.getByTestId('custom'));
-
- expect(screen.getByTestId('custom-contrast')).toHaveTextContent(
- 'below 4.5:1',
- );
- expect(screen.getByTestId('custom')).toBeEnabled();
- });
-
- it('says nothing about the floor when the colour clears it', () => {
- renderRow('#111111');
-
- fireEvent.click(screen.getByTestId('custom'));
-
- expect(screen.getByTestId('custom-contrast')).not.toHaveTextContent('below');
- });
- });
-});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ChangedDot/ChangedDot.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ChangedDot/ChangedDot.module.scss
new file mode 100644
index 0000000000..63153d668e
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ChangedDot/ChangedDot.module.scss
@@ -0,0 +1,7 @@
+.dot {
+ flex: none;
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: var(--bg-robin-500);
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ChangedDot/ChangedDot.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ChangedDot/ChangedDot.tsx
new file mode 100644
index 0000000000..74f36e70da
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ChangedDot/ChangedDot.tsx
@@ -0,0 +1,18 @@
+import styles from './ChangedDot.module.scss';
+
+function ChangedDot({
+ title = 'Unsaved changes',
+}: {
+ title?: string;
+}): JSX.Element {
+ return (
+ <span
+ className={styles.dot}
+ title={title}
+ aria-label={title}
+ data-testid="config-changed-dot"
+ />
+ );
+}
+
+export default ChangedDot;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/BackgroundSwatches.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/ColorSwatches.module.scss
similarity index 58%
rename from frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/BackgroundSwatches.module.scss
rename to frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/ColorSwatches.module.scss
index 00fc6d0ffc..7b1a31b62c 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/BackgroundSwatches/BackgroundSwatches.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/ColorSwatches.module.scss
@@ -1,32 +1,34 @@
.row {
display: flex;
+ flex-wrap: wrap;
align-items: center;
- gap: 6px;
+ gap: 8px;
+}
+
+.group {
+ display: contents;
}
.swatch {
+ position: relative;
+ display: block;
+ width: 24px;
+ height: 24px;
flex: none;
- width: 26px;
- height: 26px;
padding: 0;
- display: inline-flex;
- align-items: center;
- justify-content: center;
border: 1px solid var(--l2-border);
border-radius: 4px;
background: none;
cursor: pointer;
- position: relative;
- // The input carries focus, so the ring is drawn on the swatch around it.
- &:has(.input:focus-visible) {
+ &:has(.input:focus-visible),
+ &:focus-visible {
outline: 2px solid var(--bg-robin-400);
- outline-offset: 1px;
+ outline-offset: 2px;
}
}
-// The real control, sized to the swatch and invisible over it: clicks and focus
-// land on the radio, the swatch is what the user sees.
+// Clicks and focus land on the radio; the swatch is what the user sees.
.input {
position: absolute;
inset: 0;
@@ -35,12 +37,13 @@
cursor: pointer;
}
-.selected {
- box-shadow: 0 0 0 2px var(--bg-robin-500);
+.selected,
+.selected:has(.input:focus-visible) {
+ outline: 2px solid var(--l1-foreground);
+ outline-offset: 2px;
}
-// Transparency has no colour to show, so it reads as the conventional checkerboard.
-.checkerboard {
+.transparent {
background-color: var(--l2-background);
background-image:
linear-gradient(
@@ -63,14 +66,29 @@
4px 4px;
}
-.defaultSurface {
+.surface {
background: var(--l2-background);
}
+.custom {
+ background: conic-gradient(
+ from 0deg,
+ var(--bg-cherry-400),
+ var(--bg-amber-400),
+ var(--bg-forest-400),
+ var(--bg-robin-400),
+ var(--bg-sakura-400),
+ var(--bg-cherry-400)
+ );
+}
+
+.customAnchor {
+ display: inline-flex;
+}
+
.divider {
flex: none;
width: 1px;
height: 18px;
- margin: 0 2px;
background: var(--l2-border);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/ColorSwatches.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/ColorSwatches.tsx
new file mode 100644
index 0000000000..13002f204c
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/ColorSwatches.tsx
@@ -0,0 +1,80 @@
+import { Fragment, type ReactNode } from 'react';
+import { TooltipSimple } from '@signozhq/ui/tooltip';
+import cx from 'classnames';
+
+import CustomColorSwatch from './CustomColorSwatch';
+
+import styles from './ColorSwatches.module.scss';
+
+export interface ColorSwatchOption<T extends string> {
+ value: T;
+ id: string;
+ label: string;
+ tooltip?: string;
+ fill?: string;
+ pattern?: 'transparent' | 'surface';
+}
+
+interface CustomColor {
+ /** The active custom color; `undefined` while a preset is selected. */
+ value: string | undefined;
+ initial: string;
+ onChange: (hex: string) => void;
+ pickerFooter?: (hex: string) => ReactNode;
+}
+
+interface ColorSwatchesProps<T extends string> {
+ testId: string;
+ label: string;
+ value: T | undefined;
+ options: ColorSwatchOption<T>[];
+ dividerAfter?: number;
+ onChange: (value: T) => void;
+ custom: CustomColor;
+}
+
+function ColorSwatches<T extends string>({
+ testId,
+ label,
+ value,
+ options,
+ dividerAfter,
+ onChange,
+ custom,
+}: ColorSwatchesProps<T>): JSX.Element {
+ return (
+ <div className={styles.row} data-testid={testId}>
+ <div role="radiogroup" aria-label={label} className={styles.group}>
+ {options.map((option, index) => (
+ <Fragment key={option.id}>
+ <TooltipSimple title={option.tooltip ?? option.label} arrow>
+ <label
+ className={cx(styles.swatch, {
+ [styles.transparent]: option.pattern === 'transparent',
+ [styles.surface]: option.pattern === 'surface',
+ [styles.selected]: option.value === value,
+ })}
+ style={option.fill ? { background: option.fill } : undefined}
+ data-testid={`${testId}-${option.id}`}
+ >
+ <input
+ type="radio"
+ className={styles.input}
+ name={testId}
+ value={option.value}
+ checked={option.value === value}
+ aria-label={option.label}
+ onChange={(): void => onChange(option.value)}
+ />
+ </label>
+ </TooltipSimple>
+ {index === dividerAfter && <span className={styles.divider} />}
+ </Fragment>
+ ))}
+ </div>
+ <CustomColorSwatch testId={`${testId}-custom`} {...custom} />
+ </div>
+ );
+}
+
+export default ColorSwatches;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/CustomColorSwatch.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/CustomColorSwatch.tsx
new file mode 100644
index 0000000000..225fc1979c
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/CustomColorSwatch.tsx
@@ -0,0 +1,59 @@
+import type { ReactNode } from 'react';
+import { TooltipSimple } from '@signozhq/ui/tooltip';
+import { ColorPicker } from 'antd';
+import cx from 'classnames';
+
+import styles from './ColorSwatches.module.scss';
+
+interface CustomColorSwatchProps {
+ testId: string;
+ value: string | undefined;
+ initial: string;
+ onChange: (hex: string) => void;
+ pickerFooter?: (hex: string) => ReactNode;
+}
+
+function CustomColorSwatch({
+ testId,
+ value,
+ initial,
+ onChange,
+ pickerFooter,
+}: CustomColorSwatchProps): JSX.Element {
+ const color = value ?? initial;
+ const title = value ? `Custom ${value.toUpperCase()}` : 'Custom color';
+
+ return (
+ <ColorPicker
+ value={color}
+ trigger="click"
+ panelRender={
+ pickerFooter
+ ? (panel): ReactNode => (
+ <>
+ {panel}
+ {pickerFooter(color)}
+ </>
+ )
+ : undefined
+ }
+ onChangeComplete={(next): void => onChange(next.toHexString())}
+ >
+ <span className={styles.customAnchor}>
+ <TooltipSimple title={title} arrow>
+ <button
+ type="button"
+ aria-label={title}
+ aria-pressed={value !== undefined}
+ className={cx(styles.swatch, styles.custom, {
+ [styles.selected]: value !== undefined,
+ })}
+ data-testid={testId}
+ />
+ </TooltipSimple>
+ </span>
+ </ColorPicker>
+ );
+}
+
+export default CustomColorSwatch;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/__tests__/ColorSwatches.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/__tests__/ColorSwatches.test.tsx
new file mode 100644
index 0000000000..64eb92e8eb
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ColorSwatches/__tests__/ColorSwatches.test.tsx
@@ -0,0 +1,135 @@
+import { render, screen, waitFor } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { TooltipProvider } from '@signozhq/ui/tooltip';
+
+import ColorSwatches, { type ColorSwatchOption } from '../ColorSwatches';
+
+const OPTIONS: ColorSwatchOption<string>[] = [
+ { value: 'none', id: 'none', label: 'Transparent', pattern: 'transparent' },
+ {
+ value: 'default',
+ id: 'default',
+ label: 'Default panel',
+ tooltip: 'Default panel color',
+ pattern: 'surface',
+ },
+ { value: '#ff0000', id: 'red', label: 'Red', fill: '#ff0000' },
+ { value: '#00ff00', id: 'green', label: 'Green', fill: '#00ff00' },
+];
+
+function renderSwatches(
+ props: Partial<React.ComponentProps<typeof ColorSwatches<string>>> = {},
+): { onChange: jest.Mock; onCustom: jest.Mock } {
+ const onChange = jest.fn();
+ const onCustom = jest.fn();
+ render(
+ <TooltipProvider>
+ <ColorSwatches
+ testId="color"
+ label="Color"
+ value="default"
+ options={OPTIONS}
+ dividerAfter={1}
+ onChange={onChange}
+ custom={{
+ value: undefined,
+ initial: '#3A2A63',
+ onChange: onCustom,
+ pickerFooter: (hex) => <span data-testid="footer">{hex}</span>,
+ }}
+ {...props}
+ />
+ </TooltipProvider>,
+ );
+ return { onChange, onCustom };
+}
+
+describe('ColorSwatches', () => {
+ it('is one labelled radio group, in option order', () => {
+ renderSwatches();
+
+ expect(screen.getByRole('radiogroup', { name: 'Color' })).toBeInTheDocument();
+ expect(
+ screen.getAllByRole('radio').map((r) => r.getAttribute('aria-label')),
+ ).toStrictEqual(['Transparent', 'Default panel', 'Red', 'Green']);
+ });
+
+ it('paints each swatch its fill', () => {
+ renderSwatches();
+
+ expect(screen.getByTestId('color-red')).toHaveStyle({
+ background: '#ff0000',
+ });
+ });
+
+ it('checks only the selected swatch', () => {
+ renderSwatches({ value: '#00ff00' });
+
+ expect(screen.getByRole('radio', { name: 'Green' })).toBeChecked();
+ expect(screen.getByRole('radio', { name: 'Red' })).not.toBeChecked();
+ });
+
+ it('reports the swatch that was clicked', async () => {
+ const user = userEvent.setup();
+ const { onChange } = renderSwatches();
+
+ await user.click(screen.getByRole('radio', { name: 'Red' }));
+
+ expect(onChange).toHaveBeenCalledWith('#ff0000');
+ });
+
+ it.each([
+ ['color-default', 'Default panel color'],
+ ['color-red', 'Red'],
+ ])('explains %s on hover', async (swatchId, copy) => {
+ const user = userEvent.setup();
+ renderSwatches();
+
+ await user.hover(screen.getByTestId(swatchId));
+
+ await waitFor(() => {
+ expect(screen.getByRole('tooltip')).toHaveTextContent(copy);
+ });
+ });
+
+ describe('the custom swatch', () => {
+ it('is pressed only while a custom color is active', () => {
+ renderSwatches();
+ expect(screen.getByTestId('color-custom')).toHaveAttribute(
+ 'aria-pressed',
+ 'false',
+ );
+ });
+
+ it('names the active custom color', () => {
+ renderSwatches({
+ value: undefined,
+ custom: { value: '#3a2a64', initial: '#000000', onChange: jest.fn() },
+ });
+
+ expect(
+ screen.getByRole('button', { name: 'Custom #3A2A64' }),
+ ).toHaveAttribute('aria-pressed', 'true');
+ });
+
+ it('opens a picker with the footer, starting from the initial color', async () => {
+ const user = userEvent.setup();
+ renderSwatches();
+
+ await user.click(screen.getByTestId('color-custom'));
+
+ expect(screen.getByTestId('footer')).toHaveTextContent('#3A2A63');
+ });
+
+ it('reports the color picked', async () => {
+ const user = userEvent.setup();
+ const { onCustom } = renderSwatches();
+
+ await user.click(screen.getByTestId('color-custom'));
+ await user.clear(screen.getByRole('textbox'));
+ await user.type(screen.getByRole('textbox'), '3A2A64');
+
+ expect(onCustom).toHaveBeenCalledWith('#3a2a64');
+ });
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigField/ConfigField.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigField/ConfigField.module.scss
new file mode 100644
index 0000000000..eb0bc7fdad
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigField/ConfigField.module.scss
@@ -0,0 +1,60 @@
+.field {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ min-width: 0;
+}
+
+.header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ min-height: 18px;
+}
+
+.label {
+ font-family: 'Geist Mono', monospace;
+ font-size: 12px;
+ letter-spacing: 0.1em;
+ text-transform: uppercase;
+ white-space: nowrap;
+ color: var(--l2-foreground);
+}
+
+.aside {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ font-family: 'Geist Mono', monospace;
+ font-size: 12px;
+ text-align: right;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ color: var(--l2-foreground);
+}
+
+.plainLabel {
+ font-size: 13px;
+ color: var(--l1-foreground);
+}
+
+.reset {
+ padding: 0;
+ border: 0;
+ background: transparent;
+ font: inherit;
+ font-size: 12px;
+ color: var(--bg-robin-400);
+ cursor: pointer;
+
+ &:hover {
+ color: var(--bg-robin-300);
+ }
+}
+
+.help {
+ font-size: 12px;
+ line-height: 17px;
+ color: var(--l2-foreground);
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigField/ConfigField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigField/ConfigField.tsx
new file mode 100644
index 0000000000..40f914ed6d
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigField/ConfigField.tsx
@@ -0,0 +1,52 @@
+import type { ReactNode } from 'react';
+import cx from 'classnames';
+
+import styles from './ConfigField.module.scss';
+
+interface ConfigFieldProps {
+ label: ReactNode;
+ /** Shown at the end of the heading row, before Reset. */
+ aside?: ReactNode;
+ /** Shown under the control. */
+ help?: ReactNode;
+ changed?: boolean;
+ onReset?: () => void;
+ /** Plain body label instead of the uppercase field heading. */
+ plain?: boolean;
+ className?: string;
+ children: ReactNode;
+}
+
+function ConfigField({
+ label,
+ aside,
+ help,
+ changed,
+ onReset,
+ plain,
+ className,
+ children,
+}: ConfigFieldProps): JSX.Element {
+ return (
+ <div className={cx(styles.field, className)}>
+ <div className={styles.header}>
+ <span className={plain ? styles.plainLabel : styles.label}>{label}</span>
+ {aside && <span className={styles.aside}>{aside}</span>}
+ {changed && onReset && (
+ <button
+ type="button"
+ className={styles.reset}
+ data-testid="config-field-reset"
+ onClick={onReset}
+ >
+ Reset
+ </button>
+ )}
+ </div>
+ {children}
+ {help && <span className={styles.help}>{help}</span>}
+ </div>
+ );
+}
+
+export default ConfigField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigFieldRow/ConfigFieldRow.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigFieldRow/ConfigFieldRow.module.scss
new file mode 100644
index 0000000000..b0baeac5af
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigFieldRow/ConfigFieldRow.module.scss
@@ -0,0 +1,5 @@
+.row {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
+ gap: 10px;
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigFieldRow/ConfigFieldRow.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigFieldRow/ConfigFieldRow.tsx
new file mode 100644
index 0000000000..a39bae4779
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigFieldRow/ConfigFieldRow.tsx
@@ -0,0 +1,10 @@
+import type { ReactNode } from 'react';
+
+import styles from './ConfigFieldRow.module.scss';
+
+/** Side-by-side fields that wrap when the pane is narrow. */
+function ConfigFieldRow({ children }: { children: ReactNode }): JSX.Element {
+ return <div className={styles.row}>{children}</div>;
+}
+
+export default ConfigFieldRow;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigInlineField/ConfigInlineField.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigInlineField/ConfigInlineField.module.scss
new file mode 100644
index 0000000000..560dccfc23
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigInlineField/ConfigInlineField.module.scss
@@ -0,0 +1,24 @@
+.row {
+ display: grid;
+ grid-template-columns: 76px minmax(0, 1fr);
+ align-items: center;
+ gap: 12px;
+}
+
+// Matches ConfigField's heading.
+.label {
+ font-family: 'Geist Mono', monospace;
+ font-size: 12px;
+ letter-spacing: 0.1em;
+ text-transform: uppercase;
+ white-space: nowrap;
+ color: var(--l2-foreground);
+}
+
+.help {
+ grid-column: 2;
+ margin-top: -4px;
+ font-size: 12px;
+ line-height: 17px;
+ color: var(--l2-foreground);
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigInlineField/ConfigInlineField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigInlineField/ConfigInlineField.tsx
new file mode 100644
index 0000000000..ee7c7f53ad
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigInlineField/ConfigInlineField.tsx
@@ -0,0 +1,45 @@
+import type { ReactNode } from 'react';
+import { Callout } from '@signozhq/ui/callout';
+
+import styles from './ConfigInlineField.module.scss';
+
+interface ConfigInlineFieldProps {
+ label: string;
+ /** Shown under the control. */
+ help?: ReactNode;
+ helpTestId?: string;
+ /** Shown in place of the help. */
+ error?: ReactNode;
+ children: ReactNode;
+}
+
+/** A field whose heading sits beside the control rather than above it. */
+function ConfigInlineField({
+ label,
+ help,
+ helpTestId,
+ error,
+ children,
+}: ConfigInlineFieldProps): JSX.Element {
+ return (
+ <div className={styles.row}>
+ <span className={styles.label}>{label}</span>
+ {children}
+ {error ? (
+ <div className={styles.help} data-testid={helpTestId}>
+ <Callout type="error" size="small" showIcon>
+ {error}
+ </Callout>
+ </div>
+ ) : (
+ help && (
+ <span className={styles.help} data-testid={helpTestId}>
+ {help}
+ </span>
+ )
+ )}
+ </div>
+ );
+}
+
+export default ConfigInlineField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigNumberInput/ConfigNumberInput.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigNumberInput/ConfigNumberInput.tsx
new file mode 100644
index 0000000000..993865c16f
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigNumberInput/ConfigNumberInput.tsx
@@ -0,0 +1,50 @@
+import type { ChangeEvent } from 'react';
+import { Input } from 'antd';
+
+import ConfigField from '../ConfigField/ConfigField';
+
+interface ConfigNumberInputProps {
+ testId: string;
+ /** Omitted for an input whose row already names it. */
+ label?: string;
+ placeholder?: string;
+ invalid?: boolean;
+ value: number | null | undefined;
+ onChange: (next: number | null) => void;
+}
+
+/** Numeric input where empty means "auto"; transient non-numeric input (e.g. "-") clears. */
+function ConfigNumberInput({
+ testId,
+ label,
+ placeholder = 'Auto',
+ invalid,
+ value,
+ onChange,
+}: ConfigNumberInputProps): JSX.Element {
+ const handleChange = (e: ChangeEvent<HTMLInputElement>): void => {
+ const raw = e.target.value;
+ onChange(raw === '' || Number.isNaN(Number(raw)) ? null : Number(raw));
+ };
+
+ const input = (
+ <Input
+ data-testid={testId}
+ type="number"
+ placeholder={placeholder}
+ status={invalid ? 'error' : undefined}
+ value={value ?? ''}
+ onChange={handleChange}
+ />
+ );
+
+ return label ? (
+ <ConfigField label={label} plain>
+ {input}
+ </ConfigField>
+ ) : (
+ input
+ );
+}
+
+export default ConfigNumberInput;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/ConfigRangeInput.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/ConfigRangeInput.module.scss
new file mode 100644
index 0000000000..811bdedf16
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/ConfigRangeInput.module.scss
@@ -0,0 +1,10 @@
+.range {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
+ align-items: center;
+ gap: 10px;
+}
+
+.dash {
+ color: var(--l3-foreground);
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/ConfigRangeInput.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/ConfigRangeInput.tsx
new file mode 100644
index 0000000000..8f7b20c3fd
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/ConfigRangeInput.tsx
@@ -0,0 +1,47 @@
+import ConfigNumberInput from '../ConfigNumberInput/ConfigNumberInput';
+
+import { isRangeInverted } from './utils';
+
+import styles from './ConfigRangeInput.module.scss';
+
+interface ConfigRangeInputProps {
+ minTestId: string;
+ maxTestId: string;
+ min: number | null | undefined;
+ max: number | null | undefined;
+ onChangeMin: (next: number | null) => void;
+ onChangeMax: (next: number | null) => void;
+}
+
+function ConfigRangeInput({
+ minTestId,
+ maxTestId,
+ min,
+ max,
+ onChangeMin,
+ onChangeMax,
+}: ConfigRangeInputProps): JSX.Element {
+ const inverted = isRangeInverted(min, max);
+
+ return (
+ <div className={styles.range}>
+ <ConfigNumberInput
+ testId={minTestId}
+ placeholder="Min"
+ invalid={inverted}
+ value={min}
+ onChange={onChangeMin}
+ />
+ <span className={styles.dash}>–</span>
+ <ConfigNumberInput
+ testId={maxTestId}
+ placeholder="Max"
+ invalid={inverted}
+ value={max}
+ onChange={onChangeMax}
+ />
+ </div>
+ );
+}
+
+export default ConfigRangeInput;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/__tests__/utils.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/__tests__/utils.test.ts
new file mode 100644
index 0000000000..47265c6c39
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/__tests__/utils.test.ts
@@ -0,0 +1,14 @@
+import { isRangeInverted } from '../utils';
+
+describe('isRangeInverted', () => {
+ it.each([
+ [23, 12, true],
+ [12, 23, false],
+ [5, 5, false],
+ [-10, -20, true],
+ [null, 12, false],
+ [23, undefined, false],
+ ])('min %p, max %p → %p', (min, max, expected) => {
+ expect(isRangeInverted(min, max)).toBe(expected);
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/utils.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/utils.ts
new file mode 100644
index 0000000000..d92550596b
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigRangeInput/utils.ts
@@ -0,0 +1,6 @@
+export function isRangeInverted(
+ min: number | null | undefined,
+ max: number | null | undefined,
+): boolean {
+ return min != null && max != null && min > max;
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.module.scss
deleted file mode 100644
index be94ab2e70..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.module.scss
+++ /dev/null
@@ -1,10 +0,0 @@
-.group {
- width: 100%;
-}
-
-.segment {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- white-space: nowrap;
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.tsx
deleted file mode 100644
index 93df1d81ec..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSegmented/ConfigSegmented.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import { ToggleGroupSimple } from '@signozhq/ui/toggle-group';
-
-import { SegmentIcon, type SegmentIconName } from '../segmentIcons';
-
-import styles from './ConfigSegmented.module.scss';
-
-export interface ConfigSegmentedItem {
- value: string;
- label: string;
- icon?: SegmentIconName;
-}
-
-interface ConfigSegmentedProps<T extends string = string> {
- testId: string;
- value: T | undefined;
- items: ConfigSegmentedItem[];
- onChange: (value: T) => void;
-}
-
-/**
- * Inline segmented control for short option sets in the config pane (line style, fill
- * mode, axis scale, legend position). Each segment carries an optional muted glyph that
- * brightens with the selected state (it inherits the toggle's `currentColor`). Built on
- * the Periscope ToggleGroup so it stays theme-faithful.
- */
-function ConfigSegmented<T extends string = string>({
- testId,
- value,
- items,
- onChange,
-}: ConfigSegmentedProps<T>): JSX.Element {
- return (
- <ToggleGroupSimple
- type="single"
- testId={testId}
- className={styles.group}
- value={value}
- items={items.map((item) => ({
- value: item.value,
- 'aria-label': item.label,
- label: (
- <span className={styles.segment}>
- {item.icon && <SegmentIcon name={item.icon} />}
- {item.label}
- </span>
- ),
- }))}
- // Single toggle-groups emit '' when the active segment is re-clicked; ignore that
- // so a required choice (e.g. scale, position) can't be cleared to an empty value.
- onChange={(next: T): void => {
- if (next) {
- onChange(next);
- }
- }}
- />
- );
-}
-
-export default ConfigSegmented;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSlider/ConfigSlider.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSlider/ConfigSlider.tsx
index a86c54fe76..cc1f3e7671 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSlider/ConfigSlider.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSlider/ConfigSlider.tsx
@@ -11,6 +11,8 @@ interface ConfigSliderProps {
/** Renders the current value beside the track (e.g. as a percentage). */
formatValue?: (value: number) => string;
onChange: (value: number) => void;
+ /** Fires once on release, for a value too costly to write on every step. */
+ onChangeEnd?: (value: number) => void;
}
/**
@@ -25,6 +27,7 @@ function ConfigSlider({
step,
formatValue,
onChange,
+ onChangeEnd,
}: ConfigSliderProps): JSX.Element {
return (
<div className={styles.row}>
@@ -36,6 +39,10 @@ function ConfigSlider({
max={max}
step={step}
onChange={(next): void => onChange(Array.isArray(next) ? next[0] : next)}
+ onAfterChange={
+ onChangeEnd &&
+ ((next): void => onChangeEnd(Array.isArray(next) ? next[0] : next))
+ }
/>
<span className={styles.value}>
{formatValue ? formatValue(value) : value}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.module.scss
index 419b66a331..e6a5d07c72 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.module.scss
@@ -1,30 +1,31 @@
.card {
display: flex;
align-items: center;
- justify-content: space-between;
- gap: 12px;
- padding: 12px 14px;
- border: 1px solid var(--l2-border);
- border-radius: 2px;
- background: var(--l2-background-60);
+ gap: 14px;
+ padding: 14px 16px;
+ border: 1px solid var(--l1-border);
+ border-radius: 4px;
+ background: var(--l2-background);
}
.text {
display: flex;
+ flex: 1;
flex-direction: column;
- gap: 2px;
+ gap: 3px;
min-width: 0;
}
.title {
- font-size: 12px;
- font-weight: 600;
- letter-spacing: 0.06em;
- text-transform: uppercase;
- color: var(--l2-foreground);
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 14px;
+ color: var(--l1-foreground);
}
.description {
font-size: 12px;
- color: var(--l3-foreground);
+ line-height: 17px;
+ color: var(--l2-foreground);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.tsx
index bdf5f9cec0..ec58b6a7fa 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigSwitch/ConfigSwitch.tsx
@@ -1,39 +1,38 @@
+import type { ReactNode } from 'react';
import { Switch } from '@signozhq/ui/switch';
-import { Typography } from '@signozhq/ui/typography';
+
+import ChangedDot from '../ChangedDot/ChangedDot';
import styles from './ConfigSwitch.module.scss';
interface ConfigSwitchProps {
testId: string;
- /** Shown uppercased as the card title. */
title: string;
- /** Optional helper line under the title. */
description?: string;
+ sketch?: ReactNode;
+ changed?: boolean;
value: boolean;
onChange: (checked: boolean) => void;
}
-/**
- * Boolean toggle rendered as a bordered card: an uppercase title with an optional
- * description on the left and a Switch on the right. The standard presentation for
- * on/off panel-config controls (e.g. "Show points").
- */
function ConfigSwitch({
testId,
title,
description,
+ sketch,
+ changed,
value,
onChange,
}: ConfigSwitchProps): JSX.Element {
return (
<div className={styles.card}>
+ {sketch}
<div className={styles.text}>
- <span className={styles.title}>{title}</span>
- {description && (
- <Typography.Text className={styles.description}>
- {description}
- </Typography.Text>
- )}
+ <span className={styles.title}>
+ {title}
+ {changed && <ChangedDot />}
+ </span>
+ {description && <span className={styles.description}>{description}</span>}
</div>
<Switch testId={testId} value={value} onChange={onChange} />
</div>
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigTiles/ConfigTiles.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigTiles/ConfigTiles.module.scss
new file mode 100644
index 0000000000..519258143e
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigTiles/ConfigTiles.module.scss
@@ -0,0 +1,110 @@
+.container {
+ container-type: inline-size;
+}
+
+.grid {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr);
+ gap: 8px;
+}
+
+.tile {
+ position: relative;
+ display: flex;
+ align-items: center;
+ gap: 14px;
+ min-width: 0;
+ height: 52px;
+ padding: 0 14px;
+ border: 1px solid var(--l1-border);
+ border-radius: 4px;
+ background: var(--l2-background);
+ color: var(--l2-foreground);
+ font: inherit;
+ font-size: 13px;
+ cursor: pointer;
+ transition:
+ border-color 150ms,
+ background 150ms;
+
+ &:hover {
+ border-color: var(--l2-border);
+ }
+
+ &:has(:focus-visible) {
+ outline: 1px solid var(--bg-robin-500);
+ outline-offset: 1px;
+ }
+}
+
+.input {
+ position: absolute;
+ inset: 0;
+ margin: 0;
+ opacity: 0;
+ cursor: pointer;
+}
+
+.selected {
+ border-color: var(--bg-robin-500);
+ background: color-mix(in srgb, var(--bg-robin-500) 12%, var(--l1-background));
+ color: var(--l1-foreground);
+
+ &:hover {
+ border-color: var(--bg-robin-500);
+ }
+}
+
+.label {
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+}
+
+@mixin stacked-tiles($columns) {
+ grid-template-columns: repeat($columns, minmax(0, 1fr));
+
+ .tile {
+ flex-direction: column;
+ justify-content: center;
+ gap: 10px;
+ height: 88px;
+ padding: 0 4px;
+ }
+}
+
+@container (min-width: 200px) {
+ .grid[data-count='2'] {
+ @include stacked-tiles(2);
+ }
+}
+
+@container (min-width: 216px) {
+ .grid[data-count='3'] {
+ @include stacked-tiles(3);
+ }
+}
+
+@container (min-width: 220px) {
+ .grid[data-count='4'] {
+ @include stacked-tiles(2);
+ }
+}
+
+@container (min-width: 420px) {
+ .grid[data-count='4'] {
+ @include stacked-tiles(4);
+ }
+}
+
+.grid.compact {
+ grid-auto-flow: column;
+ grid-auto-columns: minmax(0, 1fr);
+ gap: 6px;
+
+ .tile {
+ justify-content: center;
+ height: 36px;
+ padding: 0 4px;
+ }
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigTiles/ConfigTiles.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigTiles/ConfigTiles.tsx
new file mode 100644
index 0000000000..8070e32fba
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/ConfigTiles/ConfigTiles.tsx
@@ -0,0 +1,74 @@
+import { type ReactNode, useId } from 'react';
+import cx from 'classnames';
+
+import styles from './ConfigTiles.module.scss';
+
+export interface ConfigTileItem<T extends string = string> {
+ value: T;
+ label: string;
+ /** Accessible name when `label` alone is ambiguous (e.g. a bare symbol). */
+ ariaLabel?: string;
+ drawing?: ReactNode;
+}
+
+interface ConfigTilesProps<T extends string> {
+ testId: string;
+ value: T | undefined;
+ items: ConfigTileItem<T>[];
+ onChange: (value: T) => void;
+ /** Compact text-only tiles on one row (e.g. decimal places). */
+ compact?: boolean;
+ 'aria-label'?: string;
+}
+
+/**
+ * Single-choice tiles. Columns follow the container width: rows of 4 fold to 2×2 and
+ * any row too narrow for its tiles becomes a full-width list.
+ */
+function ConfigTiles<T extends string>({
+ testId,
+ value,
+ items,
+ onChange,
+ compact,
+ 'aria-label': ariaLabel,
+}: ConfigTilesProps<T>): JSX.Element {
+ const name = useId();
+
+ return (
+ <div className={styles.container}>
+ <div
+ role="radiogroup"
+ aria-label={ariaLabel}
+ data-testid={testId}
+ data-count={items.length}
+ className={cx(styles.grid, { [styles.compact]: compact })}
+ >
+ {items.map((item) => {
+ const selected = item.value === value;
+ return (
+ <label
+ key={item.value}
+ data-testid={`${testId}-${item.value}`}
+ className={cx(styles.tile, { [styles.selected]: selected })}
+ >
+ <input
+ type="radio"
+ className={styles.input}
+ name={name}
+ value={item.value}
+ checked={selected}
+ aria-label={item.ariaLabel ?? item.label}
+ onChange={(): void => onChange(item.value)}
+ />
+ {item.drawing}
+ <span className={styles.label}>{item.label}</span>
+ </label>
+ );
+ })}
+ </div>
+ </div>
+ );
+}
+
+export default ConfigTiles;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColorRow.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColorRow.tsx
index 367a047ca8..8796166e81 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColorRow.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColorRow.tsx
@@ -1,6 +1,5 @@
import { ColorPicker } from 'antd';
import { Button } from '@signozhq/ui/button';
-import { Typography } from '@signozhq/ui/typography';
import styles from './LegendColors.module.scss';
@@ -41,9 +40,9 @@ function LegendColorRow({
data-testid={`legend-color-${label}`}
>
<span className={styles.swatch} style={{ backgroundColor: color }} />
- <Typography.Text className={styles.label} title={label}>
+ <span className={styles.label} title={label}>
{label}
- </Typography.Text>
+ </span>
</button>
</ColorPicker>
{isOverridden && (
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.module.scss
index ed079795d3..aca0ddf62f 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.module.scss
@@ -42,7 +42,9 @@
.label {
overflow: hidden;
- font-size: 12px;
+ font-family: var(--font-mono);
+ font-size: var(--font-size-xs);
+ letter-spacing: -0.01em;
color: var(--l2-foreground);
white-space: nowrap;
text-overflow: ellipsis;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsx
index 4970ad579d..e54337a119 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/LegendColors.tsx
@@ -40,7 +40,7 @@ function LegendColors({
if (series.length === 0) {
return (
<Typography.Text className={styles.empty}>
- Run the panel to customise series colors.
+ Run the query to set a color for each series.
</Typography.Text>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/LegendColors.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/LegendColors.test.tsx
index 4ec91988e7..1aff7c9114 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/LegendColors.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/LegendColors/__tests__/LegendColors.test.tsx
@@ -1,4 +1,5 @@
-import { fireEvent, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import type { LegendSeries } from 'pages/DashboardPage/DashboardContainer/Panels/utils/legendSeries';
import LegendColors from '../LegendColors';
@@ -15,7 +16,7 @@ describe('LegendColors', () => {
expect(
screen.queryByTestId('panel-editor-v2-legend-colors'),
).not.toBeInTheDocument();
- expect(screen.getByText(/run the panel/i)).toBeInTheDocument();
+ expect(screen.getByText(/run the query/i)).toBeInTheDocument();
});
it('renders the search box once series are present', () => {
@@ -28,14 +29,14 @@ describe('LegendColors', () => {
).toBeInTheDocument();
});
- it('shows a no-match message when the search filters everything out', () => {
+ it('shows a no-match message when the search filters everything out', async () => {
+ const user = userEvent.setup();
render(
<LegendColors series={SERIES} value={undefined} onChange={jest.fn()} />,
);
- fireEvent.change(screen.getByTestId('panel-editor-v2-legend-search'), {
- target: { value: 'zzz' },
- });
+ await user.clear(screen.getByTestId('panel-editor-v2-legend-search'));
+ await user.type(screen.getByTestId('panel-editor-v2-legend-search'), 'zzz');
expect(screen.getByText(/no series match/i)).toBeInTheDocument();
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/LegendFrame.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/LegendFrame.tsx
new file mode 100644
index 0000000000..869b51f0de
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/LegendFrame.tsx
@@ -0,0 +1,28 @@
+import type { ReactNode } from 'react';
+
+function LegendFrame({ children }: { children: ReactNode }): JSX.Element {
+ return (
+ <svg
+ width={56}
+ height={30}
+ viewBox="0 0 56 30"
+ fill="none"
+ strokeLinecap="round"
+ style={{ flex: 'none' }}
+ aria-hidden
+ >
+ <rect
+ x={1}
+ y={1}
+ width={54}
+ height={28}
+ rx={2}
+ stroke="var(--l3-border)"
+ strokeWidth={1.4}
+ />
+ {children}
+ </svg>
+ );
+}
+
+export default LegendFrame;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/SketchSvg.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/SketchSvg.tsx
new file mode 100644
index 0000000000..c2d02d9c7f
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/SketchSvg.tsx
@@ -0,0 +1,22 @@
+import type { ReactNode } from 'react';
+
+function SketchSvg({ children }: { children: ReactNode }): JSX.Element {
+ return (
+ <svg
+ width={40}
+ height={22}
+ viewBox="0 0 40 22"
+ fill="none"
+ stroke="var(--l3-foreground)"
+ strokeWidth={1.8}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ style={{ flex: 'none' }}
+ aria-hidden
+ >
+ {children}
+ </svg>
+ );
+}
+
+export default SketchSvg;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/TileSvg.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/TileSvg.tsx
new file mode 100644
index 0000000000..ab86565cd8
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/TileSvg.tsx
@@ -0,0 +1,22 @@
+import type { ReactNode } from 'react';
+
+function TileSvg({ children }: { children: ReactNode }): JSX.Element {
+ return (
+ <svg
+ width={64}
+ height={24}
+ viewBox="0 0 64 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={2.4}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ style={{ flex: 'none' }}
+ aria-hidden
+ >
+ {children}
+ </svg>
+ );
+}
+
+export default TileSvg;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/switchSketches.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/switchSketches.tsx
new file mode 100644
index 0000000000..1f2819b12c
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/switchSketches.tsx
@@ -0,0 +1,37 @@
+import SketchSvg from './SketchSvg';
+
+/** Muted sketches for on/off cards. */
+export const SWITCH_SKETCHES = {
+ hideHeader: (
+ <SketchSvg>
+ <rect x={3} y={3} width={34} height={16} rx={2} />
+ <path d="M3 8 H37" strokeDasharray="3 3" />
+ </SketchSvg>
+ ),
+ fillGaps: (
+ <SketchSvg>
+ <path d="M3 9 L11 7 L16 19 L26 19 L30 8 L37 6" />
+ </SketchSvg>
+ ),
+ points: (
+ <SketchSvg>
+ <path d="M4 17 L14 9 L24 13 L36 6" />
+ {[
+ [4, 17],
+ [14, 9],
+ [24, 13],
+ [36, 6],
+ ].map(([cx, cy]) => (
+ <circle key={cx} cx={cx} cy={cy} r={2} fill="var(--l3-foreground)" />
+ ))}
+ </SketchSvg>
+ ),
+ combine: (
+ <SketchSvg>
+ <rect x={4} y={10} width={6} height={10} />
+ <rect x={13} y={4} width={6} height={16} />
+ <rect x={22} y={8} width={6} height={12} />
+ <rect x={31} y={13} width={6} height={7} />
+ </SketchSvg>
+ ),
+} satisfies Record<string, JSX.Element>;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/tileDrawings.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/tileDrawings.tsx
new file mode 100644
index 0000000000..149d774973
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/drawings/tileDrawings.tsx
@@ -0,0 +1,240 @@
+import LegendFrame from './LegendFrame';
+import TileSvg from './TileSvg';
+
+const FILLED = { fill: 'currentColor', stroke: 'none' } as const;
+const LINE = 'M4 17 L18 9 L30 14 L44 5 L60 11';
+const POINTS = [
+ [4, 18],
+ [22, 8],
+ [40, 14],
+ [58, 6],
+];
+
+function interpDrawing(path: string): JSX.Element {
+ return (
+ <TileSvg>
+ <path d={path} />
+ {POINTS.map(([cx, cy]) => (
+ <circle key={cx} cx={cx} cy={cy} r={2.2} {...FILLED} />
+ ))}
+ </TileSvg>
+ );
+}
+
+/** Heatmap bucket rows over a y axis; `ys` sets the row spacing a scale gives. */
+function bucketRowsDrawing(ys: number[], dashed = false): JSX.Element {
+ return (
+ <TileSvg>
+ <path d="M6 2 V22 H60" strokeWidth={1.4} opacity={0.35} />
+ {ys.map((y) => (
+ <path
+ key={y}
+ d={`M10 ${y} H58`}
+ strokeWidth={2}
+ strokeDasharray={dashed ? '3 3' : undefined}
+ />
+ ))}
+ </TileSvg>
+ );
+}
+
+export const TILE_DRAWINGS = {
+ lineSolid: (
+ <TileSvg>
+ <path d={LINE} />
+ </TileSvg>
+ ),
+ lineDashed: (
+ <TileSvg>
+ <path d={LINE} strokeDasharray="5 5" />
+ </TileSvg>
+ ),
+ interpLinear: interpDrawing('M4 18 L22 8 L40 14 L58 6'),
+ interpSpline: interpDrawing(
+ 'M4 18 C 12 18, 14 8, 22 8 S 34 14, 40 14 S 52 6, 58 6',
+ ),
+ interpStepBefore: interpDrawing('M4 18 V8 H22 V14 H40 V6 H58'),
+ interpStepAfter: interpDrawing('M4 18 H22 V8 H40 V14 H58 V6'),
+ fillNone: (
+ <TileSvg>
+ <path d={LINE} />
+ </TileSvg>
+ ),
+ fillSolid: (
+ <TileSvg>
+ <path d={`${LINE} L60 22 L4 22Z`} {...FILLED} opacity={0.4} />
+ <path d={LINE} />
+ </TileSvg>
+ ),
+ fillGradient: (
+ <TileSvg>
+ <defs>
+ <linearGradient id="config-tile-fill-gradient" x1="0" y1="0" x2="0" y2="1">
+ <stop offset="0" stopColor="currentColor" stopOpacity={0.55} />
+ <stop offset="1" stopColor="currentColor" stopOpacity={0} />
+ </linearGradient>
+ </defs>
+ <path
+ d={`${LINE} L60 22 L4 22Z`}
+ fill="url(#config-tile-fill-gradient)"
+ stroke="none"
+ />
+ <path d={LINE} />
+ </TileSvg>
+ ),
+ gapsConnect: (
+ <TileSvg>
+ <path d="M4 16 L14 11 L22 14" />
+ <path d="M22 14 L42 8" strokeDasharray="3 4" />
+ <path d="M42 8 L50 11 L60 6" />
+ </TileSvg>
+ ),
+ gapsBreak: (
+ <TileSvg>
+ <path d="M4 16 L14 11 L22 14" />
+ <path d="M42 8 L50 11 L60 6" />
+ </TileSvg>
+ ),
+ scaleLinear: (
+ <TileSvg>
+ <path d="M4 20 L60 4" />
+ </TileSvg>
+ ),
+ scaleLog: (
+ <TileSvg>
+ <path d="M4 20 C 8 8, 20 5, 60 4" />
+ </TileSvg>
+ ),
+ scaleAuto: (
+ <TileSvg>
+ <path d="M4 20 L60 4" strokeDasharray="3 3" />
+ </TileSvg>
+ ),
+ scaleSqrt: (
+ <TileSvg>
+ <path d="M4 20 C 10 10, 26 6, 60 4" />
+ </TileSvg>
+ ),
+ colorPalette: (
+ <TileSvg>
+ <defs>
+ <linearGradient id="config-tile-color-palette" x1="0" x2="1">
+ <stop offset="0" style={{ stopColor: 'var(--bg-robin-700)' }} />
+ <stop offset="0.35" style={{ stopColor: 'var(--bg-sakura-400)' }} />
+ <stop offset="0.7" style={{ stopColor: 'var(--bg-amber-400)' }} />
+ <stop offset="1" style={{ stopColor: 'var(--bg-amber-100)' }} />
+ </linearGradient>
+ </defs>
+ <rect
+ x={4}
+ y={9}
+ width={56}
+ height={8}
+ rx={1}
+ fill="url(#config-tile-color-palette)"
+ stroke="none"
+ />
+ </TileSvg>
+ ),
+ colorOpacity: (
+ <TileSvg>
+ <defs>
+ <linearGradient id="config-tile-color-opacity" x1="0" x2="1">
+ <stop offset="0" stopColor="currentColor" stopOpacity={0.08} />
+ <stop offset="1" stopColor="currentColor" stopOpacity={1} />
+ </linearGradient>
+ </defs>
+ <rect
+ x={4}
+ y={9}
+ width={56}
+ height={8}
+ rx={1}
+ fill="url(#config-tile-color-opacity)"
+ stroke="none"
+ />
+ </TileSvg>
+ ),
+ bucketsAuto: bucketRowsDrawing([5, 10, 14, 18], true),
+ bucketsLinear: bucketRowsDrawing([4, 9, 14, 19]),
+ bucketsLog: bucketRowsDrawing([3, 5, 9, 17]),
+ bucketsSymlog: bucketRowsDrawing([3, 9, 11, 13, 19]),
+ scaleSymlog: (
+ <TileSvg>
+ <path d="M4 20 C 20 20, 22 12, 32 12 S 44 4, 60 4" />
+ </TileSvg>
+ ),
+ barsSideBySide: (
+ <TileSvg>
+ <rect x={10} y={10} width={7} height={12} {...FILLED} opacity={0.5} />
+ <rect x={18} y={4} width={7} height={18} {...FILLED} />
+ <rect x={36} y={12} width={7} height={10} {...FILLED} opacity={0.5} />
+ <rect x={44} y={7} width={7} height={15} {...FILLED} />
+ </TileSvg>
+ ),
+ barsStacked: (
+ <TileSvg>
+ <rect x={14} y={13} width={11} height={9} {...FILLED} opacity={0.5} />
+ <rect x={14} y={4} width={11} height={8} {...FILLED} />
+ <rect x={38} y={15} width={11} height={7} {...FILLED} opacity={0.5} />
+ <rect x={38} y={8} width={11} height={6} {...FILLED} />
+ </TileSvg>
+ ),
+ areaOverlap: (
+ <TileSvg>
+ <path d="M4 15 L18 9 L32 13 L46 6 L60 9" />
+ <path d="M4 20 L18 15 L32 18 L46 13 L60 15" opacity={0.5} />
+ </TileSvg>
+ ),
+ areaStacked: (
+ <TileSvg>
+ <path
+ d="M4 22 L4 17 L18 15 L32 16 L46 14 L60 15 L60 22Z"
+ {...FILLED}
+ opacity={0.45}
+ />
+ <path
+ d="M4 17 L18 15 L32 16 L46 14 L60 15 L60 8 L46 5 L32 9 L18 6 L4 10Z"
+ {...FILLED}
+ />
+ </TileSvg>
+ ),
+ areaPercent: (
+ <TileSvg>
+ <path
+ d="M4 22 L4 12 L18 10 L32 13 L46 9 L60 11 L60 22Z"
+ {...FILLED}
+ opacity={0.45}
+ />
+ <path d="M4 12 L18 10 L32 13 L46 9 L60 11 L60 2 L4 2Z" {...FILLED} />
+ </TileSvg>
+ ),
+ legendBottom: (
+ <LegendFrame>
+ <path
+ d="M8 15 L18 10 L28 13 L38 7 L48 9"
+ stroke="var(--bg-robin-300)"
+ strokeWidth={2}
+ />
+ <path
+ d="M8 23 H16 M22 23 H30 M36 23 H44"
+ stroke="var(--l2-foreground)"
+ strokeWidth={2.4}
+ />
+ </LegendFrame>
+ ),
+ legendRight: (
+ <LegendFrame>
+ <path
+ d="M6 20 L14 12 L22 16 L32 8"
+ stroke="var(--bg-robin-300)"
+ strokeWidth={2}
+ />
+ <path
+ d="M40 9 H48 M40 15 H48 M40 21 H48"
+ stroke="var(--l2-foreground)"
+ strokeWidth={2.4}
+ />
+ </LegendFrame>
+ ),
+} satisfies Record<string, JSX.Element>;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/segmentIcons.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/segmentIcons.tsx
deleted file mode 100644
index 625bf2415c..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/controls/segmentIcons.tsx
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * Small glyph icons for the panel-editor segmented/select controls, ported from the
- * Configure-panel design. They render at 14px and inherit `currentColor` so the
- * surrounding control can dim them when unselected and brighten them when active.
- */
-export type SegmentIconName =
- | 'solid-line'
- | 'dashed-line'
- | 'fill-none'
- | 'fill-solid'
- | 'fill-gradient'
- | 'pos-bottom'
- | 'pos-right'
- | 'scale-linear'
- | 'scale-log'
- | 'scale-sqrt'
- | 'interp-linear'
- | 'interp-spline'
- | 'interp-step-before'
- | 'interp-step-after';
-
-function Svg({ children }: { children: React.ReactNode }): JSX.Element {
- return (
- <svg
- width={14}
- height={14}
- viewBox="0 0 16 16"
- fill="none"
- stroke="currentColor"
- strokeWidth={1.5}
- strokeLinecap="round"
- strokeLinejoin="round"
- style={{ flex: 'none' }}
- aria-hidden
- >
- {children}
- </svg>
- );
-}
-
-const FILLED = { fill: 'currentColor', stroke: 'none' } as const;
-
-export function SegmentIcon({
- name,
-}: {
- name: SegmentIconName;
-}): JSX.Element | null {
- switch (name) {
- case 'solid-line':
- return (
- <Svg>
- <path d="M2 8 H14" />
- </Svg>
- );
- case 'dashed-line':
- return (
- <Svg>
- <path d="M2 8 H4.5" />
- <path d="M6.75 8 H9.25" />
- <path d="M11.5 8 H14" />
- </Svg>
- );
- case 'fill-none':
- return (
- <Svg>
- <path d="M2 11 L6 6 L10 9 L14 5" />
- </Svg>
- );
- case 'fill-solid':
- return (
- <Svg>
- <path
- d="M2 10.5 L6 5.5 L10 8.5 L14 4.5 V13.5 H2 Z"
- fill="currentColor"
- fillOpacity={0.85}
- stroke="none"
- />
- <path d="M2 10.5 L6 5.5 L10 8.5 L14 4.5" />
- </Svg>
- );
- case 'fill-gradient':
- return (
- <Svg>
- <path
- d="M2 10.5 L6 5.5 L10 8.5 L14 4.5 V13.5 H2 Z"
- fill="currentColor"
- fillOpacity={0.3}
- stroke="none"
- />
- <path d="M2 10.5 L6 5.5 L10 8.5 L14 4.5" />
- </Svg>
- );
- case 'pos-bottom':
- return (
- <Svg>
- <rect x={2} y={2.5} width={12} height={9} rx={1.2} />
- <rect x={2} y={9} width={12} height={2.5} {...FILLED} />
- </Svg>
- );
- case 'pos-right':
- return (
- <Svg>
- <rect x={2} y={2.5} width={12} height={9} rx={1.2} />
- <rect x={10.5} y={2.5} width={3.5} height={9} {...FILLED} />
- </Svg>
- );
- case 'scale-linear':
- return (
- <Svg>
- <path d="M2.5 13 L13.5 3" />
- </Svg>
- );
- case 'scale-log':
- return (
- <Svg>
- <path d="M2.5 13 C5 13, 8 4.5, 13.5 3" />
- </Svg>
- );
- case 'scale-sqrt':
- return (
- <Svg>
- <path d="M2.5 13 C5.5 11, 8.5 6.5, 13.5 3" />
- </Svg>
- );
- case 'interp-linear':
- return (
- <Svg>
- <path d="M2 12 L6 5 L10 9 L14 4" />
- </Svg>
- );
- case 'interp-spline':
- return (
- <Svg>
- <path d="M2 12 C5 3, 9 3, 14 8" />
- </Svg>
- );
- case 'interp-step-before':
- return (
- <Svg>
- <path d="M2 6 H6 V10 H10 V4.5 H14" />
- </Svg>
- );
- case 'interp-step-after':
- return (
- <Svg>
- <path d="M2 10 H6 V5 H10 V9.5 H14" />
- </Svg>
- );
- default:
- return null;
- }
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx
index af7329b395..f7b6bffb92 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sectionRegistry.tsx
@@ -15,6 +15,7 @@ import {
type SectionEditorProps,
type SectionSpecMap,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
+import type { SeededPluginSpec } from 'pages/DashboardPage/DashboardContainer/Panels/utils/buildPluginSpec';
import type { SectionEditorContext } from './sectionContext';
import AxesSection from './sections/AxesSection/AxesSection';
@@ -159,6 +160,8 @@ export interface ErasedSectionDescriptor {
Component: ComponentType<
{
value: unknown;
+ defaultValue?: unknown;
+ savedValue?: unknown;
controls?: unknown;
onChange: (next: unknown) => void;
} & SectionEditorContext
@@ -174,3 +177,16 @@ export function resolveSectionEditor(
| ErasedSectionDescriptor
| undefined;
}
+
+/** A slice's default, read through the same lens from the kind's seeded plugin spec. */
+export function getSectionDefault(
+ editor: ErasedSectionDescriptor,
+ spec: PanelSpec,
+ defaults: SeededPluginSpec,
+): unknown {
+ return editor.get({
+ ...spec,
+ links: [],
+ plugin: { ...spec.plugin, spec: defaults },
+ } as PanelSpec);
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.module.scss
index b3ee5bffd9..3405904f1c 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.module.scss
@@ -1,11 +1,5 @@
-.bounds {
+.fields {
display: flex;
- gap: 8px;
-}
-
-.field {
- display: flex;
- flex: 1;
flex-direction: column;
- gap: 8px;
+ gap: 14px;
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsx
index d0434e71ba..e9bc92497a 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxesSection.tsx
@@ -1,127 +1,81 @@
-import type { ChangeEvent } from 'react';
-import { Typography } from '@signozhq/ui/typography';
-import { Input } from 'antd';
import { DashboardtypesHeatmapYScaleDTO } from 'api/generated/services/sigNoz.schemas';
import type {
SectionEditorProps,
SectionKind,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
-import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';
-import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';
-
-import styles from './AxesSection.module.scss';
-
-type SoftBound = 'softMin' | 'softMax';
-
-const SCALE_OPTIONS = [
- { value: 'linear', label: 'Linear', icon: 'scale-linear' as const },
- { value: 'log', label: 'Log', icon: 'scale-log' as const },
-];
-
-// Auto is the only one that reads the boundaries rather than overriding them.
-const Y_SCALE_OPTIONS = [
- {
- value: DashboardtypesHeatmapYScaleDTO.auto,
- label: 'Auto',
- tooltip:
- 'Log when every bucket bound is positive, symmetric log when they cross zero',
- },
- {
- value: DashboardtypesHeatmapYScaleDTO.linear,
- label: 'Linear',
- tooltip: 'Row heights proportional to the bucket range',
- },
- {
- value: DashboardtypesHeatmapYScaleDTO.log,
- label: 'Log',
- tooltip:
- 'Log-proportional row heights; a zero bucket sits one bucket below the smallest positive bound',
- },
- {
- value: DashboardtypesHeatmapYScaleDTO.symlog,
- label: 'Symmetric log',
- tooltip:
- 'Linear within the smallest non-zero bound, logarithmic beyond, mirrored across zero',
- },
-];
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigTiles from '../../controls/ConfigTiles/ConfigTiles';
+import { createFieldResetter } from '../../utils/changes';
+import AxisFields from './AxisFields';
+import AxisRangeField from './AxisRangeField';
+import AxisScaleField from './AxisScaleField';
+import {
+ BUCKET_SCALE_HELP,
+ BUCKET_SCALE_OPTIONS,
+ LOG_SCALE_OPTIONS,
+ SCALE_HELP,
+} from './options';
/**
* Edits the `axes` slice of a panel spec: soft Y-axis min/max bounds, the
- * linear/logarithmic scale toggle, and the heatmap's bucket-axis distribution.
- * Each control is gated by its `controls` flag.
+ * linear/logarithmic scale toggle, or — for the heatmap, which has no soft bounds —
+ * the bucket-axis distribution. Each control is gated by its `controls` flag.
*/
function AxesSection({
value,
+ savedValue,
controls,
onChange,
}: SectionEditorProps<SectionKind.Axes>): JSX.Element {
- // An empty field clears the bound (null); otherwise parse to a number, ignoring
- // transient non-numeric input (e.g. a lone "-") by leaving the bound unset.
- const handleBound =
- (bound: SoftBound) =>
- (e: ChangeEvent<HTMLInputElement>): void => {
- const raw = e.target.value;
- const next = raw === '' || Number.isNaN(Number(raw)) ? null : Number(raw);
- onChange({ ...value, [bound]: next });
- };
+ const reset = createFieldResetter(value, savedValue, onChange);
+
+ if (controls.y) {
+ const scale = value?.y?.scale ?? DashboardtypesHeatmapYScaleDTO.auto;
+ return (
+ <ConfigField
+ label="Y-axis scale"
+ help={BUCKET_SCALE_HELP[scale]}
+ {...reset('y')}
+ >
+ <ConfigTiles
+ testId="panel-editor-v2-y-scale"
+ aria-label="Y-axis scale"
+ value={scale}
+ items={BUCKET_SCALE_OPTIONS}
+ onChange={(next): void =>
+ onChange({ ...value, y: { ...value?.y, scale: next } })
+ }
+ />
+ </ConfigField>
+ );
+ }
return (
- <>
- {controls.minMax && (
- <div className={styles.bounds}>
- <div className={styles.field}>
- <Typography.Text>Soft min</Typography.Text>
- <Input
- data-testid="panel-editor-v2-soft-min"
- type="number"
- placeholder="Auto"
- value={value?.softMin ?? ''}
- onChange={handleBound('softMin')}
- />
- </div>
- <div className={styles.field}>
- <Typography.Text>Soft max</Typography.Text>
- <Input
- data-testid="panel-editor-v2-soft-max"
- type="number"
- placeholder="Auto"
- value={value?.softMax ?? ''}
- onChange={handleBound('softMax')}
- />
- </div>
- </div>
- )}
+ <ConfigField label="Y axis" {...reset('softMin', 'softMax', 'isLogScale')}>
+ <AxisFields>
+ {controls.minMax && (
+ <AxisRangeField
+ testIdPrefix="panel-editor-v2"
+ value={value}
+ onChange={(bounds): void => onChange({ ...value, ...bounds })}
+ />
+ )}
- {controls.logScale && (
- <div className={styles.field}>
- <Typography.Text>Y-axis scale</Typography.Text>
- <ConfigSegmented
+ {controls.logScale && (
+ <AxisScaleField
testId="panel-editor-v2-log-scale"
+ aria-label="Y-axis scale"
value={value?.isLogScale ? 'log' : 'linear'}
- items={SCALE_OPTIONS}
+ items={LOG_SCALE_OPTIONS}
+ help={SCALE_HELP}
onChange={(next): void =>
onChange({ ...value, isLogScale: next === 'log' })
}
/>
- </div>
- )}
-
- {controls.y && (
- <div className={styles.field}>
- <Typography.Text>Y-axis scale</Typography.Text>
- <ConfigSelect
- testId="panel-editor-v2-y-scale"
- placeholder="Select scale…"
- value={value?.y?.scale}
- items={Y_SCALE_OPTIONS}
- onChange={(next): void =>
- onChange({ ...value, y: { ...value?.y, scale: next } })
- }
- />
- </div>
- )}
- </>
+ )}
+ </AxisFields>
+ </ConfigField>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisFields.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisFields.tsx
new file mode 100644
index 0000000000..9e4658c20d
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisFields.tsx
@@ -0,0 +1,10 @@
+import type { ReactNode } from 'react';
+
+import styles from './AxesSection.module.scss';
+
+/** One axis's fields, stacked under its heading. */
+function AxisFields({ children }: { children: ReactNode }): JSX.Element {
+ return <div className={styles.fields}>{children}</div>;
+}
+
+export default AxisFields;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisRangeField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisRangeField.tsx
new file mode 100644
index 0000000000..b7d10a4c97
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisRangeField.tsx
@@ -0,0 +1,53 @@
+import type { ReactNode } from 'react';
+
+import ConfigInlineField from '../../controls/ConfigInlineField/ConfigInlineField';
+import ConfigRangeInput from '../../controls/ConfigRangeInput/ConfigRangeInput';
+import { isRangeInverted } from '../../controls/ConfigRangeInput/utils';
+import { RANGE_HELP, RANGE_INVERTED_ERROR } from './options';
+
+export interface AxisBounds {
+ softMin?: number | null;
+ softMax?: number | null;
+}
+
+interface AxisRangeFieldProps {
+ /** Prefix for the `-soft-min` / `-soft-max` test ids. */
+ testIdPrefix: string;
+ value: AxisBounds | undefined;
+ onChange: (bounds: AxisBounds) => void;
+ help?: ReactNode;
+ helpTestId?: string;
+}
+
+/** Soft min/max bounds, flagged when min is above max. */
+function AxisRangeField({
+ testIdPrefix,
+ value,
+ onChange,
+ help = RANGE_HELP,
+ helpTestId,
+}: AxisRangeFieldProps): JSX.Element {
+ return (
+ <ConfigInlineField
+ label="Range"
+ help={help}
+ helpTestId={helpTestId}
+ error={
+ isRangeInverted(value?.softMin, value?.softMax)
+ ? RANGE_INVERTED_ERROR
+ : undefined
+ }
+ >
+ <ConfigRangeInput
+ minTestId={`${testIdPrefix}-soft-min`}
+ maxTestId={`${testIdPrefix}-soft-max`}
+ min={value?.softMin}
+ max={value?.softMax}
+ onChangeMin={(softMin): void => onChange({ softMin })}
+ onChangeMax={(softMax): void => onChange({ softMax })}
+ />
+ </ConfigInlineField>
+ );
+}
+
+export default AxisRangeField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisScaleField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisScaleField.tsx
new file mode 100644
index 0000000000..a38a82d2a8
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/AxisScaleField.tsx
@@ -0,0 +1,37 @@
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigTiles, {
+ type ConfigTileItem,
+} from '../../controls/ConfigTiles/ConfigTiles';
+
+interface AxisScaleFieldProps<T extends string> {
+ testId: string;
+ 'aria-label': string;
+ value: T;
+ items: ConfigTileItem<T>[];
+ /** Help for each scale, shown for the selected one. */
+ help: Record<T, string>;
+ onChange: (next: T) => void;
+}
+
+function AxisScaleField<T extends string>({
+ testId,
+ 'aria-label': ariaLabel,
+ value,
+ items,
+ help,
+ onChange,
+}: AxisScaleFieldProps<T>): JSX.Element {
+ return (
+ <ConfigField label="Scale" help={help[value]}>
+ <ConfigTiles
+ testId={testId}
+ aria-label={ariaLabel}
+ value={value}
+ items={items}
+ onChange={onChange}
+ />
+ </ConfigField>
+ );
+}
+
+export default AxisScaleField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/AxesSection.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/AxesSection.test.tsx
index 5d7aed8a71..05f1b1bcf6 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/AxesSection.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/AxesSection.test.tsx
@@ -90,25 +90,20 @@ describe('AxesSection', () => {
<AxesSection value={undefined} controls={{ y: true }} onChange={onChange} />,
);
- const trigger = screen.getByTestId('panel-editor-v2-y-scale');
- await user.click(
- trigger.querySelector('.ant-select-selector') as HTMLElement,
+ ['auto', 'linear', 'log', 'symlog'].forEach((scale) =>
+ expect(
+ screen.getByTestId(`panel-editor-v2-y-scale-${scale}`),
+ ).toBeInTheDocument(),
);
- await expect(
- screen.findByRole('option', { name: /Auto/ }),
- ).resolves.toBeInTheDocument();
- expect(screen.getByRole('option', { name: /Log/ })).toBeInTheDocument();
- expect(screen.getByRole('option', { name: /Linear/ })).toBeInTheDocument();
-
- await user.click(screen.getByRole('option', { name: /Symmetric log/ }));
+ await user.click(screen.getByTestId('panel-editor-v2-y-scale-symlog'));
expect(onChange).toHaveBeenCalledWith({
y: { scale: DashboardtypesHeatmapYScaleDTO.symlog },
});
});
- it('shows the scale the spec asks for', () => {
+ it('shows the help for the scale the spec asks for', () => {
render(
<AxesSection
value={{ y: { scale: DashboardtypesHeatmapYScaleDTO.symlog } }}
@@ -117,7 +112,7 @@ describe('AxesSection', () => {
/>,
);
- expect(screen.getByText('Symmetric log')).toBeInTheDocument();
+ expect(screen.getByText(/Log on both sides of zero/)).toBeInTheDocument();
});
it('toggles the logarithmic scale through onChange', async () => {
@@ -131,8 +126,25 @@ describe('AxesSection', () => {
/>,
);
- await user.click(screen.getByText('Log'));
+ await user.click(screen.getByTestId('panel-editor-v2-log-scale-log'));
expect(onChange).toHaveBeenCalledWith({ isLogScale: true });
});
+
+ it('flags a soft min above the soft max', () => {
+ render(
+ <AxesSection
+ value={{ softMin: 23, softMax: 12 }}
+ controls={{ minMax: true }}
+ onChange={jest.fn()}
+ />,
+ );
+
+ expect(
+ screen.getByText("Min can't be greater than Max."),
+ ).toBeInTheDocument();
+ expect(
+ screen.queryByText(/The axis always shows at least this range/),
+ ).not.toBeInTheDocument();
+ });
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/options.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/options.test.ts
new file mode 100644
index 0000000000..e36ee2e888
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/__tests__/options.test.ts
@@ -0,0 +1,15 @@
+import { pickScaleOptions } from '../options';
+
+describe('pickScaleOptions', () => {
+ it('returns the tiles for the given scales, in that order', () => {
+ expect(
+ pickScaleOptions(['symlog', 'linear'] as const).map(({ value, label }) => ({
+ value,
+ label,
+ })),
+ ).toStrictEqual([
+ { value: 'symlog', label: 'Symlog' },
+ { value: 'linear', label: 'Linear' },
+ ]);
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/options.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/options.ts
new file mode 100644
index 0000000000..1073f48042
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/AxesSection/options.ts
@@ -0,0 +1,69 @@
+import { DashboardtypesHeatmapYScaleDTO } from 'api/generated/services/sigNoz.schemas';
+
+import type { ConfigTileItem } from '../../controls/ConfigTiles/ConfigTiles';
+import { TILE_DRAWINGS } from '../../controls/drawings/tileDrawings';
+
+/** Every axis scale a panel can offer; each section picks the ones its spec stores. */
+export type AxisScale = 'auto' | 'linear' | 'log' | 'symlog';
+
+const SCALE_TILES: Record<AxisScale, Omit<ConfigTileItem, 'value'>> = {
+ auto: { label: 'Auto', drawing: TILE_DRAWINGS.scaleAuto },
+ linear: { label: 'Linear', drawing: TILE_DRAWINGS.scaleLinear },
+ log: { label: 'Logarithmic', drawing: TILE_DRAWINGS.scaleLog },
+ symlog: { label: 'Symlog', drawing: TILE_DRAWINGS.scaleSymlog },
+};
+
+/** Tiles for `scales`, in the order given; `T` keeps the caller's own scale type. */
+export function pickScaleOptions<T extends AxisScale>(
+ scales: readonly T[],
+): ConfigTileItem<T>[] {
+ return scales.map((scale) => ({ ...SCALE_TILES[scale], value: scale }));
+}
+
+export const SCALE_HELP: Record<AxisScale, string> = {
+ auto:
+ 'Logarithmic when all values are positive and span three or more orders of magnitude; otherwise linear.',
+ linear: 'Evenly spaced values.',
+ log: 'Spreads out values that span several orders of magnitude.',
+ symlog: 'Logarithmic, but also handles zero and negative values.',
+};
+
+export const LOG_SCALE_OPTIONS = pickScaleOptions(['linear', 'log'] as const);
+
+/** Heatmap bucket-axis scales; their values match `DashboardtypesHeatmapYScaleDTO`. */
+export const BUCKET_SCALE_OPTIONS: ConfigTileItem<DashboardtypesHeatmapYScaleDTO>[] =
+ [
+ {
+ value: DashboardtypesHeatmapYScaleDTO.auto,
+ label: 'Auto',
+ drawing: TILE_DRAWINGS.bucketsAuto,
+ },
+ {
+ value: DashboardtypesHeatmapYScaleDTO.linear,
+ label: 'Linear',
+ drawing: TILE_DRAWINGS.bucketsLinear,
+ },
+ {
+ value: DashboardtypesHeatmapYScaleDTO.log,
+ label: 'Log',
+ drawing: TILE_DRAWINGS.bucketsLog,
+ },
+ {
+ value: DashboardtypesHeatmapYScaleDTO.symlog,
+ label: 'Symlog',
+ drawing: TILE_DRAWINGS.bucketsSymlog,
+ },
+ ];
+
+export const BUCKET_SCALE_HELP: Record<DashboardtypesHeatmapYScaleDTO, string> =
+ {
+ auto: 'Log for wide-ranging buckets like latency, otherwise linear.',
+ linear: 'Rows evenly spaced by value.',
+ log: 'More room for small values.',
+ symlog: 'Log on both sides of zero, for buckets that cross it.',
+ };
+
+export const RANGE_HELP =
+ 'The axis always shows at least this range. Data outside it still stretches the axis.';
+
+export const RANGE_INVERTED_ERROR = "Min can't be greater than Max.";
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.module.scss
deleted file mode 100644
index 6c02dc4661..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.module.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-.field {
- display: flex;
- flex-direction: column;
- gap: 8px;
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsx
index 77c1f8d66f..810f770eaf 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/BucketsSection/BucketsSection.tsx
@@ -1,21 +1,14 @@
-import type { ChangeEvent } from 'react';
-import { Typography } from '@signozhq/ui/typography';
-import { Input } from 'antd';
-import type { DashboardtypesHistogramBucketsDTO } from 'api/generated/services/sigNoz.schemas';
import type {
SectionEditorProps,
SectionKind,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigFieldRow from '../../controls/ConfigFieldRow/ConfigFieldRow';
+import ConfigNumberInput from '../../controls/ConfigNumberInput/ConfigNumberInput';
import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';
-
-import styles from './BucketsSection.module.scss';
-
-// The two numeric bounds of the histogram-buckets spec (derived from the BE DTO).
-type NumericBound = keyof Pick<
- DashboardtypesHistogramBucketsDTO,
- 'bucketCount' | 'bucketWidth'
->;
+import { SWITCH_SKETCHES } from '../../controls/drawings/switchSketches';
+import { createFieldResetter } from '../../utils/changes';
/**
* Edits the `histogramBuckets` slice of a Histogram panel spec: bucket count / width
@@ -24,55 +17,51 @@ type NumericBound = keyof Pick<
*/
function BucketsSection({
value,
+ savedValue,
controls,
onChange,
}: SectionEditorProps<SectionKind.Buckets>): JSX.Element {
- // Empty clears the bound to null (chart auto-sizes); otherwise parse to a number,
- // ignoring transient non-numeric input by leaving it unset.
- const handleNumber =
- (bound: NumericBound) =>
- (e: ChangeEvent<HTMLInputElement>): void => {
- const raw = e.target.value;
- const next = raw === '' || Number.isNaN(Number(raw)) ? null : Number(raw);
- onChange({ ...value, [bound]: next });
- };
+ const reset = createFieldResetter(value, savedValue, onChange);
return (
<>
- {controls.count && (
- <div className={styles.field}>
- <Typography.Text>Bucket count</Typography.Text>
- <Input
- data-testid="panel-editor-v2-bucket-count"
- type="number"
- placeholder="Auto"
- value={value?.bucketCount ?? ''}
- onChange={handleNumber('bucketCount')}
- />
- </div>
- )}
-
- {controls.width && (
- <div className={styles.field}>
- <Typography.Text>Bucket width</Typography.Text>
- <Input
- data-testid="panel-editor-v2-bucket-width"
- type="number"
- placeholder="Auto"
- value={value?.bucketWidth ?? ''}
- onChange={handleNumber('bucketWidth')}
- />
- </div>
+ {(controls.count || controls.width) && (
+ <ConfigField
+ label="Buckets"
+ help="How values are grouped into bars. Leave on Auto to size buckets from the data."
+ {...reset('bucketCount', 'bucketWidth')}
+ >
+ <ConfigFieldRow>
+ {controls.count && (
+ <ConfigNumberInput
+ testId="panel-editor-v2-bucket-count"
+ label="Count"
+ value={value?.bucketCount}
+ onChange={(bucketCount): void => onChange({ ...value, bucketCount })}
+ />
+ )}
+ {controls.width && (
+ <ConfigNumberInput
+ testId="panel-editor-v2-bucket-width"
+ label="Width"
+ value={value?.bucketWidth}
+ onChange={(bucketWidth): void => onChange({ ...value, bucketWidth })}
+ />
+ )}
+ </ConfigFieldRow>
+ </ConfigField>
)}
{controls.mergeQueries && (
<ConfigSwitch
testId="panel-editor-v2-merge-queries"
- title="Merge active queries"
- description="Bucket all active queries together into one distribution"
+ title="Combine queries"
+ description="Merges all active queries into one distribution. Hides the legend."
+ sketch={SWITCH_SKETCHES.combine}
+ changed={reset('mergeAllActiveQueries').changed}
value={value?.mergeAllActiveQueries ?? false}
- onChange={(checked): void =>
- onChange({ ...value, mergeAllActiveQueries: checked })
+ onChange={(mergeAllActiveQueries): void =>
+ onChange({ ...value, mergeAllActiveQueries })
}
/>
)}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.module.scss
index fbd0f780af..f0a959e5bd 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.module.scss
@@ -1,7 +1,27 @@
-.field {
+.inset {
display: flex;
flex-direction: column;
- gap: 8px;
+ gap: 10px;
+ padding: 12px 14px;
+ border: 1px solid var(--l1-border);
+ border-radius: 4px;
+ background: var(--l2-background);
+}
+
+.insetRow {
+ flex-direction: row;
+ align-items: center;
+ gap: 12px;
+}
+
+.insetLabel {
+ font-size: 13px;
+ color: var(--l1-foreground);
+}
+
+.opacitySlider {
+ flex: 1;
+ min-width: 0;
}
.thresholdField {
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsx
index 87961f05f4..73a45ac248 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/ChartAppearanceSection.tsx
@@ -1,92 +1,32 @@
-import { Typography } from '@signozhq/ui/typography';
-import {
- DashboardtypesFillModeDTO,
- DashboardtypesLineInterpolationDTO,
- DashboardtypesLineStyleDTO,
-} from 'api/generated/services/sigNoz.schemas';
+import cx from 'classnames';
+import { resolveFillOpacity } from 'lib/uPlotV2/utils/fillOpacity';
import type {
SectionEditorProps,
SectionKind,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
-import { resolveFillOpacity } from 'lib/uPlotV2/utils/fillOpacity';
-
-import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';
-import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';
+import ConfigField from '../../controls/ConfigField/ConfigField';
import ConfigSlider from '../../controls/ConfigSlider/ConfigSlider';
import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';
-import { SegmentIcon } from '../../controls/segmentIcons';
+import ConfigTiles from '../../controls/ConfigTiles/ConfigTiles';
+import { SWITCH_SKETCHES } from '../../controls/drawings/switchSketches';
import type { SectionEditorContext } from '../../sectionContext';
+import { createFieldResetter } from '../../utils/changes';
import DisconnectValuesField from './DisconnectValuesField';
import HeatmapColorsField from './HeatmapColorsField';
+import {
+ FILL_MODE_OPTIONS,
+ FILLED_FILL_MODE_OPTIONS,
+ LINE_INTERPOLATION_HELP,
+ LINE_INTERPOLATION_OPTIONS,
+ LINE_STYLE_OPTIONS,
+} from './options';
+import { formatOpacity } from './utils';
import styles from './ChartAppearanceSection.module.scss';
-const LINE_STYLE_OPTIONS = [
- {
- value: DashboardtypesLineStyleDTO.solid,
- label: 'Solid',
- icon: 'solid-line' as const,
- },
- {
- value: DashboardtypesLineStyleDTO.dashed,
- label: 'Dashed',
- icon: 'dashed-line' as const,
- },
-];
-
-const LINE_INTERPOLATION_OPTIONS = [
- {
- value: DashboardtypesLineInterpolationDTO.linear,
- label: 'Linear',
- icon: <SegmentIcon name="interp-linear" />,
- },
- {
- value: DashboardtypesLineInterpolationDTO.spline,
- label: 'Spline',
- icon: <SegmentIcon name="interp-spline" />,
- },
- {
- value: DashboardtypesLineInterpolationDTO.step_before,
- label: 'Step before',
- icon: <SegmentIcon name="interp-step-before" />,
- },
- {
- value: DashboardtypesLineInterpolationDTO.step_after,
- label: 'Step after',
- icon: <SegmentIcon name="interp-step-after" />,
- },
-];
-
-const FILL_MODE_OPTIONS = [
- {
- value: DashboardtypesFillModeDTO.none,
- label: 'None',
- icon: 'fill-none' as const,
- },
- {
- value: DashboardtypesFillModeDTO.solid,
- label: 'Solid',
- icon: 'fill-solid' as const,
- },
- {
- value: DashboardtypesFillModeDTO.gradient,
- label: 'Gradient',
- icon: 'fill-gradient' as const,
- },
-];
-
-// An always-filled kind's wire enum (`AreaFillMode`) has no `none`.
-const FILLED_FILL_MODE_OPTIONS = FILL_MODE_OPTIONS.filter(
- (option) => option.value !== DashboardtypesFillModeDTO.none,
-);
-
const FILL_OPACITY_STEP = 0.01;
-function formatOpacity(opacity: number): string {
- return `${Math.round(opacity * 100)}%`;
-}
-
/**
* Edits the `chartAppearance` slice of a panel spec: line style / interpolation, fill
* mode, fill opacity, point markers and the connect-null-gaps threshold for the
@@ -95,84 +35,90 @@ function formatOpacity(opacity: number): string {
*/
function ChartAppearanceSection({
value,
+ savedValue,
controls,
onChange,
stepInterval,
}: SectionEditorProps<SectionKind.ChartAppearance> &
Pick<SectionEditorContext, 'stepInterval'>): JSX.Element {
+ const reset = createFieldResetter(value, savedValue, onChange);
+ const interpolation = value?.lineInterpolation;
+
return (
<>
{controls.lineStyle && (
- <div className={styles.field}>
- <Typography.Text>Line style</Typography.Text>
- <ConfigSegmented
+ <ConfigField label="Line" {...reset('lineStyle')}>
+ <ConfigTiles
testId="panel-editor-v2-line-style"
+ aria-label="Line style"
value={value?.lineStyle}
items={LINE_STYLE_OPTIONS}
- onChange={(next): void =>
- onChange({ ...value, lineStyle: next as DashboardtypesLineStyleDTO })
- }
+ onChange={(lineStyle): void => onChange({ ...value, lineStyle })}
/>
- </div>
+ </ConfigField>
)}
{controls.lineInterpolation && (
- <div className={styles.field}>
- <Typography.Text>Line interpolation</Typography.Text>
- <ConfigSelect
+ <ConfigField
+ label="How points connect"
+ help={interpolation && LINE_INTERPOLATION_HELP[interpolation]}
+ {...reset('lineInterpolation')}
+ >
+ <ConfigTiles
testId="panel-editor-v2-line-interpolation"
- placeholder="Select interpolation…"
- value={value?.lineInterpolation}
+ aria-label="How points connect"
+ value={interpolation}
items={LINE_INTERPOLATION_OPTIONS}
- onChange={(next): void =>
- onChange({
- ...value,
- lineInterpolation: next,
- })
+ onChange={(lineInterpolation): void =>
+ onChange({ ...value, lineInterpolation })
}
/>
- </div>
+ </ConfigField>
)}
{controls.fillMode && (
- <div className={styles.field}>
- <Typography.Text>Fill mode</Typography.Text>
- <ConfigSegmented
+ <ConfigField
+ label="Area under the line"
+ {...reset('fillMode', 'fillOpacity')}
+ >
+ <ConfigTiles
testId="panel-editor-v2-fill-mode"
+ aria-label="Area under the line"
value={value?.fillMode}
items={
controls.fillOpacity ? FILLED_FILL_MODE_OPTIONS : FILL_MODE_OPTIONS
}
- onChange={(next): void =>
- onChange({ ...value, fillMode: next as DashboardtypesFillModeDTO })
- }
- />
- </div>
- )}
-
- {controls.fillOpacity && (
- <div className={styles.field}>
- <Typography.Text>Fill opacity</Typography.Text>
- <ConfigSlider
- testId="panel-editor-v2-fill-opacity"
- // The chart's own default, so the thumb starts where an unset fill renders.
- value={resolveFillOpacity(value?.fillOpacity)}
- min={0}
- max={1}
- step={FILL_OPACITY_STEP}
- formatValue={formatOpacity}
- onChange={(fillOpacity): void => onChange({ ...value, fillOpacity })}
+ onChange={(fillMode): void => onChange({ ...value, fillMode })}
/>
- </div>
+ {controls.fillOpacity && (
+ <div className={cx(styles.inset, styles.insetRow)}>
+ <span className={styles.insetLabel}>Opacity</span>
+ <div className={styles.opacitySlider}>
+ <ConfigSlider
+ testId="panel-editor-v2-fill-opacity"
+ // The chart's own default, so the thumb starts where an unset fill renders.
+ value={resolveFillOpacity(value?.fillOpacity)}
+ min={0}
+ max={1}
+ step={FILL_OPACITY_STEP}
+ formatValue={formatOpacity}
+ onChange={(fillOpacity): void => onChange({ ...value, fillOpacity })}
+ />
+ </div>
+ </div>
+ )}
+ </ConfigField>
)}
{controls.showPoints && (
<ConfigSwitch
testId="panel-editor-v2-show-points"
title="Show points"
- description="Display individual data points on the chart"
+ description="Marks each sample the query returned."
+ sketch={SWITCH_SKETCHES.points}
+ changed={reset('showPoints').changed}
value={value?.showPoints ?? false}
- onChange={(checked): void => onChange({ ...value, showPoints: checked })}
+ onChange={(showPoints): void => onChange({ ...value, showPoints })}
/>
)}
@@ -181,6 +127,7 @@ function ChartAppearanceSection({
testId="panel-editor-v2-span-gaps"
value={value?.spanGaps}
stepInterval={stepInterval}
+ {...reset('spanGaps')}
onChange={(spanGaps): void => onChange({ ...value, spanGaps })}
/>
)}
@@ -188,6 +135,7 @@ function ChartAppearanceSection({
{controls.colors && (
<HeatmapColorsField
value={value?.colors}
+ savedValue={savedValue?.colors}
onChange={(colors): void => onChange({ ...value, colors })}
/>
)}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/DisconnectValuesField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/DisconnectValuesField.tsx
index 5f97067bdb..d4ed5efcf5 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/DisconnectValuesField.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/DisconnectValuesField.tsx
@@ -1,24 +1,16 @@
import { useEffect, useState } from 'react';
-import { rangeUtil } from '@grafana/data';
-import { Typography } from '@signozhq/ui/typography';
import type { DashboardtypesSpanGapsDTO } from 'api/generated/services/sigNoz.schemas';
-import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigTiles from '../../controls/ConfigTiles/ConfigTiles';
+import type { FieldResetProps } from '../../utils/changes';
import DisconnectValuesThresholdInput from './DisconnectValuesThresholdInput';
+import { DISCONNECT_MODE_OPTIONS, DisconnectValuesMode } from './options';
+import { defaultDisconnectDuration } from './utils';
import styles from './ChartAppearanceSection.module.scss';
-const DEFAULT_THRESHOLD = '1m';
-enum DisconnectValuesMode {
- NEVER = 'never',
- THRESHOLD = 'threshold',
-}
-const MODE_OPTIONS = [
- { value: DisconnectValuesMode.NEVER, label: 'Never' },
- { value: DisconnectValuesMode.THRESHOLD, label: 'Threshold' },
-];
-
-interface DisconnectValuesFieldProps {
+interface DisconnectValuesFieldProps extends FieldResetProps {
testId: string;
value: DashboardtypesSpanGapsDTO | undefined;
/** Query step interval (seconds): seeds the default threshold and floors it. */
@@ -26,13 +18,6 @@ interface DisconnectValuesFieldProps {
onChange: (next: DashboardtypesSpanGapsDTO | undefined) => void;
}
-/** Default threshold duration: the step interval (smallest meaningful), else 1m. */
-function defaultDuration(stepInterval?: number): string {
- return stepInterval && stepInterval > 0
- ? rangeUtil.secondsToHms(stepInterval)
- : DEFAULT_THRESHOLD;
-}
-
/**
* "Disconnect values": Never (span every gap — the chart default) vs Threshold
* (only bridge gaps shorter than a duration). The threshold persists as a
@@ -43,6 +28,8 @@ function DisconnectValuesField({
testId,
value,
stepInterval,
+ changed,
+ onReset,
onChange,
}: DisconnectValuesFieldProps): JSX.Element {
const duration = value?.fillLessThan || undefined;
@@ -63,7 +50,7 @@ function DisconnectValuesField({
...value,
fillOnlyBelow: true,
// Seed from the live stepInterval (async — undefined until results load), not mount.
- fillLessThan: lastDuration ?? defaultDuration(stepInterval),
+ fillLessThan: lastDuration ?? defaultDisconnectDuration(stepInterval),
});
return;
}
@@ -72,21 +59,24 @@ function DisconnectValuesField({
};
return (
- <>
- <div className={styles.field}>
- <Typography.Text>Disconnect values</Typography.Text>
- <ConfigSegmented
- testId={testId}
- value={
- isThreshold ? DisconnectValuesMode.THRESHOLD : DisconnectValuesMode.NEVER
- }
- items={MODE_OPTIONS}
- onChange={handleMode}
- />
- </div>
+ <ConfigField
+ label="When data is missing"
+ help="Breaking the line makes outages and restarts visible."
+ changed={changed}
+ onReset={onReset}
+ >
+ <ConfigTiles
+ testId={testId}
+ aria-label="When data is missing"
+ value={
+ isThreshold ? DisconnectValuesMode.THRESHOLD : DisconnectValuesMode.NEVER
+ }
+ items={DISCONNECT_MODE_OPTIONS}
+ onChange={handleMode}
+ />
{isThreshold && duration && (
- <div className={styles.field}>
- <Typography.Text>Threshold value</Typography.Text>
+ <div className={styles.inset}>
+ <span className={styles.insetLabel}>Break when a gap is longer than</span>
<DisconnectValuesThresholdInput
testId={`${testId}-value`}
value={duration}
@@ -97,7 +87,7 @@ function DisconnectValuesField({
/>
</div>
)}
- </>
+ </ConfigField>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorStepsField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorStepsField.tsx
index 313fbcae6e..3008de9346 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorStepsField.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorStepsField.tsx
@@ -1,6 +1,4 @@
import { useState } from 'react';
-import { Slider } from '@signozhq/ui/slider';
-import { Typography } from '@signozhq/ui/typography';
import {
clampColorSteps,
DEFAULT_COLOR_STEPS,
@@ -8,11 +6,11 @@ import {
MIN_COLOR_STEPS,
} from 'lib/uPlotV2/plugins/HeatmapPlugin/colorScale';
-import { singleSliderValue } from './heatmapColorOptions';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigSlider from '../../controls/ConfigSlider/ConfigSlider';
+import type { FieldResetProps } from '../../utils/changes';
-import styles from './HeatmapColorsField.module.scss';
-
-interface HeatmapColorStepsFieldProps {
+interface HeatmapColorStepsFieldProps extends Partial<FieldResetProps> {
/** Unset until the slider moves; the chart's default stands in. */
value: number | undefined;
onChange: (steps: number) => void;
@@ -25,35 +23,31 @@ interface HeatmapColorStepsFieldProps {
function HeatmapColorStepsField({
value,
onChange,
+ changed,
+ onReset,
}: HeatmapColorStepsFieldProps): JSX.Element {
const [dragging, setDragging] = useState<number | null>(null);
- const steps = dragging ?? value ?? DEFAULT_COLOR_STEPS;
-
return (
- <div className={styles.field}>
- <div className={styles.fieldHeader}>
- <Typography.Text>Color steps</Typography.Text>
- <span className={styles.mono}>{steps}</span>
- </div>
- <Slider
+ <ConfigField
+ label="Color steps"
+ help="Fewer steps make bands easier to tell apart."
+ changed={changed}
+ onReset={onReset}
+ >
+ <ConfigSlider
testId="panel-editor-v2-heatmap-color-steps"
- className={styles.slider}
- value={steps}
+ value={dragging ?? value ?? DEFAULT_COLOR_STEPS}
min={MIN_COLOR_STEPS}
max={MAX_COLOR_STEPS}
step={1}
- aria-label="Color steps"
- onChange={(next): void => setDragging(singleSliderValue(next))}
- onAfterChange={(next): void => {
+ onChange={setDragging}
+ onChangeEnd={(next): void => {
setDragging(null);
- onChange(clampColorSteps(singleSliderValue(next)));
+ onChange(clampColorSteps(next));
}}
/>
- <Typography.Text className={styles.help}>
- How many colours the ramp is split into.
- </Typography.Text>
- </div>
+ </ConfigField>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorsField.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorsField.module.scss
index c8d96ea7bb..fb75556671 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorsField.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorsField.module.scss
@@ -1,138 +1,85 @@
-.colors {
+.preview {
display: flex;
flex-direction: column;
- gap: var(--spacing-8);
+ gap: 6px;
}
-.field {
- display: flex;
- flex: 1;
- flex-direction: column;
- gap: var(--spacing-4);
- min-width: 0;
+.previewRamp {
+ height: 16px;
+ border-radius: 2px;
+ box-shadow: inset 0 0 0 1px var(--l1-border);
}
-.fieldHeader {
+.previewBounds {
display: flex;
- align-items: center;
justify-content: space-between;
- gap: var(--spacing-4);
-}
-
-// The track is inset by half a thumb at each end by default, which reads as an
-// indent against the label and help text either side of it. Radix keeps the thumb
-// in bounds on its own, so the track can run the full width of the field.
-.slider {
- --slider-track-margin-x: 0;
-}
-
-.help {
- font-size: var(--periscope-font-size-small);
- color: var(--l3-foreground);
+ gap: 8px;
+ font-family: 'Geist Mono', monospace;
+ font-size: 12px;
+ color: var(--l2-foreground);
}
-.mono {
- font-family: var(--periscope-font-family-mono);
- font-size: var(--periscope-font-size-small);
- color: var(--l3-foreground);
+// The grid can't query its own width, so a wrapper is the container.
+.cards {
+ container-type: inline-size;
}
-.bounds {
- display: flex;
- gap: var(--spacing-4);
+.cardGrid {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr);
+ gap: 8px;
}
-.fillGrid {
- display: grid;
- grid-template-columns: repeat(4, minmax(0, 1fr));
- gap: var(--spacing-4);
+@container (min-width: 200px) {
+ .cardGrid {
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ }
}
-.customFill {
+.card {
display: flex;
- align-items: center;
- justify-content: space-between;
- gap: var(--spacing-4);
- padding: var(--spacing-4) var(--spacing-6);
- border: 1px solid var(--l2-border);
- border-radius: var(--radius-1);
- background: var(--l2-background-60);
+ flex-direction: column;
+ align-items: stretch;
+ gap: 8px;
+ min-width: 0;
+ padding: 10px 10px 8px;
+ border: 1px solid var(--l1-border);
+ border-radius: 4px;
+ background: var(--l2-background);
+ font: inherit;
+ text-align: left;
cursor: pointer;
+ transition: border-color 150ms;
&:hover {
- border-color: var(--l2-foreground);
+ border-color: var(--l2-border);
}
- &.isSelected {
- border-color: var(--accent-primary);
+ &:focus-visible {
+ outline: 1px solid var(--bg-robin-500);
+ outline-offset: 1px;
}
-}
-.customFillValue {
- display: flex;
- align-items: center;
- gap: var(--spacing-4);
-}
-
-.customFillSwatch {
- width: var(--spacing-12);
- height: var(--spacing-8);
- border-radius: var(--radius-1);
- border: 1px solid var(--l2-border);
-}
-
-.preview {
- display: flex;
- flex-direction: column;
- gap: var(--spacing-3);
-}
-
-.previewHeader {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: var(--spacing-4);
-}
-
-.previewRamp {
- height: var(--spacing-8);
- border-radius: var(--radius-1);
- border: 1px solid var(--l2-border);
-}
-
-.previewBounds {
- display: flex;
- justify-content: space-between;
- gap: var(--spacing-4);
+ &.isSelected {
+ border-color: var(--bg-robin-500);
+ box-shadow: inset 0 0 0 1px var(--bg-robin-500);
+ }
}
-.paletteGrid {
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: var(--spacing-4);
+.cardRamp {
+ height: 10px;
+ border-radius: 2px;
}
-.paletteCard {
- display: flex;
- flex-direction: column;
- gap: var(--spacing-3);
- padding: var(--spacing-4);
- border: 1px solid var(--l2-border);
- border-radius: var(--radius-1);
- background: var(--l2-background-60);
- cursor: pointer;
- text-align: left;
+.cardName {
+ overflow: hidden;
+ font-family: 'Geist Mono', monospace;
+ font-size: 12px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ color: var(--l2-foreground);
- &:hover {
- border-color: var(--l2-foreground);
- }
-
- &.isSelected {
- border-color: var(--accent-primary);
+ .isSelected & {
+ color: var(--l1-foreground);
}
}
-
-.paletteRamp {
- height: var(--spacing-6);
- border-radius: var(--radius-1);
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorsField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorsField.tsx
index e7c3d5600f..6c3250021e 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorsField.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapColorsField.tsx
@@ -1,22 +1,29 @@
-import { Typography } from '@signozhq/ui/typography';
import {
DashboardtypesHeatmapColorModeDTO,
- DashboardtypesHeatmapColorScaleDTO,
type DashboardtypesHeatmapColorsDTO,
} from 'api/generated/services/sigNoz.schemas';
-import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigTiles from '../../controls/ConfigTiles/ConfigTiles';
+import { createFieldResetter } from '../../utils/changes';
import HeatmapColorStepsField from './HeatmapColorStepsField';
import HeatmapCountRangeField from './HeatmapCountRangeField';
import HeatmapFillField from './HeatmapFillField';
import HeatmapPaletteGrid from './HeatmapPaletteGrid';
import HeatmapRampPreview from './HeatmapRampPreview';
-import { COLOR_MODE_OPTIONS, COLOR_SCALE_OPTIONS } from './heatmapColorOptions';
-
-import styles from './HeatmapColorsField.module.scss';
+import {
+ COLOR_MODE_HELP,
+ COLOR_MODE_OPTIONS,
+ COLOR_SCALE_HELP,
+ COLOR_SCALE_OPTIONS,
+ DEFAULT_COLOR_MODE,
+ DEFAULT_COLOR_SCALE,
+ DEFAULT_PALETTE,
+} from './heatmapColorOptions';
interface HeatmapColorsFieldProps {
value: DashboardtypesHeatmapColorsDTO | undefined;
+ savedValue?: DashboardtypesHeatmapColorsDTO;
onChange: (next: DashboardtypesHeatmapColorsDTO) => void;
}
@@ -27,73 +34,73 @@ interface HeatmapColorsFieldProps {
*/
function HeatmapColorsField({
value,
+ savedValue,
onChange,
}: HeatmapColorsFieldProps): JSX.Element {
- const isOpacityMode =
- value?.mode === DashboardtypesHeatmapColorModeDTO.opacity;
+ const reset = createFieldResetter(value, savedValue, onChange);
+ // Unset fields select what the chart draws for them.
+ const mode = value?.mode ?? DEFAULT_COLOR_MODE;
+ const scale = value?.scale ?? DEFAULT_COLOR_SCALE;
return (
- <div className={styles.colors}>
+ <>
<HeatmapRampPreview colors={value} />
- <div className={styles.field}>
- <Typography.Text>Color mode</Typography.Text>
- <ConfigSegmented
+ <ConfigField
+ label="Color mode"
+ help={COLOR_MODE_HELP[mode]}
+ {...reset('mode')}
+ >
+ <ConfigTiles
testId="panel-editor-v2-heatmap-color-mode"
- value={value?.mode}
+ aria-label="Color mode"
+ value={mode}
items={COLOR_MODE_OPTIONS}
- onChange={(next): void =>
- onChange({
- ...value,
- mode: next as DashboardtypesHeatmapColorModeDTO,
- })
- }
+ onChange={(next): void => onChange({ ...value, mode: next })}
/>
- </div>
+ </ConfigField>
- {isOpacityMode ? (
+ {mode === DashboardtypesHeatmapColorModeDTO.opacity ? (
<HeatmapFillField
value={value?.fill}
+ {...reset('fill')}
onChange={(fill): void => onChange({ ...value, fill })}
/>
) : (
- <div className={styles.field}>
- <Typography.Text>Palette</Typography.Text>
+ <ConfigField label="Palette" {...reset('palette')}>
<HeatmapPaletteGrid
- value={value?.palette}
+ value={value?.palette ?? DEFAULT_PALETTE}
onChange={(palette): void => onChange({ ...value, palette })}
/>
- </div>
+ </ConfigField>
)}
- <div className={styles.field}>
- <Typography.Text>Color scale</Typography.Text>
- <ConfigSegmented
+ <ConfigField
+ label="Color scale"
+ help={COLOR_SCALE_HELP[scale]}
+ {...reset('scale')}
+ >
+ <ConfigTiles
testId="panel-editor-v2-heatmap-color-scale"
- value={value?.scale}
+ aria-label="Color scale"
+ value={scale}
items={COLOR_SCALE_OPTIONS}
- onChange={(next): void =>
- onChange({
- ...value,
- scale: next as DashboardtypesHeatmapColorScaleDTO,
- })
- }
+ onChange={(next): void => onChange({ ...value, scale: next })}
/>
- <Typography.Text className={styles.help}>
- How a count maps onto the ramp.
- </Typography.Text>
- </div>
+ </ConfigField>
<HeatmapColorStepsField
value={value?.steps || undefined}
+ {...reset('steps')}
onChange={(steps): void => onChange({ ...value, steps })}
/>
<HeatmapCountRangeField
value={{ minCount: value?.minCount, maxCount: value?.maxCount }}
+ {...reset('minCount', 'maxCount')}
onChange={(bounds): void => onChange({ ...value, ...bounds })}
/>
- </div>
+ </>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapCountRangeField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapCountRangeField.tsx
index 9140a881e6..57b7d00b35 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapCountRangeField.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapCountRangeField.tsx
@@ -1,14 +1,15 @@
-import type { ChangeEvent } from 'react';
-import { Typography } from '@signozhq/ui/typography';
-import { Input } from 'antd';
+import { Callout } from '@signozhq/ui/callout';
import type { DashboardtypesHeatmapColorsDTO } from 'api/generated/services/sigNoz.schemas';
-import styles from './HeatmapColorsField.module.scss';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigRangeInput from '../../controls/ConfigRangeInput/ConfigRangeInput';
+import { isRangeInverted } from '../../controls/ConfigRangeInput/utils';
+import type { FieldResetProps } from '../../utils/changes';
/** `null` on either bound derives it from the data. */
type CountBound = Pick<DashboardtypesHeatmapColorsDTO, 'minCount' | 'maxCount'>;
-interface HeatmapCountRangeFieldProps {
+interface HeatmapCountRangeFieldProps extends Partial<FieldResetProps> {
value: CountBound;
onChange: (next: CountBound) => void;
}
@@ -20,45 +21,35 @@ interface HeatmapCountRangeFieldProps {
function HeatmapCountRangeField({
value,
onChange,
+ changed,
+ onReset,
}: HeatmapCountRangeFieldProps): JSX.Element {
- // An empty field derives the bound (null), as does transient non-numeric input
- // (a lone "-"), which pinning would read as a bound the user never typed.
- const handleBound =
- (bound: keyof CountBound) =>
- (event: ChangeEvent<HTMLInputElement>): void => {
- const raw = event.target.value;
- const next = raw === '' || Number.isNaN(Number(raw)) ? null : Number(raw);
- onChange({ ...value, [bound]: next });
- };
+ const { minCount, maxCount } = value;
return (
- <div className={styles.field}>
- <div className={styles.bounds}>
- <div className={styles.field}>
- <Typography.Text>Min count</Typography.Text>
- <Input
- data-testid="panel-editor-v2-heatmap-min-count"
- type="number"
- placeholder="Auto"
- value={value.minCount ?? ''}
- onChange={handleBound('minCount')}
- />
- </div>
- <div className={styles.field}>
- <Typography.Text>Max count</Typography.Text>
- <Input
- data-testid="panel-editor-v2-heatmap-max-count"
- type="number"
- placeholder="Auto"
- value={value.maxCount ?? ''}
- onChange={handleBound('maxCount')}
- />
- </div>
- </div>
- <Typography.Text className={styles.help}>
- The counts the ramp&apos;s ends mean; empty reads them off the data.
- </Typography.Text>
- </div>
+ <ConfigField
+ label="Count range"
+ changed={changed}
+ onReset={onReset}
+ help={
+ isRangeInverted(minCount, maxCount) ? (
+ <Callout type="error" size="small" showIcon>
+ Min count can&apos;t be greater than max count.
+ </Callout>
+ ) : (
+ 'Leave empty to read the range from the data.'
+ )
+ }
+ >
+ <ConfigRangeInput
+ minTestId="panel-editor-v2-heatmap-min-count"
+ maxTestId="panel-editor-v2-heatmap-max-count"
+ min={minCount}
+ max={maxCount}
+ onChangeMin={(next): void => onChange({ ...value, minCount: next })}
+ onChangeMax={(next): void => onChange({ ...value, maxCount: next })}
+ />
+ </ConfigField>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapFillField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapFillField.tsx
index 86ab802d91..841cec2bf0 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapFillField.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapFillField.tsx
@@ -1,13 +1,11 @@
-import cx from 'classnames';
-import { ColorPicker } from 'antd';
-import { Typography } from '@signozhq/ui/typography';
import { DEFAULT_OPACITY_FILL } from 'lib/uPlotV2/plugins/HeatmapPlugin/colorScale';
-import { FILL_PRESETS, isSameColor } from './heatmapColorOptions';
+import ColorSwatches from '../../controls/ColorSwatches/ColorSwatches';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import type { FieldResetProps } from '../../utils/changes';
+import { FILL_OPTIONS, GROUP_FILL, isSameColor } from './heatmapColorOptions';
-import styles from './HeatmapColorsField.module.scss';
-
-interface HeatmapFillFieldProps {
+interface HeatmapFillFieldProps extends Partial<FieldResetProps> {
/** Empty follows the selected group's legend colour. */
value: string | undefined;
onChange: (fill: string) => void;
@@ -20,65 +18,34 @@ interface HeatmapFillFieldProps {
function HeatmapFillField({
value,
onChange,
+ changed,
+ onReset,
}: HeatmapFillFieldProps): JSX.Element {
- const isAuto = !value;
- const isCustom =
- !isAuto && !FILL_PRESETS.some((preset) => isSameColor(preset.color, value));
+ const selected = value
+ ? FILL_OPTIONS.find((option) => isSameColor(option.value, value))?.value
+ : GROUP_FILL;
return (
- <div className={styles.field}>
- <Typography.Text>Base color</Typography.Text>
-
- <div className={styles.fillGrid}>
- {FILL_PRESETS.map((preset) => (
- <button
- key={preset.label}
- type="button"
- aria-pressed={isSameColor(preset.color, value)}
- className={cx(styles.paletteCard, {
- [styles.isSelected]: isSameColor(preset.color, value),
- })}
- data-testid={`panel-editor-v2-heatmap-fill-${preset.label}`}
- onClick={(): void => onChange(preset.color)}
- >
- <span
- className={styles.paletteRamp}
- style={{ background: preset.color }}
- />
- <span className={styles.mono}>{preset.label}</span>
- </button>
- ))}
- </div>
-
- <ColorPicker
- value={value || DEFAULT_OPACITY_FILL}
- trigger="click"
- onChangeComplete={(next): void => onChange(next.toHexString())}
- >
- <button
- type="button"
- className={cx(styles.customFill, {
- [styles.isSelected]: isCustom,
- })}
- data-testid="panel-editor-v2-heatmap-fill-custom"
- >
- <Typography.Text>Custom</Typography.Text>
- <span className={styles.customFillValue}>
- <span className={styles.mono}>
- {isAuto ? 'group colour' : value.toUpperCase()}
- </span>
- <span
- className={styles.customFillSwatch}
- style={{ background: value || DEFAULT_OPACITY_FILL }}
- />
- </span>
- </button>
- </ColorPicker>
-
- <Typography.Text className={styles.help}>
- The colour whose alpha ramps; unset uses the group&apos;s.
- </Typography.Text>
- </div>
+ <ConfigField
+ label="Base color"
+ help="Group color gives each group its own color."
+ changed={changed}
+ onReset={onReset}
+ >
+ <ColorSwatches
+ testId="panel-editor-v2-heatmap-fill"
+ label="Base color"
+ value={selected}
+ options={FILL_OPTIONS}
+ dividerAfter={0}
+ onChange={onChange}
+ custom={{
+ value: selected === undefined ? value : undefined,
+ initial: value || DEFAULT_OPACITY_FILL,
+ onChange,
+ }}
+ />
+ </ConfigField>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapPaletteGrid.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapPaletteGrid.tsx
index 397a46c23b..451aabfccf 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapPaletteGrid.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapPaletteGrid.tsx
@@ -7,7 +7,7 @@ import { paletteGradient, PALETTE_OPTIONS } from './heatmapColorOptions';
import styles from './HeatmapColorsField.module.scss';
interface HeatmapPaletteGridProps {
- value: DashboardtypesHeatmapPaletteDTO | undefined;
+ value: DashboardtypesHeatmapPaletteDTO;
onChange: (palette: DashboardtypesHeatmapPaletteDTO) => void;
}
@@ -19,25 +19,27 @@ function HeatmapPaletteGrid({
const isDarkMode = useIsDarkMode();
return (
- <div className={styles.paletteGrid}>
- {PALETTE_OPTIONS.map((option) => (
- <button
- key={option.value}
- type="button"
- aria-pressed={option.value === value}
- className={cx(styles.paletteCard, {
- [styles.isSelected]: option.value === value,
- })}
- data-testid={`panel-editor-v2-heatmap-palette-${option.value}`}
- onClick={(): void => onChange(option.value)}
- >
- <span
- className={styles.paletteRamp}
- style={{ background: paletteGradient(option.value, isDarkMode) }}
- />
- <span className={styles.mono}>{option.label}</span>
- </button>
- ))}
+ <div className={styles.cards}>
+ <div className={styles.cardGrid}>
+ {PALETTE_OPTIONS.map((option) => (
+ <button
+ key={option.value}
+ type="button"
+ aria-pressed={option.value === value}
+ className={cx(styles.card, {
+ [styles.isSelected]: option.value === value,
+ })}
+ data-testid={`panel-editor-v2-heatmap-palette-${option.value}`}
+ onClick={(): void => onChange(option.value)}
+ >
+ <span
+ className={styles.cardRamp}
+ style={{ background: paletteGradient(option.value, isDarkMode) }}
+ />
+ <span className={styles.cardName}>{option.label}</span>
+ </button>
+ ))}
+ </div>
</div>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapRampPreview.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapRampPreview.tsx
index a693f1d922..a480727e03 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapRampPreview.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/HeatmapRampPreview.tsx
@@ -1,15 +1,22 @@
import { useMemo } from 'react';
-import { Typography } from '@signozhq/ui/typography';
-import type { DashboardtypesHeatmapColorsDTO } from 'api/generated/services/sigNoz.schemas';
+import {
+ DashboardtypesHeatmapColorModeDTO,
+ type DashboardtypesHeatmapColorsDTO,
+} from 'api/generated/services/sigNoz.schemas';
import { useIsDarkMode } from 'hooks/useDarkMode';
import {
createHeatmapColorResolver,
DEFAULT_HEATMAP_COLORS,
} from 'lib/uPlotV2/plugins/HeatmapPlugin/colorScale';
-import { HeatmapColorMode } from 'lib/uPlotV2/plugins/HeatmapPlugin/types';
import { resolveHeatmapColors } from 'pages/DashboardPage/DashboardContainer/Panels/utils/chartAppearance/resolvers';
-import { rampGradient } from './heatmapColorOptions';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import {
+ DEFAULT_COLOR_MODE,
+ DEFAULT_COLOR_SCALE,
+ DEFAULT_PALETTE,
+ rampGradient,
+} from './heatmapColorOptions';
import styles from './HeatmapColorsField.module.scss';
@@ -46,29 +53,30 @@ function HeatmapRampPreview({ colors }: HeatmapRampPreviewProps): JSX.Element {
);
const summary = [
- options.mode === HeatmapColorMode.Opacity ? 'opacity' : options.palette,
- options.scale,
+ (colors?.mode ?? DEFAULT_COLOR_MODE) ===
+ DashboardtypesHeatmapColorModeDTO.opacity
+ ? DashboardtypesHeatmapColorModeDTO.opacity
+ : (colors?.palette ?? DEFAULT_PALETTE),
+ colors?.scale ?? DEFAULT_COLOR_SCALE,
`${options.steps} steps`,
].join(' · ');
return (
- <div className={styles.preview} data-testid="panel-editor-v2-heatmap-preview">
- <div className={styles.previewHeader}>
- <Typography.Text>Preview</Typography.Text>
- <span className={styles.mono}>{summary}</span>
- </div>
- <div
- className={styles.previewRamp}
- style={{ background: rampGradient(ramp) }}
- />
- <div className={styles.previewBounds}>
- <span className={styles.mono}>
- {(colors?.minCount ?? 0).toLocaleString()}
- </span>
- <span className={styles.mono}>
- {colors?.maxCount == null ? 'auto' : colors.maxCount.toLocaleString()}
- </span>
- </div>
+ <div data-testid="panel-editor-v2-heatmap-preview">
+ <ConfigField label="Preview" aside={summary}>
+ <div className={styles.preview}>
+ <div
+ className={styles.previewRamp}
+ style={{ background: rampGradient(ramp) }}
+ />
+ <div className={styles.previewBounds}>
+ <span>{(colors?.minCount ?? 0).toLocaleString()}</span>
+ <span>
+ {colors?.maxCount == null ? 'auto' : colors.maxCount.toLocaleString()}
+ </span>
+ </div>
+ </div>
+ </ConfigField>
</div>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/ChartAppearanceSection.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/ChartAppearanceSection.test.tsx
index 20ec29fa9a..0ecdcf92f4 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/ChartAppearanceSection.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/ChartAppearanceSection.test.tsx
@@ -30,16 +30,6 @@ function StatefulSpanGaps({
);
}
-// Open the antd Select by clicking its selector, then pick the option by label. The
-// line-style and fill-mode controls are ConfigSegmented (buttons), so this helper is
-// only used for the line-interpolation ConfigSelect.
-async function pickOption(triggerTestId: string, label: string): Promise<void> {
- const user = userEvent.setup();
- const trigger = screen.getByTestId(triggerTestId);
- await user.click(trigger.querySelector('.ant-select-selector') as HTMLElement);
- await user.click(await screen.findByRole('option', { name: label }));
-}
-
const ALL_CONTROLS = {
lineStyle: true,
lineInterpolation: true,
@@ -139,7 +129,7 @@ describe('ChartAppearanceSection', () => {
render(
<ChartAppearanceSection
value={undefined}
- controls={{ fillOpacity: true }}
+ controls={{ fillMode: true, fillOpacity: true }}
onChange={jest.fn()}
/>,
);
@@ -156,7 +146,7 @@ describe('ChartAppearanceSection', () => {
render(
<ChartAppearanceSection
value={{ fillOpacity: 0.25 }}
- controls={{ fillOpacity: true }}
+ controls={{ fillMode: true, fillOpacity: true }}
onChange={jest.fn()}
/>,
);
@@ -195,7 +185,7 @@ describe('ChartAppearanceSection', () => {
expect(screen.getByText('Gradient')).toBeInTheDocument();
});
- it('writes the chosen line interpolation through the dropdown', async () => {
+ it('writes the chosen line interpolation through the tiles', async () => {
const onChange = jest.fn();
render(
<ChartAppearanceSection
@@ -205,7 +195,9 @@ describe('ChartAppearanceSection', () => {
/>,
);
- await pickOption('panel-editor-v2-line-interpolation', 'Spline');
+ await userEvent
+ .setup()
+ .click(screen.getByTestId('panel-editor-v2-line-interpolation-spline'));
expect(onChange).toHaveBeenCalledWith({ lineInterpolation: 'spline' });
});
@@ -235,7 +227,9 @@ describe('ChartAppearanceSection', () => {
/>,
);
- expect(screen.getByText('Never')).toBeInTheDocument();
+ expect(
+ screen.getByTestId('panel-editor-v2-span-gaps-never'),
+ ).toBeInTheDocument();
expect(
screen.queryByTestId('panel-editor-v2-span-gaps-value'),
).not.toBeInTheDocument();
@@ -252,7 +246,7 @@ describe('ChartAppearanceSection', () => {
/>,
);
- await user.click(screen.getByText('Threshold'));
+ await user.click(screen.getByTestId('panel-editor-v2-span-gaps-threshold'));
expect(onChange).toHaveBeenLastCalledWith({
spanGaps: { fillOnlyBelow: true, fillLessThan: '1m' },
@@ -314,7 +308,7 @@ describe('ChartAppearanceSection', () => {
/>,
);
- await user.click(screen.getByText('Never'));
+ await user.click(screen.getByTestId('panel-editor-v2-span-gaps-never'));
expect(onChange).toHaveBeenLastCalledWith({
spanGaps: { fillOnlyBelow: false, fillLessThan: undefined },
@@ -390,7 +384,7 @@ describe('ChartAppearanceSection', () => {
/>,
);
- await user.click(screen.getByText('Threshold'));
+ await user.click(screen.getByTestId('panel-editor-v2-span-gaps-threshold'));
expect(onChange).toHaveBeenLastCalledWith({
spanGaps: { fillOnlyBelow: true, fillLessThan: '5m' },
@@ -418,7 +412,7 @@ describe('ChartAppearanceSection', () => {
/>,
);
- await user.click(screen.getByText('Threshold'));
+ await user.click(screen.getByTestId('panel-editor-v2-span-gaps-threshold'));
// Regression: a value seeded at mount would still be the 1m fallback.
expect(onChange).toHaveBeenLastCalledWith({
@@ -472,7 +466,7 @@ describe('ChartAppearanceSection', () => {
// Focus the input first so clicking Never also fires its blur (the toggle race).
await user.click(screen.getByTestId('panel-editor-v2-span-gaps-value'));
- await user.click(screen.getByText('Never'));
+ await user.click(screen.getByTestId('panel-editor-v2-span-gaps-never'));
expect(
screen.queryByTestId('panel-editor-v2-span-gaps-value'),
@@ -483,8 +477,8 @@ describe('ChartAppearanceSection', () => {
const user = userEvent.setup();
render(<StatefulSpanGaps initial={{ spanGaps: { fillLessThan: '5m' } }} />);
- await user.click(screen.getByText('Never'));
- await user.click(screen.getByText('Threshold'));
+ await user.click(screen.getByTestId('panel-editor-v2-span-gaps-never'));
+ await user.click(screen.getByTestId('panel-editor-v2-span-gaps-threshold'));
expect(screen.getByTestId('panel-editor-v2-span-gaps-value')).toHaveValue(
'5m',
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/HeatmapColorsField.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/HeatmapColorsField.test.tsx
index de237694e0..e480254d3b 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/HeatmapColorsField.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/__tests__/HeatmapColorsField.test.tsx
@@ -124,10 +124,10 @@ describe('HeatmapColorsField', () => {
render(<HeatmapColorsField value={undefined} onChange={onChange} />);
expect(
- screen.getByText(/How a count maps onto the ramp/),
+ screen.getByText('Keeps sparse buckets visible next to busy ones.'),
).toBeInTheDocument();
- await user.click(screen.getByText('Sqrt'));
+ await user.click(screen.getByText('Square root'));
expect(onChange).toHaveBeenCalledWith({
scale: DashboardtypesHeatmapColorScaleDTO.sqrt,
@@ -238,9 +238,7 @@ describe('HeatmapColorsField', () => {
/>,
);
- expect(
- screen.getByTestId('panel-editor-v2-heatmap-fill-forest'),
- ).toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('radio', { name: 'Forest' })).toBeChecked();
});
it('shows a fill that is no preset as the custom one', () => {
@@ -254,10 +252,23 @@ describe('HeatmapColorsField', () => {
/>,
);
- expect(screen.getByText('#0060E6')).toBeInTheDocument();
expect(
- screen.getByTestId('panel-editor-v2-heatmap-fill-robin'),
- ).toHaveAttribute('aria-pressed', 'false');
+ screen.getByTestId('panel-editor-v2-heatmap-fill-custom'),
+ ).toHaveAttribute('aria-pressed', 'true');
+ expect(screen.getByRole('radio', { name: 'Robin' })).not.toBeChecked();
+ });
+
+ it('flags a min count above the max count', () => {
+ render(
+ <HeatmapColorsField
+ value={{ minCount: 500, maxCount: 10 }}
+ onChange={jest.fn()}
+ />,
+ );
+
+ expect(
+ screen.getByText("Min count can't be greater than max count."),
+ ).toBeInTheDocument();
});
it('names the group colour as the fill until one is picked', () => {
@@ -268,9 +279,9 @@ describe('HeatmapColorsField', () => {
/>,
);
- expect(screen.getByText('group colour')).toBeInTheDocument();
+ expect(screen.getByRole('radio', { name: 'Group color' })).toBeChecked();
expect(
- screen.getByTestId('panel-editor-v2-heatmap-fill-robin'),
+ screen.getByTestId('panel-editor-v2-heatmap-fill-custom'),
).toHaveAttribute('aria-pressed', 'false');
});
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/heatmapColorOptions.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/heatmapColorOptions.ts
index 701db4a9bc..1b50d49d0a 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/heatmapColorOptions.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/heatmapColorOptions.ts
@@ -4,46 +4,110 @@ import {
DashboardtypesHeatmapColorScaleDTO,
DashboardtypesHeatmapPaletteDTO,
} from 'api/generated/services/sigNoz.schemas';
-import { HEATMAP_PALETTE_MAP } from 'pages/DashboardPage/DashboardContainer/Panels/utils/chartAppearance/enumMaps';
+import {
+ HEATMAP_COLOR_MODE_MAP,
+ HEATMAP_COLOR_SCALE_MAP,
+ HEATMAP_PALETTE_MAP,
+} from 'pages/DashboardPage/DashboardContainer/Panels/utils/chartAppearance/enumMaps';
+import { DEFAULT_HEATMAP_COLORS } from 'lib/uPlotV2/plugins/HeatmapPlugin/colorScale';
import { getPaletteStops } from 'lib/uPlotV2/plugins/HeatmapPlugin/palettes';
-import type { ConfigSegmentedItem } from '../../controls/ConfigSegmented/ConfigSegmented';
+import type { ColorSwatchOption } from '../../controls/ColorSwatches/ColorSwatches';
+import type { ConfigTileItem } from '../../controls/ConfigTiles/ConfigTiles';
+import { TILE_DRAWINGS } from '../../controls/drawings/tileDrawings';
-export const COLOR_MODE_OPTIONS: ConfigSegmentedItem[] = [
- { value: DashboardtypesHeatmapColorModeDTO.palette, label: 'Palette' },
- { value: DashboardtypesHeatmapColorModeDTO.opacity, label: 'Opacity' },
-];
+function dtoFor<D extends string, V>(map: Record<D, V>, value: V): D {
+ return (Object.keys(map) as D[]).find((key) => map[key] === value) as D;
+}
+
+/** What the chart draws for an unset field, in spec terms. */
+export const DEFAULT_COLOR_MODE = dtoFor(
+ HEATMAP_COLOR_MODE_MAP,
+ DEFAULT_HEATMAP_COLORS.mode,
+);
+export const DEFAULT_COLOR_SCALE = dtoFor(
+ HEATMAP_COLOR_SCALE_MAP,
+ DEFAULT_HEATMAP_COLORS.scale,
+);
+export const DEFAULT_PALETTE = dtoFor(
+ HEATMAP_PALETTE_MAP,
+ DEFAULT_HEATMAP_COLORS.palette,
+);
+
+export const COLOR_MODE_OPTIONS: ConfigTileItem<DashboardtypesHeatmapColorModeDTO>[] =
+ [
+ {
+ value: DashboardtypesHeatmapColorModeDTO.palette,
+ label: 'Palette',
+ drawing: TILE_DRAWINGS.colorPalette,
+ },
+ {
+ value: DashboardtypesHeatmapColorModeDTO.opacity,
+ label: 'Opacity',
+ drawing: TILE_DRAWINGS.colorOpacity,
+ },
+ ];
+
+export const COLOR_MODE_HELP: Record<
+ DashboardtypesHeatmapColorModeDTO,
+ string
+> = {
+ palette: 'Each count maps to a color on a multi-color ramp.',
+ opacity: 'One color fades from clear to solid.',
+};
// Log first: bucket counts routinely span decades.
-export const COLOR_SCALE_OPTIONS: ConfigSegmentedItem[] = [
- {
- value: DashboardtypesHeatmapColorScaleDTO.log,
- label: 'Log',
- icon: 'scale-log',
- },
- {
- value: DashboardtypesHeatmapColorScaleDTO.sqrt,
- label: 'Sqrt',
- icon: 'scale-sqrt',
- },
- {
- value: DashboardtypesHeatmapColorScaleDTO.linear,
- label: 'Linear',
- icon: 'scale-linear',
- },
-];
+export const COLOR_SCALE_OPTIONS: ConfigTileItem<DashboardtypesHeatmapColorScaleDTO>[] =
+ [
+ {
+ value: DashboardtypesHeatmapColorScaleDTO.log,
+ label: 'Log',
+ drawing: TILE_DRAWINGS.scaleLog,
+ },
+ {
+ value: DashboardtypesHeatmapColorScaleDTO.sqrt,
+ label: 'Square root',
+ drawing: TILE_DRAWINGS.scaleSqrt,
+ },
+ {
+ value: DashboardtypesHeatmapColorScaleDTO.linear,
+ label: 'Linear',
+ drawing: TILE_DRAWINGS.scaleLinear,
+ },
+ ];
-export interface HeatmapFillPreset {
- label: string;
- color: string;
-}
+export const COLOR_SCALE_HELP: Record<
+ DashboardtypesHeatmapColorScaleDTO,
+ string
+> = {
+ log: 'Keeps sparse buckets visible next to busy ones.',
+ sqrt: 'A middle ground between Log and Linear.',
+ linear: 'Color changes evenly with count.',
+};
+
+/** The unset fill: each group ramps its own legend colour. */
+export const GROUP_FILL = '';
/** Opacity-mode base colours: the palette values that read on both themes. */
-export const FILL_PRESETS: HeatmapFillPreset[] = [
- { label: 'robin', color: Color.BG_ROBIN_400 },
- { label: 'aqua', color: Color.BG_AQUA_400 },
- { label: 'forest', color: Color.BG_FOREST_400 },
- { label: 'sienna', color: Color.BG_SIENNA_400 },
+export const FILL_OPTIONS: ColorSwatchOption<string>[] = [
+ {
+ value: GROUP_FILL,
+ id: 'group',
+ label: 'Group color',
+ tooltip: 'Each group’s own color',
+ fill: `conic-gradient(${Color.BG_ROBIN_400}, ${Color.BG_AQUA_400}, ${Color.BG_FOREST_400}, ${Color.BG_SIENNA_400}, ${Color.BG_ROBIN_400})`,
+ },
+ ...[
+ { id: 'robin', color: Color.BG_ROBIN_400 },
+ { id: 'aqua', color: Color.BG_AQUA_400 },
+ { id: 'forest', color: Color.BG_FOREST_400 },
+ { id: 'sienna', color: Color.BG_SIENNA_400 },
+ ].map(({ id, color }) => ({
+ value: color,
+ id,
+ label: id.charAt(0).toUpperCase() + id.slice(1),
+ fill: color,
+ })),
];
/** Hex comparison for a spec value that may differ only in case. */
@@ -95,8 +159,3 @@ export function rampGradient(ramp: string[]): string {
]);
return `linear-gradient(90deg, ${stops.join(', ')})`;
}
-
-/** The Slider emits a pair in range mode; these are all single-thumb. */
-export function singleSliderValue(value: number | number[]): number {
- return Array.isArray(value) ? value[0] : value;
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/options.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/options.ts
new file mode 100644
index 0000000000..4b091f243b
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/options.ts
@@ -0,0 +1,101 @@
+import {
+ DashboardtypesFillModeDTO,
+ DashboardtypesLineInterpolationDTO,
+ DashboardtypesLineStyleDTO,
+} from 'api/generated/services/sigNoz.schemas';
+
+import type { ConfigTileItem } from '../../controls/ConfigTiles/ConfigTiles';
+import { TILE_DRAWINGS } from '../../controls/drawings/tileDrawings';
+
+export const LINE_STYLE_OPTIONS: ConfigTileItem<DashboardtypesLineStyleDTO>[] =
+ [
+ {
+ value: DashboardtypesLineStyleDTO.solid,
+ label: 'Solid',
+ drawing: TILE_DRAWINGS.lineSolid,
+ },
+ {
+ value: DashboardtypesLineStyleDTO.dashed,
+ label: 'Dashed',
+ drawing: TILE_DRAWINGS.lineDashed,
+ },
+ ];
+
+export const LINE_INTERPOLATION_OPTIONS: ConfigTileItem<DashboardtypesLineInterpolationDTO>[] =
+ [
+ {
+ value: DashboardtypesLineInterpolationDTO.linear,
+ label: 'Straight',
+ drawing: TILE_DRAWINGS.interpLinear,
+ },
+ {
+ value: DashboardtypesLineInterpolationDTO.spline,
+ label: 'Smooth',
+ drawing: TILE_DRAWINGS.interpSpline,
+ },
+ {
+ value: DashboardtypesLineInterpolationDTO.step_before,
+ label: 'Step before',
+ drawing: TILE_DRAWINGS.interpStepBefore,
+ },
+ {
+ value: DashboardtypesLineInterpolationDTO.step_after,
+ label: 'Step after',
+ drawing: TILE_DRAWINGS.interpStepAfter,
+ },
+ ];
+
+export const LINE_INTERPOLATION_HELP: Record<
+ DashboardtypesLineInterpolationDTO,
+ string
+> = {
+ [DashboardtypesLineInterpolationDTO.linear]:
+ 'Joins each point with a straight line.',
+ [DashboardtypesLineInterpolationDTO.spline]:
+ 'Curves through each point. Can overshoot between points.',
+ [DashboardtypesLineInterpolationDTO.step_before]:
+ 'Shows each value from the previous point up to its own timestamp.',
+ [DashboardtypesLineInterpolationDTO.step_after]:
+ 'Holds each value until the next point.',
+};
+
+export const FILL_MODE_OPTIONS: ConfigTileItem<DashboardtypesFillModeDTO>[] = [
+ {
+ value: DashboardtypesFillModeDTO.none,
+ label: 'None',
+ drawing: TILE_DRAWINGS.fillNone,
+ },
+ {
+ value: DashboardtypesFillModeDTO.solid,
+ label: 'Solid',
+ drawing: TILE_DRAWINGS.fillSolid,
+ },
+ {
+ value: DashboardtypesFillModeDTO.gradient,
+ label: 'Gradient',
+ drawing: TILE_DRAWINGS.fillGradient,
+ },
+];
+
+// An always-filled kind's wire enum (`AreaFillMode`) has no `none`.
+export const FILLED_FILL_MODE_OPTIONS = FILL_MODE_OPTIONS.filter(
+ (option) => option.value !== DashboardtypesFillModeDTO.none,
+);
+
+export enum DisconnectValuesMode {
+ NEVER = 'never',
+ THRESHOLD = 'threshold',
+}
+
+export const DISCONNECT_MODE_OPTIONS: ConfigTileItem<DisconnectValuesMode>[] = [
+ {
+ value: DisconnectValuesMode.NEVER,
+ label: 'Connect the line',
+ drawing: TILE_DRAWINGS.gapsConnect,
+ },
+ {
+ value: DisconnectValuesMode.THRESHOLD,
+ label: 'Break long gaps',
+ drawing: TILE_DRAWINGS.gapsBreak,
+ },
+];
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/utils.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/utils.ts
new file mode 100644
index 0000000000..31558d065f
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ChartAppearanceSection/utils.ts
@@ -0,0 +1,14 @@
+import { rangeUtil } from '@grafana/data';
+
+const DEFAULT_DISCONNECT_DURATION = '1m';
+
+/** The step interval (smallest meaningful gap), else 1m. */
+export function defaultDisconnectDuration(stepInterval?: number): string {
+ return stepInterval && stepInterval > 0
+ ? rangeUtil.secondsToHms(stepInterval)
+ : DEFAULT_DISCONNECT_DURATION;
+}
+
+export function formatOpacity(opacity: number): string {
+ return `${Math.round(opacity * 100)}%`;
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.module.scss
index 4751f94532..ff3d042f72 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.module.scss
@@ -1,7 +1,13 @@
.list {
display: flex;
flex-direction: column;
- gap: 8px;
+ gap: 14px;
+}
+
+.help {
+ font-size: 13px;
+ line-height: 19px;
+ color: var(--l2-foreground);
}
/* --- Saved-link list item --- */
@@ -9,10 +15,15 @@
display: flex;
align-items: center;
justify-content: space-between;
- gap: 8px;
- padding: 8px 10px;
- border: 1px solid var(--l2-border);
- border-radius: 6px;
+ gap: 14px;
+ padding: 8px 10px 8px 16px;
+ border: 1px solid var(--l1-border);
+ border-radius: 4px;
+ background: var(--l2-background);
+
+ &:hover {
+ border-color: var(--l2-border);
+ }
}
.listItemText {
@@ -32,12 +43,13 @@
.listItemLabel {
font-size: 13px;
- color: var(--text-vanilla-100);
+ color: var(--l1-foreground);
}
.listItemUrl {
- font-size: 11px;
- color: var(--text-vanilla-400);
+ font-family: 'Geist Mono', monospace;
+ font-size: 12px;
+ color: var(--l2-foreground);
}
.listItemActions {
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsx
index 09cbcf3daf..458b7640b5 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ContextLinksSection/ContextLinksSection.tsx
@@ -61,6 +61,10 @@ function ContextLinksSection({
return (
<div className={styles.list}>
+ <span className={styles.help}>
+ Links appear in a menu when someone clicks a data point. Variables pass the
+ clicked series and time range along.
+ </span>
{links.map((link, index) => (
<ContextLinkListItem
// Links have no stable id on the wire; index is the row identity here.
@@ -81,7 +85,7 @@ function ContextLinksSection({
data-testid="panel-editor-v2-add-link"
onClick={openAddDialog}
>
- Add Context Link
+ Add link
</Button>
<ContextLinkDialog
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/ColumnUnits.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/ColumnUnits.tsx
index 17c7272e6d..c649eda170 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/ColumnUnits.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/ColumnUnits.tsx
@@ -31,7 +31,7 @@ function ColumnUnits({
if (columns.length === 0) {
return (
<Typography.Text className={styles.columnUnitsHint}>
- Run the panel to set per-column units.
+ Run the query to set a unit for each value column.
</Typography.Text>
);
}
@@ -50,7 +50,7 @@ function ColumnUnits({
<div className={styles.columnUnits}>
{columns.map((column) => (
<div className={styles.columnField} key={column.key}>
- <Typography.Text>{column.label}</Typography.Text>
+ <span className={styles.columnLabel}>{column.label}</span>
<YAxisUnitSelector
data-testid={`panel-editor-v2-column-unit-${column.key}`}
placeholder="Select unit"
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/DecimalsField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/DecimalsField.tsx
new file mode 100644
index 0000000000..6866571e13
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/DecimalsField.tsx
@@ -0,0 +1,53 @@
+import type { DashboardtypesPrecisionOptionDTO } from 'api/generated/services/sigNoz.schemas';
+import { resolveDecimalPrecision } from 'pages/DashboardPage/DashboardContainer/Panels/utils/chartAppearance/resolvers';
+import { formatPanelValue } from 'pages/DashboardPage/DashboardContainer/Panels/utils/formatPanelValue';
+
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigTiles from '../../controls/ConfigTiles/ConfigTiles';
+import type { FieldResetProps } from '../../utils/changes';
+import {
+ DECIMAL_OPTIONS,
+ DECIMALS_PREVIEW_VALUE,
+ DEFAULT_DECIMAL_PRECISION,
+} from './options';
+
+import styles from './FormattingSection.module.scss';
+
+interface DecimalsFieldProps extends FieldResetProps {
+ value: DashboardtypesPrecisionOptionDTO | undefined;
+ unit?: string;
+ onChange: (next: DashboardtypesPrecisionOptionDTO) => void;
+}
+
+function DecimalsField({
+ value = DEFAULT_DECIMAL_PRECISION,
+ unit,
+ changed,
+ onReset,
+ onChange,
+}: DecimalsFieldProps): JSX.Element {
+ return (
+ <ConfigField label="Decimal places" changed={changed} onReset={onReset}>
+ <ConfigTiles
+ compact
+ testId="panel-editor-v2-decimals"
+ aria-label="Decimal places"
+ value={value}
+ items={DECIMAL_OPTIONS}
+ onChange={onChange}
+ />
+ <div className={styles.preview}>
+ <span className={styles.previewLabel}>Shows as</span>
+ <span className={styles.previewValue} data-testid="decimals-preview">
+ {formatPanelValue(
+ DECIMALS_PREVIEW_VALUE,
+ unit,
+ resolveDecimalPrecision(value),
+ )}
+ </span>
+ </div>
+ </ConfigField>
+ );
+}
+
+export default DecimalsField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.module.scss
index d92965fc06..384c2cc288 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.module.scss
@@ -1,9 +1,3 @@
-.field {
- display: flex;
- flex-direction: column;
- gap: 8px;
-}
-
.unitSelector {
:global(.ant-select) {
width: 100%;
@@ -13,11 +7,31 @@
}
}
+.preview {
+ display: flex;
+ align-items: baseline;
+ gap: 8px;
+ padding: 12px 14px;
+ border-radius: 4px;
+ background: var(--l2-background);
+}
+
+.previewLabel {
+ font-size: 12px;
+ color: var(--l2-foreground);
+}
+
+.previewValue {
+ font-family: 'Geist Mono', monospace;
+ font-size: 15px;
+ color: var(--l1-foreground);
+}
+
// Stacked per-column unit pickers; each column keeps the standard field layout.
.columnUnits {
display: flex;
flex-direction: column;
- gap: 12px;
+ gap: 10px;
:global(.ant-select) {
width: 100%;
@@ -31,10 +45,15 @@
.columnField {
display: flex;
- flex-direction: row;
- align-items: center;
- gap: 16px;
+ flex-direction: column;
+ gap: 6px;
+}
+
+.columnLabel {
+ font-size: 13px;
+ color: var(--l1-foreground);
}
+
.columnUnitSelector {
flex: 1;
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsx
index 2645e1b2df..874bb61e58 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/FormattingSection.tsx
@@ -1,5 +1,3 @@
-import { Typography } from '@signozhq/ui/typography';
-import { DashboardtypesPrecisionOptionDTO } from 'api/generated/services/sigNoz.schemas';
import YAxisUnitSelector from 'components/YAxisUnitSelector';
import { YAxisSource } from 'components/YAxisUnitSelector/types';
import type {
@@ -7,28 +5,17 @@ import type {
SectionKind,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
-import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';
+import ConfigField from '../../controls/ConfigField/ConfigField';
import type { SectionEditorContext } from '../../sectionContext';
+import { createFieldResetter } from '../../utils/changes';
import ColumnUnits from './ColumnUnits';
+import DecimalsField from './DecimalsField';
import styles from './FormattingSection.module.scss';
type FormattingSectionProps = SectionEditorProps<SectionKind.Formatting> &
Pick<SectionEditorContext, 'tableColumns' | 'metricUnit'>;
-// `full` means "show the raw value, no rounding"; the digits round to that many places.
-const DECIMAL_OPTIONS: {
- value: DashboardtypesPrecisionOptionDTO;
- label: string;
-}[] = [
- { value: DashboardtypesPrecisionOptionDTO.NUMBER_0, label: '0 decimals' },
- { value: DashboardtypesPrecisionOptionDTO.NUMBER_1, label: '1 decimal' },
- { value: DashboardtypesPrecisionOptionDTO.NUMBER_2, label: '2 decimals' },
- { value: DashboardtypesPrecisionOptionDTO.NUMBER_3, label: '3 decimals' },
- { value: DashboardtypesPrecisionOptionDTO.NUMBER_4, label: '4 decimals' },
- { value: DashboardtypesPrecisionOptionDTO.full, label: 'Full' },
-];
-
/**
* Edits the `formatting` slice of a panel spec (unit + decimal precision). Which
* controls show is driven by the per-kind `controls` flags; the spec slice itself
@@ -36,16 +23,22 @@ const DECIMAL_OPTIONS: {
*/
function FormattingSection({
value,
+ savedValue,
controls,
onChange,
tableColumns = [],
metricUnit,
}: FormattingSectionProps): JSX.Element {
+ const reset = createFieldResetter(value, savedValue, onChange);
+
return (
<>
{controls.unit && (
- <div className={styles.field}>
- <Typography.Text>Unit</Typography.Text>
+ <ConfigField
+ label="Unit"
+ help="Formats values, axis ticks and tooltips. With milliseconds, 1500 shows as 1.5 s."
+ {...reset('unit')}
+ >
<YAxisUnitSelector
containerClassName={styles.unitSelector}
data-testid="panel-editor-v2-unit"
@@ -54,37 +47,29 @@ function FormattingSection({
initialValue={metricUnit}
onChange={(unit): void => onChange({ ...value, unit })}
/>
- </div>
+ </ConfigField>
)}
{controls.decimals && (
- <div className={styles.field}>
- <Typography.Text>Decimals</Typography.Text>
- <ConfigSelect
- testId="panel-editor-v2-decimals"
- placeholder="Select decimals…"
- value={value?.decimalPrecision}
- items={DECIMAL_OPTIONS}
- onChange={(next): void =>
- onChange({
- ...value,
- decimalPrecision: next,
- })
- }
- />
- </div>
+ <DecimalsField
+ value={value?.decimalPrecision}
+ unit={value?.unit}
+ {...reset('decimalPrecision')}
+ onChange={(decimalPrecision): void =>
+ onChange({ ...value, decimalPrecision })
+ }
+ />
)}
{controls.columnUnits && (
- <div className={styles.field}>
- <Typography.Text>Column units</Typography.Text>
+ <ConfigField label="Column units" {...reset('columnUnits')}>
<ColumnUnits
columns={tableColumns}
value={value?.columnUnits ?? {}}
metricUnit={metricUnit}
onChange={(columnUnits): void => onChange({ ...value, columnUnits })}
/>
- </div>
+ </ConfigField>
)}
</>
);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/__tests__/FormattingSection.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/__tests__/FormattingSection.test.tsx
index c7d5d72e25..96c5eee9e8 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/__tests__/FormattingSection.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/__tests__/FormattingSection.test.tsx
@@ -1,17 +1,15 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
+import { DashboardtypesPrecisionOptionDTO } from 'api/generated/services/sigNoz.schemas';
import FormattingSection from '../FormattingSection';
// Auto-seeding is covered by useSeedMetricUnit's tests; here `metricUnit` is just a prop.
-// Open the Decimals select (clicking its antd selector) and pick the option with the
-// given visible label.
-async function pickDecimal(label: string): Promise<void> {
- const user = userEvent.setup();
- const trigger = screen.getByTestId('panel-editor-v2-decimals');
- await user.click(trigger.querySelector('.ant-select-selector') as HTMLElement);
- await user.click(await screen.findByRole('option', { name: label }));
+async function pickDecimal(value: string): Promise<void> {
+ await userEvent
+ .setup()
+ .click(screen.getByTestId(`panel-editor-v2-decimals-${value}`));
}
describe('FormattingSection', () => {
@@ -51,7 +49,7 @@ describe('FormattingSection', () => {
/>,
);
- await pickDecimal('Full');
+ await pickDecimal('full');
expect(onChange).toHaveBeenCalledWith({ decimalPrecision: 'full' });
});
@@ -66,14 +64,61 @@ describe('FormattingSection', () => {
/>,
);
- await pickDecimal('2 decimals');
+ await pickDecimal('3');
expect(onChange).toHaveBeenCalledWith({
unit: 'bytes',
- decimalPrecision: '2',
+ decimalPrecision: '3',
});
});
+ it('previews a sample value at the chosen precision', () => {
+ render(
+ <FormattingSection
+ value={{ decimalPrecision: DashboardtypesPrecisionOptionDTO.NUMBER_1 }}
+ controls={{ decimals: true }}
+ onChange={jest.fn()}
+ />,
+ );
+
+ expect(screen.getByTestId('decimals-preview')).toHaveTextContent('1,234.5');
+ });
+
+ it('reverts a changed precision to its saved value', async () => {
+ const onChange = jest.fn();
+ render(
+ <FormattingSection
+ value={{
+ unit: 'bytes',
+ decimalPrecision: DashboardtypesPrecisionOptionDTO.NUMBER_4,
+ }}
+ savedValue={{ unit: 'bytes' }}
+ controls={{ decimals: true }}
+ onChange={onChange}
+ />,
+ );
+
+ await userEvent.setup().click(screen.getByTestId('config-field-reset'));
+
+ expect(onChange).toHaveBeenCalledWith({
+ unit: 'bytes',
+ decimalPrecision: undefined,
+ });
+ });
+
+ it('offers no reset for a unit that matches the saved one', () => {
+ render(
+ <FormattingSection
+ value={{ unit: 'ms' }}
+ savedValue={{ unit: 'ms' }}
+ controls={{ unit: true }}
+ onChange={jest.fn()}
+ />,
+ );
+
+ expect(screen.queryByTestId('config-field-reset')).not.toBeInTheDocument();
+ });
+
it('warns when the selected unit mismatches the metric unit', () => {
// metric sent in seconds, but bytes is selected.
render(
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/options.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/options.ts
new file mode 100644
index 0000000000..9c8da25f00
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/FormattingSection/options.ts
@@ -0,0 +1,19 @@
+import { DashboardtypesPrecisionOptionDTO } from 'api/generated/services/sigNoz.schemas';
+
+import type { ConfigTileItem } from '../../controls/ConfigTiles/ConfigTiles';
+
+/** What an unset precision renders with. */
+export const DEFAULT_DECIMAL_PRECISION =
+ DashboardtypesPrecisionOptionDTO.NUMBER_2;
+
+export const DECIMALS_PREVIEW_VALUE = 1234.56789;
+
+export const DECIMAL_OPTIONS: ConfigTileItem<DashboardtypesPrecisionOptionDTO>[] =
+ [
+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_0, label: '0' },
+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_1, label: '1' },
+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_2, label: '2' },
+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_3, label: '3' },
+ { value: DashboardtypesPrecisionOptionDTO.NUMBER_4, label: '4' },
+ { value: DashboardtypesPrecisionOptionDTO.full, label: 'Full' },
+ ];
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.module.scss
deleted file mode 100644
index 6c02dc4661..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.module.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-.field {
- display: flex;
- flex-direction: column;
- gap: 8px;
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsx
index e43a322e2d..12765a9f79 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/LegendSection.tsx
@@ -1,32 +1,18 @@
-import { Typography } from '@signozhq/ui/typography';
-import { DashboardtypesLegendPositionDTO } from 'api/generated/services/sigNoz.schemas';
import type {
SectionEditorProps,
SectionKind,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
-import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import ConfigTiles from '../../controls/ConfigTiles/ConfigTiles';
import LegendColors from '../../controls/LegendColors/LegendColors';
import type { SectionEditorContext } from '../../sectionContext';
-
-import styles from './LegendSection.module.scss';
+import { createFieldResetter } from '../../utils/changes';
+import { POSITION_OPTIONS } from './options';
type LegendSectionProps = SectionEditorProps<SectionKind.Legend> &
Pick<SectionEditorContext, 'legendSeries'>;
-const POSITION_OPTIONS = [
- {
- value: DashboardtypesLegendPositionDTO.bottom,
- label: 'Bottom',
- icon: 'pos-bottom' as const,
- },
- {
- value: DashboardtypesLegendPositionDTO.right,
- label: 'Right',
- icon: 'pos-right' as const,
- },
-];
-
/**
* Edits the `legend` slice of a panel spec: legend position and per-series color
* overrides. The colors control reads the panel's resolved series from context (the
@@ -34,38 +20,36 @@ const POSITION_OPTIONS = [
*/
function LegendSection({
value,
+ defaultValue,
+ savedValue,
controls,
onChange,
legendSeries,
}: LegendSectionProps): JSX.Element {
+ const reset = createFieldResetter(value, savedValue, onChange);
+
return (
<>
{controls.position && (
- <div className={styles.field}>
- <Typography.Text>Position</Typography.Text>
- <ConfigSegmented
+ <ConfigField label="Position" {...reset('position')}>
+ <ConfigTiles
testId="panel-editor-v2-legend-position"
+ aria-label="Legend position"
items={POSITION_OPTIONS}
- value={value?.position}
- onChange={(next): void =>
- onChange({
- ...value,
- position: next as DashboardtypesLegendPositionDTO,
- })
- }
+ value={value?.position ?? defaultValue?.position}
+ onChange={(position): void => onChange({ ...value, position })}
/>
- </div>
+ </ConfigField>
)}
{controls.colors && (
- <div className={styles.field}>
- <Typography.Text>Series colors</Typography.Text>
+ <ConfigField label="Series colors" {...reset('customColors')}>
<LegendColors
series={legendSeries ?? []}
value={value?.customColors}
onChange={(customColors): void => onChange({ ...value, customColors })}
/>
- </div>
+ </ConfigField>
)}
</>
);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/__tests__/LegendSection.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/__tests__/LegendSection.test.tsx
index 4e61951ca5..ae84a463cf 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/__tests__/LegendSection.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/__tests__/LegendSection.test.tsx
@@ -1,4 +1,5 @@
-import { fireEvent, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import { DashboardtypesLegendPositionDTO } from 'api/generated/services/sigNoz.schemas';
import LegendSection from '../LegendSection';
@@ -16,8 +17,8 @@ describe('LegendSection', () => {
expect(
screen.getByTestId('panel-editor-v2-legend-position'),
).toBeInTheDocument();
- expect(screen.getByText('Bottom')).toBeInTheDocument();
- expect(screen.getByText('Right')).toBeInTheDocument();
+ expect(screen.getByText('Below chart')).toBeInTheDocument();
+ expect(screen.getByText('Right of chart')).toBeInTheDocument();
});
it('renders nothing when position is not enabled', () => {
@@ -30,7 +31,8 @@ describe('LegendSection', () => {
).not.toBeInTheDocument();
});
- it('writes the chosen position through onChange', () => {
+ it('writes the chosen position through onChange', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(
<LegendSection
@@ -40,12 +42,13 @@ describe('LegendSection', () => {
/>,
);
- fireEvent.click(screen.getByText('Right'));
+ await user.click(screen.getByTestId('panel-editor-v2-legend-position-right'));
expect(onChange).toHaveBeenCalledWith({ position: 'right' });
});
- it('preserves other legend fields when changing position', () => {
+ it('preserves other legend fields when changing position', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(
<LegendSection
@@ -58,7 +61,7 @@ describe('LegendSection', () => {
/>,
);
- fireEvent.click(screen.getByText('Right'));
+ await user.click(screen.getByTestId('panel-editor-v2-legend-position-right'));
expect(onChange).toHaveBeenCalledWith({
position: 'right',
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/options.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/options.ts
new file mode 100644
index 0000000000..45300411a0
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/LegendSection/options.ts
@@ -0,0 +1,18 @@
+import { DashboardtypesLegendPositionDTO } from 'api/generated/services/sigNoz.schemas';
+
+import type { ConfigTileItem } from '../../controls/ConfigTiles/ConfigTiles';
+import { TILE_DRAWINGS } from '../../controls/drawings/tileDrawings';
+
+export const POSITION_OPTIONS: ConfigTileItem<DashboardtypesLegendPositionDTO>[] =
+ [
+ {
+ value: DashboardtypesLegendPositionDTO.bottom,
+ label: 'Below chart',
+ drawing: TILE_DRAWINGS.legendBottom,
+ },
+ {
+ value: DashboardtypesLegendPositionDTO.right,
+ label: 'Right of chart',
+ drawing: TILE_DRAWINGS.legendRight,
+ },
+ ];
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/PanelHeaderSection/PanelHeaderSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/PanelHeaderSection/PanelHeaderSection.tsx
index cadcdd5f4d..d10646cade 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/PanelHeaderSection/PanelHeaderSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/PanelHeaderSection/PanelHeaderSection.tsx
@@ -4,19 +4,24 @@ import type {
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';
+import { SWITCH_SKETCHES } from '../../controls/drawings/switchSketches';
/** Edits the Text panel's `headerOptions` slice: the panel card's title strip. */
function PanelHeaderSection({
value,
onChange,
}: SectionEditorProps<SectionKind.PanelHeader>): JSX.Element {
+ const hide = value?.hide === true;
+
return (
<ConfigSwitch
testId="panel-header-hide"
- title="Hide header"
- description="Drop the title strip on the dashboard; hovering the panel shows controls for drag and actions."
- value={value?.hide === true}
- onChange={(hide): void => onChange({ ...value, hide })}
+ title="Hide panel header"
+ description="Removes the title strip on the dashboard. The drag handle and actions appear on hover."
+ sketch={SWITCH_SKETCHES.hideHeader}
+ changed={hide}
+ value={hide}
+ onChange={(next): void => onChange({ ...value, hide: next })}
/>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/BackgroundContrastNote.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/BackgroundContrastNote.module.scss
new file mode 100644
index 0000000000..085a3ca67c
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/BackgroundContrastNote.module.scss
@@ -0,0 +1,12 @@
+.contrast {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 8px 4px 2px;
+ font-size: 12px;
+ color: var(--l2-foreground);
+}
+
+.warning {
+ color: var(--callout-warning-description);
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/BackgroundContrastNote.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/BackgroundContrastNote.tsx
new file mode 100644
index 0000000000..519da0ae48
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/BackgroundContrastNote.tsx
@@ -0,0 +1,39 @@
+import { TriangleAlert } from '@signozhq/icons';
+import cx from 'classnames';
+import {
+ contrastRatio,
+ inkForSurface,
+ MIN_CONTRAST_RATIO,
+} from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/contrast';
+
+import styles from './BackgroundContrastNote.module.scss';
+
+interface BackgroundContrastNoteProps {
+ testId: string;
+ color: string;
+}
+
+/** Warns below the contrast floor but never blocks the choice. */
+function BackgroundContrastNote({
+ testId,
+ color,
+}: BackgroundContrastNoteProps): JSX.Element {
+ const ratio = contrastRatio(inkForSurface(color), color);
+ const isLegible = ratio >= MIN_CONTRAST_RATIO;
+
+ return (
+ <div
+ className={cx(styles.contrast, { [styles.warning]: !isLegible })}
+ data-testid={testId}
+ >
+ {!isLegible && <TriangleAlert size={12} />}
+ <span className="translate-safe">
+ {isLegible
+ ? `Contrast ${ratio.toFixed(1)}:1`
+ : `Contrast ${ratio.toFixed(1)}:1 — below the ${MIN_CONTRAST_RATIO}:1 minimum`}
+ </span>
+ </div>
+ );
+}
+
+export default BackgroundContrastNote;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/TextLayoutSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/TextLayoutSection.module.scss
deleted file mode 100644
index c4914fed9a..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/TextLayoutSection.module.scss
+++ /dev/null
@@ -1,11 +0,0 @@
-.section {
- display: flex;
- flex-direction: column;
- gap: 16px;
-}
-
-.field {
- display: flex;
- flex-direction: column;
- gap: 8px;
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/TextLayoutSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/TextLayoutSection.tsx
index 21cd1b7b29..7766ad678c 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/TextLayoutSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/TextLayoutSection.tsx
@@ -2,7 +2,6 @@ import {
DashboardtypesTextAlignDTO,
DashboardtypesVerticalAlignDTO,
} from 'api/generated/services/sigNoz.schemas';
-import { Typography } from '@signozhq/ui/typography';
import { useIsDarkMode } from 'hooks/useDarkMode';
import {
resolveTextBackground,
@@ -19,23 +18,15 @@ import type {
SectionKind,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
-import BackgroundSwatches from '../../controls/BackgroundSwatches/BackgroundSwatches';
-import CustomBackgroundRow from '../../controls/BackgroundSwatches/CustomBackgroundRow';
-import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';
+import AlignmentGrid from '../../controls/AlignmentGrid/AlignmentGrid';
+import ColorSwatches from '../../controls/ColorSwatches/ColorSwatches';
+import ConfigField from '../../controls/ConfigField/ConfigField';
+import { createFieldResetter } from '../../utils/changes';
+import { backgroundOptions } from './background';
+import BackgroundContrastNote from './BackgroundContrastNote';
-import styles from './TextLayoutSection.module.scss';
-
-const HORIZONTAL_OPTIONS = [
- { value: DashboardtypesTextAlignDTO.left, label: 'Left' },
- { value: DashboardtypesTextAlignDTO.center, label: 'Center' },
- { value: DashboardtypesTextAlignDTO.right, label: 'Right' },
-];
-
-const VERTICAL_OPTIONS = [
- { value: DashboardtypesVerticalAlignDTO.top, label: 'Top' },
- { value: DashboardtypesVerticalAlignDTO.center, label: 'Middle' },
- { value: DashboardtypesVerticalAlignDTO.bottom, label: 'Bottom' },
-];
+/** What the picker opens on before a custom colour is chosen. */
+const INITIAL_CUSTOM_COLOR = '#3A2A63';
/**
* Edits the Text panel's `presentation` slice: body alignment and the card
@@ -43,56 +34,56 @@ const VERTICAL_OPTIONS = [
*/
function TextLayoutSection({
value,
+ savedValue,
onChange,
}: SectionEditorProps<SectionKind.TextLayout>): JSX.Element {
const theme = useIsDarkMode() ? PanelTheme.Dark : PanelTheme.Light;
const background = resolveTextBackground(value?.background, theme);
+ const reset = createFieldResetter(value, savedValue, onChange);
return (
- <div className={styles.section}>
- <div className={styles.field}>
- <Typography.Text>Horizontal alignment</Typography.Text>
- <ConfigSegmented
- testId="text-layout-horizontal-align"
- items={HORIZONTAL_OPTIONS}
- value={value?.textAlign ?? DashboardtypesTextAlignDTO.left}
- onChange={(textAlign): void => onChange({ ...value, textAlign })}
- />
- </div>
- <div className={styles.field}>
- <Typography.Text>Vertical alignment</Typography.Text>
- <ConfigSegmented
- testId="text-layout-vertical-align"
- items={VERTICAL_OPTIONS}
- value={value?.verticalAlign ?? DashboardtypesVerticalAlignDTO.top}
- onChange={(verticalAlign): void => onChange({ ...value, verticalAlign })}
+ <>
+ <ConfigField label="Text position" {...reset('textAlign', 'verticalAlign')}>
+ <AlignmentGrid
+ testId="text-layout-align"
+ description="Where the text sits inside the panel."
+ value={{
+ textAlign: value?.textAlign ?? DashboardtypesTextAlignDTO.left,
+ verticalAlign: value?.verticalAlign ?? DashboardtypesVerticalAlignDTO.top,
+ }}
+ onChange={(alignment): void => onChange({ ...value, ...alignment })}
/>
- </div>
- <div className={styles.field}>
- <Typography.Text>Background</Typography.Text>
- <BackgroundSwatches
+ </ConfigField>
+ <ConfigField label="Background" {...reset('background')}>
+ <ColorSwatches
testId="text-layout-background"
label="Panel background"
- theme={theme}
value={selectionFromResolved(background)}
+ options={backgroundOptions(theme)}
+ dividerAfter={1}
onChange={(selection: TextBackgroundSelection): void =>
onChange({
...value,
background: storedFromSelection(selection, theme),
})
}
+ custom={{
+ value:
+ background.kind === TextBackgroundKind.Custom
+ ? background.surface
+ : undefined,
+ initial: INITIAL_CUSTOM_COLOR,
+ onChange: (hex): void => onChange({ ...value, background: hex }),
+ pickerFooter: (hex) => (
+ <BackgroundContrastNote
+ testId="text-layout-background-custom-contrast"
+ color={hex}
+ />
+ ),
+ }}
/>
- <CustomBackgroundRow
- testId="text-layout-background-custom"
- value={
- background.kind === TextBackgroundKind.Custom
- ? background.surface
- : undefined
- }
- onChange={(hex): void => onChange({ ...value, background: hex })}
- />
- </div>
- </div>
+ </ConfigField>
+ </>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/__tests__/BackgroundContrastNote.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/__tests__/BackgroundContrastNote.test.tsx
new file mode 100644
index 0000000000..917b490e2d
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/__tests__/BackgroundContrastNote.test.tsx
@@ -0,0 +1,23 @@
+import { render, screen } from '@testing-library/react';
+
+import BackgroundContrastNote from '../BackgroundContrastNote';
+
+function renderNote(color: string): HTMLElement {
+ render(<BackgroundContrastNote testId="contrast" color={color} />);
+ return screen.getByTestId('contrast');
+}
+
+describe('BackgroundContrastNote', () => {
+ it('reports the contrast the derived ink achieves', () => {
+ // The derived ink is pure white, not purple's paired ink.
+ expect(renderNote('#3A2A63')).toHaveTextContent('Contrast 12.4:1');
+ });
+
+ it('warns when no ink clears the floor', () => {
+ expect(renderNote('#808080')).toHaveTextContent('below the 4.5:1 minimum');
+ });
+
+ it('says nothing about the floor when the colour clears it', () => {
+ expect(renderNote('#111111')).not.toHaveTextContent('below');
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/__tests__/TextLayoutSection.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/__tests__/TextLayoutSection.test.tsx
index 7c0fe6929e..4a54bda94d 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/__tests__/TextLayoutSection.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/__tests__/TextLayoutSection.test.tsx
@@ -1,10 +1,11 @@
import type { ReactElement } from 'react';
import {
- fireEvent,
render as rtlRender,
type RenderResult,
screen,
+ within,
} from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import { TooltipProvider } from '@signozhq/ui/tooltip';
import {
DashboardtypesTextAlignDTO,
@@ -29,11 +30,12 @@ function render(ui: ReactElement): RenderResult {
// The theme context defaults to dark, so the swatches paint the dark pairs.
describe('TextLayoutSection', () => {
- it('changes horizontal alignment', () => {
+ it('changes horizontal alignment', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(<TextLayoutSection value={value} onChange={onChange} />);
- fireEvent.click(screen.getByText('Center'));
+ await user.click(screen.getByTestId('text-layout-align-top-center'));
expect(onChange).toHaveBeenCalledWith({
...value,
@@ -41,11 +43,12 @@ describe('TextLayoutSection', () => {
});
});
- it('changes vertical alignment', () => {
+ it('changes vertical alignment', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(<TextLayoutSection value={value} onChange={onChange} />);
- fireEvent.click(screen.getByText('Bottom'));
+ await user.click(screen.getByTestId('text-layout-align-bottom-left'));
expect(onChange).toHaveBeenCalledWith({
...value,
@@ -53,11 +56,12 @@ describe('TextLayoutSection', () => {
});
});
- it('stores the surface of the theme a preset was picked in', () => {
+ it('stores the surface of the theme a preset was picked in', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(<TextLayoutSection value={value} onChange={onChange} />);
- fireEvent.click(screen.getByRole('radio', { name: 'Amber' }));
+ await user.click(screen.getByRole('radio', { name: 'Amber' }));
expect(onChange).toHaveBeenCalledWith({
...value,
@@ -65,11 +69,12 @@ describe('TextLayoutSection', () => {
});
});
- it('stores a zero-alpha colour for transparent', () => {
+ it('stores a zero-alpha colour for transparent', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(<TextLayoutSection value={value} onChange={onChange} />);
- fireEvent.click(screen.getByRole('radio', { name: 'Transparent' }));
+ await user.click(screen.getByRole('radio', { name: 'Transparent' }));
expect(onChange).toHaveBeenCalledWith({
...value,
@@ -77,7 +82,8 @@ describe('TextLayoutSection', () => {
});
});
- it('unsets the background for the default panel surface', () => {
+ it('unsets the background for the default panel surface', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(
<TextLayoutSection
@@ -86,7 +92,7 @@ describe('TextLayoutSection', () => {
/>,
);
- fireEvent.click(screen.getByRole('radio', { name: 'Default panel' }));
+ await user.click(screen.getByRole('radio', { name: 'Default panel' }));
expect(onChange).toHaveBeenCalledWith({ ...value, background: undefined });
});
@@ -102,14 +108,14 @@ describe('TextLayoutSection', () => {
expect(screen.getByRole('radio', { name: 'Sakura' })).toBeChecked();
});
- it('stores a custom colour straight from the picker', () => {
+ it('stores a custom colour straight from the picker', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(<TextLayoutSection value={value} onChange={onChange} />);
- fireEvent.click(screen.getByTestId('text-layout-background-custom'));
- fireEvent.change(screen.getByRole('textbox'), {
- target: { value: '3A2A64' },
- });
+ await user.click(screen.getByTestId('text-layout-background-custom'));
+ await user.clear(screen.getByRole('textbox'));
+ await user.type(screen.getByRole('textbox'), '3A2A64');
expect(onChange).toHaveBeenCalledWith({
...value,
@@ -117,7 +123,7 @@ describe('TextLayoutSection', () => {
});
});
- it('shows a stored custom colour on the custom row alone', () => {
+ it('shows a stored custom colour on the custom swatch alone', () => {
render(
<TextLayoutSection
value={{ ...value, background: '#3A2A64' }}
@@ -125,11 +131,12 @@ describe('TextLayoutSection', () => {
/>,
);
- expect(screen.getByTestId('text-layout-background-custom')).toHaveTextContent(
- '#3A2A64',
+ expect(screen.getByTestId('text-layout-background-custom')).toHaveAttribute(
+ 'aria-label',
+ 'Custom #3A2A64',
);
expect(
- screen
+ within(screen.getByRole('radiogroup', { name: 'Panel background' }))
.getAllByRole<HTMLInputElement>('radio')
.filter((swatch) => swatch.checked),
).toHaveLength(0);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/background.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/background.ts
new file mode 100644
index 0000000000..bf4e89fb89
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/TextLayoutSection/background.ts
@@ -0,0 +1,76 @@
+import {
+ TEXT_BACKGROUND_PAIRS,
+ TEXT_BACKGROUND_PRESETS,
+} from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/presets';
+import {
+ type PanelTheme,
+ type ResolvedTextBackground,
+ TextBackgroundKind,
+ type TextBackgroundPreset,
+ type TextBackgroundSelection,
+} from 'pages/DashboardPage/DashboardContainer/Panels/kinds/TextPanel/background/types';
+
+import type { ColorSwatchOption } from '../../controls/ColorSwatches/ColorSwatches';
+
+const PRESET_TITLES: Record<TextBackgroundPreset, string> = {
+ robin: 'Robin',
+ purple: 'Purple',
+ sakura: 'Sakura',
+ cherry: 'Cherry',
+ amber: 'Amber',
+ forest: 'Forest',
+ sienna: 'Sienna',
+ slate: 'Slate',
+};
+
+type BaseSelection = TextBackgroundKind.None | TextBackgroundKind.Default;
+
+const BASE_TITLES: Record<BaseSelection, string> = {
+ none: 'Transparent',
+ default: 'Default panel',
+};
+
+export function backgroundTitle(background: ResolvedTextBackground): string {
+ switch (background.kind) {
+ case TextBackgroundKind.Preset:
+ return background.preset ? PRESET_TITLES[background.preset] : 'Custom';
+ case TextBackgroundKind.Custom:
+ return `Custom ${background.surface?.toUpperCase() ?? ''}`.trim();
+ case TextBackgroundKind.None:
+ return BASE_TITLES.none;
+ default:
+ return BASE_TITLES.default;
+ }
+}
+
+const BASE_TOOLTIPS: Record<BaseSelection, string> = {
+ none: 'Transparent — no card, border or title bar',
+ default: 'Default panel color',
+};
+
+export function backgroundOptions(
+ theme: PanelTheme,
+): ColorSwatchOption<TextBackgroundSelection>[] {
+ return [
+ {
+ value: TextBackgroundKind.None,
+ id: TextBackgroundKind.None,
+ label: BASE_TITLES.none,
+ tooltip: BASE_TOOLTIPS.none,
+ pattern: 'transparent',
+ },
+ {
+ value: TextBackgroundKind.Default,
+ id: TextBackgroundKind.Default,
+ label: BASE_TITLES.default,
+ tooltip: BASE_TOOLTIPS.default,
+ pattern: 'surface',
+ },
+ ...TEXT_BACKGROUND_PRESETS.map((preset) => ({
+ value: preset,
+ id: preset,
+ label: PRESET_TITLES[preset],
+ fill: TEXT_BACKGROUND_PAIRS[preset][theme].surface,
+ })),
+ ];
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdColorSelect.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdColorSelect.tsx
deleted file mode 100644
index ff87737fd8..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdColorSelect.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import { ChevronDown } from '@signozhq/icons';
-import { ColorPicker } from 'antd';
-import { ThresholdColor } from 'pages/DashboardPage/DashboardContainer/Panels/types/threshold';
-
-import styles from './ThresholdsSection.module.scss';
-
-interface ThresholdColorSelectProps {
- value: string;
- testId?: string;
- onChange: (hex: string) => void;
-}
-
-// Named presets from the SigNoz palette (cherry / amber / forest / robin). They surface
-// as quick swatches in the picker; the full picker below covers any custom color.
-const PRESETS: { label: string; value: ThresholdColor }[] = [
- { label: 'Red', value: ThresholdColor.RED },
- { label: 'Orange', value: ThresholdColor.ORANGE },
- { label: 'Green', value: ThresholdColor.GREEN },
- { label: 'Blue', value: ThresholdColor.BLUE },
-];
-
-/**
- * Threshold color control: an antd ColorPicker with the palette presets plus a full
- * custom picker, in a single popover (so moving from the trigger into the picker never
- * dismisses it). The trigger shows the current swatch and its preset name, or "Custom".
- */
-function ThresholdColorSelect({
- value,
- testId,
- onChange,
-}: ThresholdColorSelectProps): JSX.Element {
- const current = PRESETS.find(
- (p) => p.value.toLowerCase() === value?.toLowerCase(),
- );
-
- return (
- <ColorPicker
- value={value}
- onChangeComplete={(c): void => onChange(c.toHexString())}
- presets={[{ label: 'Defaults', colors: PRESETS.map((p) => p.value) }]}
- >
- <button type="button" className={styles.colorTrigger} data-testid={testId}>
- <span className={styles.dot} style={{ backgroundColor: value }} />
- <span className={styles.colorLabel}>{current?.label ?? 'Custom'}</span>
- <ChevronDown size={13} />
- </button>
- </ColorPicker>
- );
-}
-
-export default ThresholdColorSelect;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.module.scss
index 20e5380232..3596f9f700 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.module.scss
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.module.scss
@@ -1,96 +1,126 @@
.list {
display: flex;
flex-direction: column;
- gap: 8px;
+ gap: 14px;
+}
+
+.help {
+ font-size: 13px;
+ line-height: 19px;
+ color: var(--l2-foreground);
}
// ── View mode: compact summary row ──────────────────────────────────────────
.viewRow {
display: flex;
align-items: center;
- gap: 8px;
- height: 40px;
- padding: 0 4px 0 10px;
- border: 1px solid var(--l2-border);
+ gap: 14px;
+ padding: 8px 10px 8px 16px;
+ border: 1px solid var(--l1-border);
+ border-radius: 4px;
background-color: var(--l2-background);
- border-radius: 6px;
+
+ &:hover {
+ border-color: var(--l2-border);
+ }
+}
+
+.viewText {
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ gap: 2px;
+ min-width: 0;
}
.viewValue {
- flex: none;
+ overflow: hidden;
+ font-family: 'Geist Mono', monospace;
font-size: 13px;
- font-weight: 500;
- color: var(--text-vanilla-100);
+ color: var(--l1-foreground);
+ white-space: nowrap;
+ text-overflow: ellipsis;
}
.viewLabel {
overflow: hidden;
font-size: 12px;
- color: var(--text-vanilla-400);
+ color: var(--l2-foreground);
white-space: nowrap;
text-overflow: ellipsis;
}
-.spacer {
- flex: 1;
+.marker {
+ flex: none;
+}
+
+.markerSquare {
+ width: 14px;
+ height: 14px;
+ flex: none;
+ border: 1px solid transparent;
+ border-radius: 3px;
}
// ── Edit mode: labelled form ────────────────────────────────────────────────
.editRow {
display: flex;
flex-direction: column;
- gap: 12px;
- padding: 12px;
+ gap: 14px;
+ padding: 16px;
+ border: 1px solid var(--bg-robin-500);
+ border-radius: 4px;
background-color: var(--l2-background);
- border: 1px solid var(--bg-robin-400);
- border-radius: 6px;
+}
+
+.editTitle {
+ font-size: 14px;
+ font-weight: 500;
+ color: var(--l1-foreground);
}
.field {
display: flex;
flex-direction: column;
- gap: 6px;
+ gap: 8px;
}
.fieldLabel {
- font-size: 12px;
- color: var(--text-vanilla-400);
+ font-size: 13px;
+ color: var(--l2-foreground);
}
-.actions {
- display: flex;
- justify-content: flex-end;
- gap: 8px;
+.emphasis {
+ font-weight: 500;
+ color: var(--l1-foreground);
}
-// ── Shared ──────────────────────────────────────────────────────────────────
-.dot {
- width: 12px;
- height: 12px;
- flex: none;
- border-radius: 50%;
+.optional {
+ color: var(--l3-foreground);
}
-.colorTrigger {
- display: flex;
- align-items: center;
- gap: 6px;
- width: 100%;
- height: 36px;
- padding: 0 10px;
- border: 1px solid var(--l2-border);
- border-radius: 4px;
- background: transparent;
- color: var(--text-vanilla-100);
- cursor: pointer;
+.amountRow {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 8px;
}
-.colorLabel {
- flex: 1;
+.formatPreview {
+ padding: 2px 8px;
+ border-radius: 3px;
+ font-family: 'Geist Mono', monospace;
font-size: 13px;
- text-align: left;
+ font-weight: 600;
+ color: var(--bg-vanilla-100);
}
+.actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+}
+
+// ── Shared ──────────────────────────────────────────────────────────────────
// Match Formatting: make the YAxisUnitSelector fill the row width.
.unitSelector {
:global(.ant-select) {
@@ -102,6 +132,20 @@
}
.invalidUnit {
- font-size: 11px;
- color: var(--bg-cherry-400);
+ display: flex;
+ align-items: flex-start;
+ gap: 6px;
+ color: var(--callout-warning-description);
+}
+
+.invalidUnitIcon {
+ flex: none;
+ margin-top: 2px;
+ color: var(--callout-warning-icon);
+}
+
+.invalidUnitText {
+ font-size: 12px;
+ line-height: 17px;
+ color: inherit;
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.tsx
index 7637d968de..acbe7fa777 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/ThresholdsSection.tsx
@@ -25,6 +25,14 @@ import styles from './ThresholdsSection.module.scss';
// New thresholds default to red (the first palette preset); the user recolors per rule.
const DEFAULT_THRESHOLD_COLOR = ThresholdColor.RED;
+const HELP: Record<ThresholdVariant, string> = {
+ label:
+ 'Draws a dashed line across the chart at a value, so you can see when data crosses it.',
+ comparison:
+ 'Changes the number’s color when it crosses a value. Useful for green / amber / red status.',
+ table: 'Colors cells in a column when they cross a value.',
+};
+
// Add-button testId per variant — kept stable so existing E2E/unit selectors hold.
const ADD_TESTID: Record<ThresholdVariant, string> = {
label: 'panel-editor-v2-add-threshold',
@@ -148,6 +156,7 @@ function ThresholdsSection({
index,
yAxisUnit,
isEditing: editingIndex === index,
+ isNew: unsavedIndex === index,
onEdit: (): void => beginEdit(index),
onSave: saveAt(index),
onLiveChange: updateAt(index),
@@ -188,6 +197,7 @@ function ThresholdsSection({
return (
<div className={styles.list}>
+ <span className={styles.help}>{HELP[variant]}</span>
{thresholds.map(renderRow)}
<Button
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.comparison.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.comparison.test.tsx
index 50767aff89..5a192dd744 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.comparison.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.comparison.test.tsx
@@ -250,4 +250,58 @@ describe('ComparisonThresholdsSection', () => {
screen.getByTestId('comparison-threshold-unit-invalid-0'),
).toBeInTheDocument();
});
+
+ it('summarises how the threshold paints', () => {
+ render(
+ <ComparisonThresholdsSection value={THRESHOLDS} onChange={jest.fn()} />,
+ );
+
+ expect(screen.getByText('Orange background')).toBeInTheDocument();
+ });
+
+ it('heads the form "New threshold" for an added row and "Edit threshold" otherwise', async () => {
+ const user = userEvent.setup();
+ render(<Harness initial={THRESHOLDS} />);
+
+ await user.click(screen.getByTestId('comparison-threshold-edit-0'));
+ expect(screen.getByText('Edit threshold')).toBeInTheDocument();
+ await user.click(screen.getByTestId('comparison-threshold-discard-0'));
+
+ await user.click(
+ screen.getByTestId('panel-editor-v2-add-comparison-threshold'),
+ );
+ expect(screen.getByText('New threshold')).toBeInTheDocument();
+ });
+
+ it('saves the operator, color and display picked from the tiles', async () => {
+ const user = userEvent.setup();
+ const onChange = jest.fn();
+ render(
+ <ComparisonThresholdsSection value={THRESHOLDS} onChange={onChange} />,
+ );
+
+ await user.click(screen.getByTestId('comparison-threshold-edit-0'));
+ await user.click(
+ screen.getByTestId(
+ `comparison-threshold-operator-0-${DashboardtypesComparisonOperatorDTO.below_or_equal}`,
+ ),
+ );
+ expect(screen.getByText('below or equal to')).toBeInTheDocument();
+ await user.click(screen.getByTestId('comparison-threshold-color-0-green'));
+ await user.click(
+ screen.getByTestId(
+ `comparison-threshold-format-0-${DashboardtypesThresholdFormatDTO.text}`,
+ ),
+ );
+ await user.click(screen.getByTestId('comparison-threshold-save-0'));
+
+ expect(onChange).toHaveBeenLastCalledWith([
+ {
+ ...THRESHOLDS[0],
+ operator: DashboardtypesComparisonOperatorDTO.below_or_equal,
+ color: '#2BB673',
+ format: DashboardtypesThresholdFormatDTO.text,
+ },
+ ]);
+ });
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx
index 9b85964b6b..e204c1691e 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/__tests__/ThresholdsSection.test.tsx
@@ -1,8 +1,7 @@
import { useState } from 'react';
-import { render, screen, waitFor } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
import type { DashboardtypesThresholdWithLabelDTO } from 'api/generated/services/sigNoz.schemas';
import type { AnyThreshold } from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
+import { render, screen, userEvent, waitFor } from 'tests/test-utils';
import ThresholdsSection from '../ThresholdsSection';
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/ComparisonThresholdRow.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/ComparisonThresholdRow.tsx
index f4055a8f63..c5badec1f3 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/ComparisonThresholdRow.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/ComparisonThresholdRow.tsx
@@ -1,23 +1,14 @@
-import {
- type DashboardtypesComparisonOperatorDTO,
- type DashboardtypesComparisonThresholdDTO,
- type DashboardtypesThresholdFormatDTO,
-} from 'api/generated/services/sigNoz.schemas';
+import type { DashboardtypesComparisonThresholdDTO } from 'api/generated/services/sigNoz.schemas';
import { formatPanelValue } from 'pages/DashboardPage/DashboardContainer/Panels/utils/formatPanelValue';
-import {
- FORMAT_OPTIONS,
- OPERATOR_OPTIONS,
- OPERATOR_SYMBOL,
-} from '../thresholdOptions';
+import { describeThresholdPaint, OPERATOR_SYMBOL } from '../thresholdOptions';
+import ThresholdAmountField from './shared/ThresholdAmountField';
import ThresholdColorField from './shared/ThresholdColorField';
+import ThresholdFormatField from './shared/ThresholdFormatField';
+import ThresholdMarker from './shared/ThresholdMarker';
+import ThresholdOperatorField from './shared/ThresholdOperatorField';
import ThresholdRowShell from './shared/ThresholdRowShell';
-import ThresholdSelectField from './shared/ThresholdSelectField';
-import ThresholdUnitField from './shared/ThresholdUnitField';
import { useThresholdDraft } from './shared/useThresholdDraft';
-import ThresholdValueField from './shared/ThresholdValueField';
-
-import styles from '../ThresholdsSection.module.scss';
interface ComparisonThresholdRowProps {
index: number;
@@ -25,6 +16,7 @@ interface ComparisonThresholdRowProps {
/** Panel formatting unit — scopes the unit picker to its category (V1 parity). */
yAxisUnit?: string;
isEditing: boolean;
+ isNew: boolean;
onEdit: () => void;
onSave: (next: DashboardtypesComparisonThresholdDTO) => void;
onLiveChange: (next: DashboardtypesComparisonThresholdDTO) => void;
@@ -41,6 +33,7 @@ function ComparisonThresholdRow({
threshold,
yAxisUnit,
isEditing,
+ isNew,
onEdit,
onSave,
onLiveChange,
@@ -54,67 +47,53 @@ function ComparisonThresholdRow({
);
const symbol = threshold.operator ? OPERATOR_SYMBOL[threshold.operator] : '';
- const summary = (
- <span className={styles.viewValue}>
- {symbol} {formatPanelValue(threshold.value, threshold.unit)}
- </span>
- );
return (
<ThresholdRowShell
index={index}
testIdPrefix="comparison-threshold"
- color={threshold.color}
+ marker={
+ <ThresholdMarker
+ kind="format"
+ color={threshold.color}
+ format={threshold.format}
+ />
+ }
isEditing={isEditing}
- summary={summary}
+ isNew={isNew}
+ title={`${symbol} ${formatPanelValue(threshold.value, threshold.unit)}`}
+ subtitle={describeThresholdPaint(threshold.color, threshold.format)}
onEdit={onEdit}
onSave={(): void => onSave(draft)}
onDiscard={onDiscard}
onRemove={onRemove}
>
- <ThresholdSelectField
- label="If value is"
+ <ThresholdOperatorField
testId={`comparison-threshold-operator-${index}`}
- placeholder="Select condition"
value={draft.operator}
- items={OPERATOR_OPTIONS}
- onChange={(operator): void =>
- setDraft((d) => ({
- ...d,
- operator: operator as DashboardtypesComparisonOperatorDTO,
- }))
- }
+ onChange={(operator): void => setDraft((d) => ({ ...d, operator }))}
/>
- <ThresholdValueField
- testId={`comparison-threshold-value-${index}`}
+ <ThresholdAmountField
+ label="Value"
+ testIdPrefix="comparison-threshold"
+ index={index}
value={draft.value}
- onChange={setValue}
- />
- <ThresholdUnitField
- testId={`comparison-threshold-unit-${index}`}
- invalidTestId={`comparison-threshold-unit-invalid-${index}`}
- value={draft.unit}
+ onValueChange={setValue}
+ unit={draft.unit}
scopeUnit={yAxisUnit}
scopeLabel="y-axis unit"
- onChange={(unit): void => setDraft((d) => ({ ...d, unit }))}
+ onUnitChange={(unit): void => setDraft((d) => ({ ...d, unit }))}
/>
<ThresholdColorField
testId={`comparison-threshold-color-${index}`}
value={draft.color}
onChange={(color): void => setDraft((d) => ({ ...d, color }))}
/>
- <ThresholdSelectField
- label="Display"
+ <ThresholdFormatField
testId={`comparison-threshold-format-${index}`}
- placeholder="Select display"
value={draft.format}
- items={FORMAT_OPTIONS}
- onChange={(format): void =>
- setDraft((d) => ({
- ...d,
- format: format as DashboardtypesThresholdFormatDTO,
- }))
- }
+ color={draft.color}
+ onChange={(format): void => setDraft((d) => ({ ...d, format }))}
/>
</ThresholdRowShell>
);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/LabelThresholdRow.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/LabelThresholdRow.tsx
index d48aa98d2d..5343893b90 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/LabelThresholdRow.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/LabelThresholdRow.tsx
@@ -4,11 +4,11 @@ import { Input } from 'antd';
import type { DashboardtypesThresholdWithLabelDTO } from 'api/generated/services/sigNoz.schemas';
import { formatPanelValue } from 'pages/DashboardPage/DashboardContainer/Panels/utils/formatPanelValue';
+import ThresholdAmountField from './shared/ThresholdAmountField';
import ThresholdColorField from './shared/ThresholdColorField';
+import ThresholdMarker from './shared/ThresholdMarker';
import ThresholdRowShell from './shared/ThresholdRowShell';
-import ThresholdUnitField from './shared/ThresholdUnitField';
import { useThresholdDraft } from './shared/useThresholdDraft';
-import ThresholdValueField from './shared/ThresholdValueField';
import styles from '../ThresholdsSection.module.scss';
@@ -18,6 +18,7 @@ interface LabelThresholdRowProps {
/** Panel formatting unit — scopes the unit picker to its category (V1 parity). */
yAxisUnit?: string;
isEditing: boolean;
+ isNew: boolean;
onEdit: () => void;
onSave: (next: DashboardtypesThresholdWithLabelDTO) => void;
onLiveChange: (next: DashboardtypesThresholdWithLabelDTO) => void;
@@ -31,6 +32,7 @@ function LabelThresholdRow({
threshold,
yAxisUnit,
isEditing,
+ isNew,
onEdit,
onSave,
onLiveChange,
@@ -48,52 +50,44 @@ function LabelThresholdRow({
onSave({ ...draft, label: draft.label ?? '' });
}, [onSave, draft]);
- const summary = (
- <>
- <span className={styles.viewValue}>
- {formatPanelValue(threshold.value, threshold.unit)}
- </span>
- {threshold.label && (
- <span className={styles.viewLabel}>{threshold.label}</span>
- )}
- </>
- );
-
return (
<ThresholdRowShell
index={index}
testIdPrefix="threshold"
- color={threshold.color}
+ marker={<ThresholdMarker kind="line" color={threshold.color} />}
isEditing={isEditing}
- summary={summary}
+ isNew={isNew}
+ title={`Line at ${formatPanelValue(threshold.value, threshold.unit)}`}
+ subtitle={threshold.label}
onEdit={onEdit}
onSave={handleSave}
onDiscard={onDiscard}
onRemove={onRemove}
>
+ <ThresholdAmountField
+ label="Draw a line at"
+ testIdPrefix="threshold"
+ index={index}
+ value={draft.value}
+ onValueChange={setValue}
+ unit={draft.unit}
+ scopeUnit={yAxisUnit}
+ scopeLabel="y-axis unit"
+ onUnitChange={(unit): void => setDraft((d) => ({ ...d, unit }))}
+ />
<ThresholdColorField
testId={`threshold-color-${index}`}
value={draft.color}
onChange={(color): void => setDraft((d) => ({ ...d, color }))}
/>
- <ThresholdValueField
- testId={`threshold-value-${index}`}
- value={draft.value}
- onChange={setValue}
- />
- <ThresholdUnitField
- testId={`threshold-unit-${index}`}
- invalidTestId={`threshold-unit-invalid-${index}`}
- value={draft.unit}
- scopeUnit={yAxisUnit}
- scopeLabel="y-axis unit"
- onChange={(unit): void => setDraft((d) => ({ ...d, unit }))}
- />
<div className={styles.field}>
- <Typography.Text className={styles.fieldLabel}>Label</Typography.Text>
+ <Typography.Text className={styles.fieldLabel}>
+ Label <span className={styles.optional}>· optional</span>
+ </Typography.Text>
<Input
data-testid={`threshold-label-${index}`}
- placeholder="Optional"
+ aria-label="Label"
+ placeholder="e.g. SLO breach"
value={draft.label ?? ''}
onChange={(e): void => setDraft((d) => ({ ...d, label: e.target.value }))}
/>
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/TableThresholdRow.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/TableThresholdRow.tsx
index d1bac17278..ec91312fba 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/TableThresholdRow.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/TableThresholdRow.tsx
@@ -1,24 +1,17 @@
-import {
- type DashboardtypesComparisonOperatorDTO,
- type DashboardtypesTableThresholdDTO,
- type DashboardtypesThresholdFormatDTO,
-} from 'api/generated/services/sigNoz.schemas';
+import type { DashboardtypesTableThresholdDTO } from 'api/generated/services/sigNoz.schemas';
+import { getUniversalNameFromMetricUnit } from 'components/YAxisUnitSelector/utils';
import { formatPanelValue } from 'pages/DashboardPage/DashboardContainer/Panels/utils/formatPanelValue';
import type { TableColumnOption } from '../../../../hooks/useTableColumns';
-import {
- FORMAT_OPTIONS,
- OPERATOR_OPTIONS,
- OPERATOR_SYMBOL,
-} from '../thresholdOptions';
+import { describeThresholdPaint, OPERATOR_SYMBOL } from '../thresholdOptions';
+import ThresholdAmountField from './shared/ThresholdAmountField';
import ThresholdColorField from './shared/ThresholdColorField';
+import ThresholdFormatField from './shared/ThresholdFormatField';
+import ThresholdMarker from './shared/ThresholdMarker';
+import ThresholdOperatorField from './shared/ThresholdOperatorField';
import ThresholdRowShell from './shared/ThresholdRowShell';
import ThresholdSelectField from './shared/ThresholdSelectField';
-import ThresholdUnitField from './shared/ThresholdUnitField';
import { useThresholdDraft } from './shared/useThresholdDraft';
-import ThresholdValueField from './shared/ThresholdValueField';
-
-import styles from '../ThresholdsSection.module.scss';
interface TableThresholdRowProps {
index: number;
@@ -26,6 +19,7 @@ interface TableThresholdRowProps {
/** Resolved value columns (with their configured units); the rule targets one. */
tableColumns: TableColumnOption[];
isEditing: boolean;
+ isNew: boolean;
onEdit: () => void;
onSave: (next: DashboardtypesTableThresholdDTO) => void;
onLiveChange: (next: DashboardtypesTableThresholdDTO) => void;
@@ -44,6 +38,7 @@ function TableThresholdRow({
threshold,
tableColumns,
isEditing,
+ isNew,
onEdit,
onSave,
onLiveChange,
@@ -63,26 +58,32 @@ function TableThresholdRow({
threshold.columnName;
const columnItems = tableColumns.map((column) => ({
value: column.key,
- label: column.label,
+ label: column.unit
+ ? `${column.label} · ${getUniversalNameFromMetricUnit(column.unit)}`
+ : column.label,
}));
const symbol = threshold.operator ? OPERATOR_SYMBOL[threshold.operator] : '';
- const summary = (
- <>
- <span className={styles.viewLabel}>{columnLabel}</span>
- <span className={styles.viewValue}>
- {symbol} {formatPanelValue(threshold.value, threshold.unit)}
- </span>
- </>
- );
+ const paint = describeThresholdPaint(threshold.color, threshold.format);
return (
<ThresholdRowShell
index={index}
testIdPrefix="table-threshold"
- color={threshold.color}
+ marker={
+ <ThresholdMarker
+ kind="format"
+ color={threshold.color}
+ format={threshold.format}
+ />
+ }
isEditing={isEditing}
- summary={summary}
+ isNew={isNew}
+ title={`${threshold.columnName} ${symbol} ${formatPanelValue(
+ threshold.value,
+ threshold.unit,
+ )}`}
+ subtitle={columnLabel ? `${paint} · ${columnLabel}` : paint}
onEdit={onEdit}
onSave={(): void => onSave(draft)}
onDiscard={onDiscard}
@@ -96,49 +97,32 @@ function TableThresholdRow({
items={columnItems}
onChange={(columnName): void => setDraft((d) => ({ ...d, columnName }))}
/>
- <ThresholdSelectField
- label="If value is"
+ <ThresholdOperatorField
testId={`table-threshold-operator-${index}`}
- placeholder="Select condition"
value={draft.operator}
- items={OPERATOR_OPTIONS}
- onChange={(operator): void =>
- setDraft((d) => ({
- ...d,
- operator: operator as DashboardtypesComparisonOperatorDTO,
- }))
- }
+ onChange={(operator): void => setDraft((d) => ({ ...d, operator }))}
/>
- <ThresholdValueField
- testId={`table-threshold-value-${index}`}
+ <ThresholdAmountField
+ label="Value"
+ testIdPrefix="table-threshold"
+ index={index}
value={draft.value}
- onChange={setValue}
- />
- <ThresholdUnitField
- testId={`table-threshold-unit-${index}`}
- invalidTestId={`table-threshold-unit-invalid-${index}`}
- value={draft.unit}
+ onValueChange={setValue}
+ unit={draft.unit}
scopeUnit={columnUnit}
scopeLabel="column unit"
- onChange={(unit): void => setDraft((d) => ({ ...d, unit }))}
+ onUnitChange={(unit): void => setDraft((d) => ({ ...d, unit }))}
/>
<ThresholdColorField
testId={`table-threshold-color-${index}`}
value={draft.color}
onChange={(color): void => setDraft((d) => ({ ...d, color }))}
/>
- <ThresholdSelectField
- label="Display"
+ <ThresholdFormatField
testId={`table-threshold-format-${index}`}
- placeholder="Select display"
value={draft.format}
- items={FORMAT_OPTIONS}
- onChange={(format): void =>
- setDraft((d) => ({
- ...d,
- format: format as DashboardtypesThresholdFormatDTO,
- }))
- }
+ color={draft.color}
+ onChange={(format): void => setDraft((d) => ({ ...d, format }))}
/>
</ThresholdRowShell>
);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdAmountField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdAmountField.tsx
new file mode 100644
index 0000000000..1ebfbf9b3f
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdAmountField.tsx
@@ -0,0 +1,90 @@
+import { useEffect, useState } from 'react';
+import { TriangleAlert } from '@signozhq/icons';
+import { Typography } from '@signozhq/ui/typography';
+import { Input } from 'antd';
+import YAxisUnitSelector from 'components/YAxisUnitSelector';
+import { YAxisSource } from 'components/YAxisUnitSelector/types';
+import { getUniversalNameFromMetricUnit } from 'components/YAxisUnitSelector/utils';
+
+import {
+ isThresholdUnitIncompatible,
+ thresholdUnitCategories,
+} from '../../thresholdUnitCategories';
+
+import styles from '../../ThresholdsSection.module.scss';
+
+interface ThresholdAmountFieldProps {
+ label: string;
+ testIdPrefix: string;
+ index: number;
+ value: number;
+ /** Receives the raw input string; the draft hook parses it. */
+ onValueChange: (raw: string) => void;
+ unit: string | undefined;
+ /** Unit whose category scopes the picker (panel y-axis unit, or the column's unit). */
+ scopeUnit: string | undefined;
+ /** How the scope reads in the mismatch message, e.g. "y-axis unit" / "column unit". */
+ scopeLabel: string;
+ onUnitChange: (unit: string) => void;
+}
+
+/** The unit picker is scoped to `scopeUnit`'s category (V1 parity). */
+function ThresholdAmountField({
+ label,
+ testIdPrefix,
+ index,
+ value,
+ onValueChange,
+ unit,
+ scopeUnit,
+ scopeLabel,
+ onUnitChange,
+}: ThresholdAmountFieldProps): JSX.Element {
+ const [raw, setRaw] = useState(String(value));
+
+ useEffect(() => {
+ setRaw((prev) => (Number(prev) === value ? prev : String(value)));
+ }, [value]);
+
+ return (
+ <div className={styles.field}>
+ <Typography.Text className={styles.fieldLabel}>{label}</Typography.Text>
+ <div className={styles.amountRow}>
+ <Input
+ data-testid={`${testIdPrefix}-value-${index}`}
+ type="number"
+ placeholder="e.g. 500"
+ aria-label="Value"
+ value={raw}
+ onChange={(e): void => {
+ setRaw(e.target.value);
+ onValueChange(e.target.value);
+ }}
+ />
+ <YAxisUnitSelector
+ containerClassName={styles.unitSelector}
+ data-testid={`${testIdPrefix}-unit-${index}`}
+ placeholder="Unit"
+ source={YAxisSource.DASHBOARDS}
+ categoriesOverride={thresholdUnitCategories(scopeUnit)}
+ value={unit}
+ onChange={onUnitChange}
+ />
+ </div>
+ {isThresholdUnitIncompatible(unit, scopeUnit) && (
+ <div
+ className={styles.invalidUnit}
+ data-testid={`${testIdPrefix}-unit-invalid-${index}`}
+ >
+ <TriangleAlert size={13} className={styles.invalidUnitIcon} />
+ <Typography.Text className={styles.invalidUnitText}>
+ {getUniversalNameFromMetricUnit(unit)} can&apos;t be compared with the{' '}
+ {scopeLabel} ({getUniversalNameFromMetricUnit(scopeUnit)}).
+ </Typography.Text>
+ </div>
+ )}
+ </div>
+ );
+}
+
+export default ThresholdAmountField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdColorField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdColorField.tsx
index 15b80abcd1..30d2612707 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdColorField.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdColorField.tsx
@@ -1,6 +1,7 @@
import { Typography } from '@signozhq/ui/typography';
-import ThresholdColorSelect from '../../ThresholdColorSelect';
+import ColorSwatches from '../../../../controls/ColorSwatches/ColorSwatches';
+import { COLOR_PRESETS } from '../../thresholdOptions';
import styles from '../../ThresholdsSection.module.scss';
@@ -10,16 +11,38 @@ interface ThresholdColorFieldProps {
onChange: (hex: string) => void;
}
-/** Labelled color picker, shared by every threshold variant. */
+const OPTIONS = COLOR_PRESETS.map((preset) => ({
+ value: preset.value as string,
+ id: preset.label.toLowerCase(),
+ label: preset.label,
+ fill: preset.value,
+}));
+
+/** Labelled color swatches, shared by every threshold variant. */
function ThresholdColorField({
testId,
value,
onChange,
}: ThresholdColorFieldProps): JSX.Element {
+ const preset = OPTIONS.find(
+ (option) => option.value.toLowerCase() === value?.toLowerCase(),
+ );
+
return (
<div className={styles.field}>
<Typography.Text className={styles.fieldLabel}>Color</Typography.Text>
- <ThresholdColorSelect value={value} testId={testId} onChange={onChange} />
+ <ColorSwatches
+ testId={testId}
+ label="Color"
+ value={preset?.value}
+ options={OPTIONS}
+ onChange={onChange}
+ custom={{
+ value: preset ? undefined : value,
+ initial: value,
+ onChange,
+ }}
+ />
</div>
);
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdFormatField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdFormatField.tsx
new file mode 100644
index 0000000000..0a9ad421c9
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdFormatField.tsx
@@ -0,0 +1,63 @@
+import { Typography } from '@signozhq/ui/typography';
+import { DashboardtypesThresholdFormatDTO } from 'api/generated/services/sigNoz.schemas';
+
+import ConfigTiles, {
+ type ConfigTileItem,
+} from '../../../../controls/ConfigTiles/ConfigTiles';
+import { FORMAT_LABEL } from '../../thresholdOptions';
+
+import styles from '../../ThresholdsSection.module.scss';
+
+const PREVIEW_VALUE = '512';
+
+interface ThresholdFormatFieldProps {
+ testId: string;
+ value: DashboardtypesThresholdFormatDTO | undefined;
+ color: string;
+ onChange: (format: DashboardtypesThresholdFormatDTO) => void;
+}
+
+function ThresholdFormatField({
+ testId,
+ value,
+ color,
+ onChange,
+}: ThresholdFormatFieldProps): JSX.Element {
+ const items: ConfigTileItem<DashboardtypesThresholdFormatDTO>[] = [
+ {
+ value: DashboardtypesThresholdFormatDTO.background,
+ label: FORMAT_LABEL.background,
+ drawing: (
+ <span className={styles.formatPreview} style={{ backgroundColor: color }}>
+ {PREVIEW_VALUE}
+ </span>
+ ),
+ },
+ {
+ value: DashboardtypesThresholdFormatDTO.text,
+ label: FORMAT_LABEL.text,
+ drawing: (
+ <span className={styles.formatPreview} style={{ color }}>
+ {PREVIEW_VALUE}
+ </span>
+ ),
+ },
+ ];
+
+ return (
+ <div className={styles.field}>
+ <Typography.Text className={styles.fieldLabel}>
+ Apply color to
+ </Typography.Text>
+ <ConfigTiles
+ testId={testId}
+ aria-label="Apply color to"
+ value={value}
+ items={items}
+ onChange={onChange}
+ />
+ </div>
+ );
+}
+
+export default ThresholdFormatField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdMarker.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdMarker.tsx
new file mode 100644
index 0000000000..76a6b19641
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdMarker.tsx
@@ -0,0 +1,36 @@
+import { DashboardtypesThresholdFormatDTO } from 'api/generated/services/sigNoz.schemas';
+
+import styles from '../../ThresholdsSection.module.scss';
+
+type ThresholdMarkerProps =
+ | { kind: 'line'; color: string }
+ | { kind: 'format'; color: string; format?: DashboardtypesThresholdFormatDTO };
+
+function ThresholdMarker(props: ThresholdMarkerProps): JSX.Element {
+ const { color } = props;
+ if (props.kind === 'line') {
+ return (
+ <svg width={16} height={4} className={styles.marker} aria-hidden>
+ <line
+ x1={1}
+ y1={2}
+ x2={15}
+ y2={2}
+ stroke={color}
+ strokeWidth={2}
+ strokeDasharray="3 2"
+ />
+ </svg>
+ );
+ }
+ const filled = props.format !== DashboardtypesThresholdFormatDTO.text;
+ return (
+ <span
+ className={styles.markerSquare}
+ style={filled ? { backgroundColor: color } : { borderColor: color }}
+ aria-hidden
+ />
+ );
+}
+
+export default ThresholdMarker;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdOperatorField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdOperatorField.tsx
new file mode 100644
index 0000000000..d1f997bc00
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdOperatorField.tsx
@@ -0,0 +1,40 @@
+import { Typography } from '@signozhq/ui/typography';
+import { DashboardtypesComparisonOperatorDTO } from 'api/generated/services/sigNoz.schemas';
+
+import ConfigTiles from '../../../../controls/ConfigTiles/ConfigTiles';
+import { OPERATOR_PHRASE, OPERATOR_TILES } from '../../thresholdOptions';
+
+import styles from '../../ThresholdsSection.module.scss';
+
+interface ThresholdOperatorFieldProps {
+ testId: string;
+ value: DashboardtypesComparisonOperatorDTO | undefined;
+ onChange: (operator: DashboardtypesComparisonOperatorDTO) => void;
+}
+
+function ThresholdOperatorField({
+ testId,
+ value,
+ onChange,
+}: ThresholdOperatorFieldProps): JSX.Element {
+ return (
+ <div className={styles.field}>
+ <Typography.Text className={styles.fieldLabel}>
+ When the value is{' '}
+ {value && (
+ <strong className={styles.emphasis}>{OPERATOR_PHRASE[value]}</strong>
+ )}
+ </Typography.Text>
+ <ConfigTiles
+ compact
+ testId={testId}
+ aria-label="Condition"
+ value={value}
+ items={OPERATOR_TILES}
+ onChange={onChange}
+ />
+ </div>
+ );
+}
+
+export default ThresholdOperatorField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdRowShell.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdRowShell.tsx
index f5deac5f6c..e4735af134 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdRowShell.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdRowShell.tsx
@@ -1,6 +1,7 @@
import type { ReactNode } from 'react';
-import { Check, Pencil, Trash2, X } from '@signozhq/icons';
+import { Pencil, Trash2 } from '@signozhq/icons';
import { Button } from '@signozhq/ui/button';
+import { Typography } from '@signozhq/ui/typography';
import styles from '../../ThresholdsSection.module.scss';
@@ -8,11 +9,11 @@ interface ThresholdRowShellProps {
index: number;
/** testId prefix per variant: `threshold` | `comparison-threshold` | `table-threshold`. */
testIdPrefix: string;
- /** Swatch color shown in view mode. */
- color: string;
+ marker: ReactNode;
isEditing: boolean;
- /** Compact view-mode summary, rendered between the color dot and the actions. */
- summary: ReactNode;
+ isNew: boolean;
+ title: ReactNode;
+ subtitle?: ReactNode;
/** Edit-mode fields. */
children: ReactNode;
onEdit: () => void;
@@ -29,9 +30,11 @@ interface ThresholdRowShellProps {
function ThresholdRowShell({
index,
testIdPrefix,
- color,
+ marker,
isEditing,
- summary,
+ isNew,
+ title,
+ subtitle,
children,
onEdit,
onSave,
@@ -41,9 +44,11 @@ function ThresholdRowShell({
if (!isEditing) {
return (
<div className={styles.viewRow}>
- <span className={styles.dot} style={{ backgroundColor: color }} />
- {summary}
- <div className={styles.spacer} />
+ {marker}
+ <div className={styles.viewText}>
+ <span className={styles.viewValue}>{title}</span>
+ {subtitle && <span className={styles.viewLabel}>{subtitle}</span>}
+ </div>
<Button
type="button"
variant="ghost"
@@ -72,6 +77,9 @@ function ThresholdRowShell({
return (
<div className={styles.editRow}>
+ <Typography.Text className={styles.editTitle}>
+ {isNew ? 'New threshold' : 'Edit threshold'}
+ </Typography.Text>
{children}
<div className={styles.actions}>
@@ -79,17 +87,15 @@ function ThresholdRowShell({
type="button"
variant="outlined"
color="secondary"
- prefix={<X size={14} />}
data-testid={`${testIdPrefix}-discard-${index}`}
onClick={onDiscard}
>
- Discard
+ Cancel
</Button>
<Button
type="button"
variant="solid"
color="primary"
- prefix={<Check size={14} />}
data-testid={`${testIdPrefix}-save-${index}`}
onClick={onSave}
>
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdUnitField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdUnitField.tsx
deleted file mode 100644
index 41404d7ce5..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdUnitField.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { Typography } from '@signozhq/ui/typography';
-import YAxisUnitSelector from 'components/YAxisUnitSelector';
-import { YAxisSource } from 'components/YAxisUnitSelector/types';
-
-import {
- isThresholdUnitIncompatible,
- thresholdUnitCategories,
-} from '../../thresholdUnitCategories';
-
-import styles from '../../ThresholdsSection.module.scss';
-
-interface ThresholdUnitFieldProps {
- testId: string;
- invalidTestId: string;
- value: string | undefined;
- /** Unit whose category scopes the picker (panel y-axis unit, or the column's unit). */
- scopeUnit: string | undefined;
- /** How the scope reads in the mismatch message, e.g. "y-axis unit" / "column unit". */
- scopeLabel: string;
- onChange: (unit: string) => void;
-}
-
-/**
- * Labelled unit picker, scoped to `scopeUnit`'s category (V1 parity) and flagging a
- * threshold unit that resolves to a different category. Shared by every variant; only
- * the scope source and its wording differ.
- */
-function ThresholdUnitField({
- testId,
- invalidTestId,
- value,
- scopeUnit,
- scopeLabel,
- onChange,
-}: ThresholdUnitFieldProps): JSX.Element {
- return (
- <div className={styles.field}>
- <Typography.Text className={styles.fieldLabel}>Unit</Typography.Text>
- <YAxisUnitSelector
- containerClassName={styles.unitSelector}
- data-testid={testId}
- placeholder="Select unit"
- source={YAxisSource.DASHBOARDS}
- categoriesOverride={thresholdUnitCategories(scopeUnit)}
- value={value}
- onChange={onChange}
- />
- {isThresholdUnitIncompatible(value, scopeUnit) && (
- <Typography.Text className={styles.invalidUnit} data-testid={invalidTestId}>
- Threshold unit ({value}) is not valid with the {scopeLabel} ({scopeUnit})
- </Typography.Text>
- )}
- </div>
- );
-}
-
-export default ThresholdUnitField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdValueField.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdValueField.tsx
deleted file mode 100644
index 7a46776365..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/rows/shared/ThresholdValueField.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { useEffect, useState } from 'react';
-import { Typography } from '@signozhq/ui/typography';
-import { Input } from 'antd';
-
-import styles from '../../ThresholdsSection.module.scss';
-
-interface ThresholdValueFieldProps {
- testId: string;
- value: number;
- /** Receives the raw input string; the draft hook parses it. */
- onChange: (raw: string) => void;
-}
-
-/** Labelled numeric "Value" input, shared by every threshold variant. */
-function ThresholdValueField({
- testId,
- value,
- onChange,
-}: ThresholdValueFieldProps): JSX.Element {
- const [raw, setRaw] = useState(String(value));
-
- useEffect(() => {
- setRaw((prev) => (Number(prev) === value ? prev : String(value)));
- }, [value]);
-
- return (
- <div className={styles.field}>
- <Typography.Text className={styles.fieldLabel}>Value</Typography.Text>
- <Input
- data-testid={testId}
- type="number"
- placeholder="Value"
- value={raw}
- onChange={(e): void => {
- setRaw(e.target.value);
- onChange(e.target.value);
- }}
- />
- </div>
- );
-}
-
-export default ThresholdValueField;
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdOptions.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdOptions.ts
index bc47f4a0db..7891ee7e4b 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdOptions.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/ThresholdsSection/thresholdOptions.ts
@@ -2,31 +2,11 @@ import {
DashboardtypesComparisonOperatorDTO,
DashboardtypesThresholdFormatDTO,
} from 'api/generated/services/sigNoz.schemas';
+import { ThresholdColor } from 'pages/DashboardPage/DashboardContainer/Panels/types/threshold';
-import type { ConfigSelectItem } from '../../controls/ConfigSelect/ConfigSelect';
-
-// Comparison operators offered in the "If value is" condition picker. Labels pair a
-// word with its math symbol so the dropdown reads clearly while the view row can show
-// the compact symbol (OPERATOR_SYMBOL below).
-export const OPERATOR_OPTIONS: ConfigSelectItem[] = [
- { value: DashboardtypesComparisonOperatorDTO.above, label: 'Above (>)' },
- {
- value: DashboardtypesComparisonOperatorDTO.above_or_equal,
- label: 'Above or equal (≥)',
- },
- { value: DashboardtypesComparisonOperatorDTO.below, label: 'Below (<)' },
- {
- value: DashboardtypesComparisonOperatorDTO.below_or_equal,
- label: 'Below or equal (≤)',
- },
- { value: DashboardtypesComparisonOperatorDTO.equal, label: 'Equal (=)' },
- {
- value: DashboardtypesComparisonOperatorDTO.not_equal,
- label: 'Not equal (≠)',
- },
-];
+import type { ConfigTileItem } from '../../controls/ConfigTiles/ConfigTiles';
-// Compact symbol shown in the collapsed (view-mode) summary row.
+// Compact symbol shown on the operator tiles and in the collapsed summary row.
export const OPERATOR_SYMBOL: Record<
DashboardtypesComparisonOperatorDTO,
string
@@ -39,9 +19,48 @@ export const OPERATOR_SYMBOL: Record<
[DashboardtypesComparisonOperatorDTO.not_equal]: '≠',
};
-// How the threshold recolors the panel: just the number ("text") or the whole tile
-// ("background").
-export const FORMAT_OPTIONS: ConfigSelectItem[] = [
- { value: DashboardtypesThresholdFormatDTO.background, label: 'Background' },
- { value: DashboardtypesThresholdFormatDTO.text, label: 'Text' },
+export const OPERATOR_PHRASE: Record<
+ DashboardtypesComparisonOperatorDTO,
+ string
+> = {
+ [DashboardtypesComparisonOperatorDTO.above]: 'above',
+ [DashboardtypesComparisonOperatorDTO.above_or_equal]: 'above or equal to',
+ [DashboardtypesComparisonOperatorDTO.below]: 'below',
+ [DashboardtypesComparisonOperatorDTO.below_or_equal]: 'below or equal to',
+ [DashboardtypesComparisonOperatorDTO.equal]: 'equal to',
+ [DashboardtypesComparisonOperatorDTO.not_equal]: 'not equal to',
+};
+
+export const OPERATOR_TILES: ConfigTileItem<DashboardtypesComparisonOperatorDTO>[] =
+ Object.values(DashboardtypesComparisonOperatorDTO).map((operator) => ({
+ value: operator,
+ label: OPERATOR_SYMBOL[operator],
+ ariaLabel: OPERATOR_PHRASE[operator],
+ }));
+
+export const FORMAT_LABEL: Record<DashboardtypesThresholdFormatDTO, string> = {
+ [DashboardtypesThresholdFormatDTO.background]: 'Background',
+ [DashboardtypesThresholdFormatDTO.text]: 'Text',
+};
+
+export const COLOR_PRESETS: { label: string; value: ThresholdColor }[] = [
+ { label: 'Red', value: ThresholdColor.RED },
+ { label: 'Orange', value: ThresholdColor.ORANGE },
+ { label: 'Green', value: ThresholdColor.GREEN },
+ { label: 'Blue', value: ThresholdColor.BLUE },
];
+
+function colorPresetName(hex: string | undefined): string {
+ return (
+ COLOR_PRESETS.find((p) => p.value.toLowerCase() === hex?.toLowerCase())
+ ?.label ?? 'Custom'
+ );
+}
+
+export function describeThresholdPaint(
+ color: string,
+ format: DashboardtypesThresholdFormatDTO | undefined,
+): string {
+ const name = colorPresetName(color);
+ return format ? `${name} ${FORMAT_LABEL[format].toLowerCase()}` : name;
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.module.scss b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.module.scss
deleted file mode 100644
index 6c02dc4661..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.module.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-.field {
- display: flex;
- flex-direction: column;
- gap: 8px;
-}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx
index be21ddd14a..07475912ce 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/VisualizationSection.tsx
@@ -1,21 +1,27 @@
-import { Typography } from '@signozhq/ui/typography';
-import type { DashboardtypesStackModeDTO } from 'api/generated/services/sigNoz.schemas';
+import { DashboardtypesTimePreferenceDTO } from 'api/generated/services/sigNoz.schemas';
import type {
SectionEditorProps,
SectionKind,
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
import { EQueryType } from 'types/common/dashboard';
-import ConfigSegmented from '../../controls/ConfigSegmented/ConfigSegmented';
+import ConfigField from '../../controls/ConfigField/ConfigField';
import ConfigSelect from '../../controls/ConfigSelect/ConfigSelect';
import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';
+import ConfigTiles from '../../controls/ConfigTiles/ConfigTiles';
+import { SWITCH_SKETCHES } from '../../controls/drawings/switchSketches';
import PanelTypeSwitcher from '../../PanelTypeSwitcher/PanelTypeSwitcher';
import type { SectionEditorContext } from '../../sectionContext';
-import { STACK_MODE_OPTIONS } from './stackModeOptions';
+import { createFieldResetter } from '../../utils/changes';
+import {
+ BAR_LAYOUT_HELP,
+ BAR_LAYOUT_OPTIONS,
+ BarLayout,
+ STACK_MODE_HELP,
+ STACK_MODE_OPTIONS,
+} from './options';
import { TIME_PREFERENCE_OPTIONS } from './timePreferenceOptions';
-import styles from './VisualizationSection.module.scss';
-
type VisualizationSectionProps = SectionEditorProps<SectionKind.Visualization> &
Pick<
SectionEditorContext,
@@ -35,6 +41,8 @@ type VisualizationSectionProps = SectionEditorProps<SectionKind.Visualization> &
*/
function VisualizationSection({
value,
+ defaultValue,
+ savedValue,
controls,
onChange,
panelKind,
@@ -43,6 +51,14 @@ function VisualizationSection({
queryType,
signal,
}: VisualizationSectionProps): JSX.Element {
+ const reset = createFieldResetter(value, savedValue, onChange);
+ const timePreference =
+ value?.timePreference ?? DashboardtypesTimePreferenceDTO.global_time;
+ const barLayout = value?.stackedBarChart
+ ? BarLayout.STACKED
+ : BarLayout.SIDE_BY_SIDE;
+ const stack = value?.stack ?? defaultValue?.stack;
+
return (
<>
{controls.switchPanelKind && panelKind && onChangePanelKind && (
@@ -58,57 +74,68 @@ function VisualizationSection({
)}
{controls.timePreference && (
- <div className={styles.field}>
- <Typography.Text>Panel time preference</Typography.Text>
+ <ConfigField
+ label="Time range"
+ help={
+ timePreference === DashboardtypesTimePreferenceDTO.global_time
+ ? 'Follows the dashboard time picker.'
+ : 'Pinned. This panel ignores the dashboard time picker.'
+ }
+ {...reset('timePreference')}
+ >
<ConfigSelect
testId="panel-editor-v2-time-preference"
- placeholder="Select time scope…"
- value={value?.timePreference}
+ value={timePreference}
items={TIME_PREFERENCE_OPTIONS}
- onChange={(next): void =>
- onChange({
- ...value,
- timePreference: next,
- })
- }
+ onChange={(next): void => onChange({ ...value, timePreference: next })}
/>
- </div>
+ </ConfigField>
)}
- {controls.stacking && (
+ {controls.fillSpans && (
<ConfigSwitch
- testId="panel-editor-v2-stacked-bar-chart"
- title="Stack series"
- description="Stack bars from all series on top of each other"
- value={value?.stackedBarChart ?? false}
- onChange={(checked): void =>
- onChange({ ...value, stackedBarChart: checked })
- }
+ testId="panel-editor-v2-fill-spans"
+ title="Treat missing data as 0"
+ description="Empty intervals plot as 0 instead of a gap, which lowers averages."
+ sketch={SWITCH_SKETCHES.fillGaps}
+ changed={reset('fillSpans').changed}
+ value={value?.fillSpans ?? false}
+ onChange={(fillSpans): void => onChange({ ...value, fillSpans })}
/>
)}
- {controls.stackMode && (
- <div className={styles.field}>
- <Typography.Text>Stack series</Typography.Text>
- <ConfigSegmented
- testId="panel-editor-v2-stack-mode"
- value={value?.stack}
- items={STACK_MODE_OPTIONS}
+ {controls.stacking && (
+ <ConfigField
+ label="Series layout"
+ help={BAR_LAYOUT_HELP[barLayout]}
+ {...reset('stackedBarChart')}
+ >
+ <ConfigTiles
+ testId="panel-editor-v2-stacked-bar-chart"
+ aria-label="Series layout"
+ value={barLayout}
+ items={BAR_LAYOUT_OPTIONS}
onChange={(next): void =>
- onChange({ ...value, stack: next as DashboardtypesStackModeDTO })
+ onChange({ ...value, stackedBarChart: next === BarLayout.STACKED })
}
/>
- </div>
+ </ConfigField>
)}
- {controls.fillSpans && (
- <ConfigSwitch
- testId="panel-editor-v2-fill-spans"
- title="Fill gaps"
- description="Fill gaps in data with 0 for continuity"
- value={value?.fillSpans ?? false}
- onChange={(checked): void => onChange({ ...value, fillSpans: checked })}
- />
+ {controls.stackMode && (
+ <ConfigField
+ label="Series layout"
+ help={stack && STACK_MODE_HELP[stack]}
+ {...reset('stack')}
+ >
+ <ConfigTiles
+ testId="panel-editor-v2-stack-mode"
+ aria-label="Series layout"
+ value={stack}
+ items={STACK_MODE_OPTIONS}
+ onChange={(next): void => onChange({ ...value, stack: next })}
+ />
+ </ConfigField>
)}
</>
);
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsx
index c98a8abe4d..e2df2af8a1 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/__tests__/VisualizationSection.test.tsx
@@ -1,4 +1,4 @@
-import { fireEvent, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import {
DashboardtypesStackModeDTO,
@@ -96,7 +96,8 @@ describe('VisualizationSection', () => {
expect(onChange).toHaveBeenCalledWith({ timePreference: 'last_1_hr' });
});
- it('toggles bar stacking through onChange, preserving other fields', () => {
+ it('toggles bar stacking through onChange, preserving other fields', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(
<VisualizationSection
@@ -112,7 +113,9 @@ describe('VisualizationSection', () => {
/>,
);
- fireEvent.click(screen.getByTestId('panel-editor-v2-stacked-bar-chart'));
+ await user.click(
+ screen.getByTestId('panel-editor-v2-stacked-bar-chart-stacked'),
+ );
expect(onChange).toHaveBeenCalledWith({
timePreference: 'global_time',
@@ -120,7 +123,7 @@ describe('VisualizationSection', () => {
});
});
- it('writes the chosen stack mode through the segmented control', async () => {
+ it('writes the chosen stack mode through the tiles', async () => {
const user = userEvent.setup();
const onChange = jest.fn();
render(
@@ -132,7 +135,7 @@ describe('VisualizationSection', () => {
);
expect(screen.getByTestId('panel-editor-v2-stack-mode')).toBeInTheDocument();
- await user.click(screen.getByText('Percent'));
+ await user.click(screen.getByTestId('panel-editor-v2-stack-mode-percent'));
expect(onChange).toHaveBeenCalledWith({
fillSpans: true,
@@ -157,7 +160,8 @@ describe('VisualizationSection', () => {
).not.toBeInTheDocument();
});
- it('toggles fill spans through onChange', () => {
+ it('toggles fill spans through onChange', async () => {
+ const user = userEvent.setup();
const onChange = jest.fn();
render(
<VisualizationSection
@@ -170,7 +174,7 @@ describe('VisualizationSection', () => {
/>,
);
- fireEvent.click(screen.getByTestId('panel-editor-v2-fill-spans'));
+ await user.click(screen.getByTestId('panel-editor-v2-fill-spans'));
expect(onChange).toHaveBeenCalledWith({ fillSpans: true });
});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/options.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/options.ts
new file mode 100644
index 0000000000..4dc268c30a
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/options.ts
@@ -0,0 +1,58 @@
+import { DashboardtypesStackModeDTO } from 'api/generated/services/sigNoz.schemas';
+
+import type { ConfigTileItem } from '../../controls/ConfigTiles/ConfigTiles';
+import { TILE_DRAWINGS } from '../../controls/drawings/tileDrawings';
+
+export enum BarLayout {
+ SIDE_BY_SIDE = 'side',
+ STACKED = 'stacked',
+}
+
+export const BAR_LAYOUT_OPTIONS: ConfigTileItem<BarLayout>[] = [
+ {
+ value: BarLayout.SIDE_BY_SIDE,
+ label: 'Side by side',
+ drawing: TILE_DRAWINGS.barsSideBySide,
+ },
+ {
+ value: BarLayout.STACKED,
+ label: 'Stacked',
+ drawing: TILE_DRAWINGS.barsStacked,
+ },
+];
+
+export const BAR_LAYOUT_HELP: Record<BarLayout, string> = {
+ [BarLayout.SIDE_BY_SIDE]:
+ 'Each series gets its own bar, side by side, for easy comparison.',
+ [BarLayout.STACKED]:
+ 'Bars sit on top of each other, so the height shows the total.',
+};
+
+// `percent` rescales each x-slice to its column total; the y axis follows.
+export const STACK_MODE_OPTIONS: ConfigTileItem<DashboardtypesStackModeDTO>[] =
+ [
+ {
+ value: DashboardtypesStackModeDTO.none,
+ label: 'Overlap',
+ drawing: TILE_DRAWINGS.areaOverlap,
+ },
+ {
+ value: DashboardtypesStackModeDTO.normal,
+ label: 'Stacked',
+ drawing: TILE_DRAWINGS.areaStacked,
+ },
+ {
+ value: DashboardtypesStackModeDTO.percent,
+ label: '100%',
+ drawing: TILE_DRAWINGS.areaPercent,
+ },
+ ];
+
+export const STACK_MODE_HELP: Record<DashboardtypesStackModeDTO, string> = {
+ [DashboardtypesStackModeDTO.none]:
+ 'Each series is drawn from zero and may hide others.',
+ [DashboardtypesStackModeDTO.normal]:
+ 'Series sit on top of each other, so the top edge shows the total.',
+ [DashboardtypesStackModeDTO.percent]:
+ 'Each series shows its share of the total at every point in time.',
+};
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/stackModeOptions.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/stackModeOptions.ts
deleted file mode 100644
index 17ef9c8bd3..0000000000
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/sections/VisualizationSection/stackModeOptions.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { DashboardtypesStackModeDTO } from 'api/generated/services/sigNoz.schemas';
-
-import type { ConfigSegmentedItem } from '../../controls/ConfigSegmented/ConfigSegmented';
-
-// `percent` rescales each x-slice to its column total; the y axis follows.
-export const STACK_MODE_OPTIONS: ConfigSegmentedItem[] = [
- { value: DashboardtypesStackModeDTO.none, label: 'None' },
- { value: DashboardtypesStackModeDTO.normal, label: 'Normal' },
- { value: DashboardtypesStackModeDTO.percent, label: 'Percent' },
-];
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/utils/__tests__/changes.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/utils/__tests__/changes.test.ts
new file mode 100644
index 0000000000..d60c9071e6
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/utils/__tests__/changes.test.ts
@@ -0,0 +1,47 @@
+import { createFieldResetter, isDifferent } from '../changes';
+
+describe('isDifferent', () => {
+ it.each([
+ [undefined, undefined],
+ [false, undefined],
+ [null, ''],
+ [[], undefined],
+ ['solid', 'solid'],
+ [{ fillOnlyBelow: false }, undefined],
+ [{ unit: 'ms' }, { unit: 'ms', decimalPrecision: '' }],
+ ])('treats %p and saved %p as equal', (value, saved) => {
+ expect(isDifferent(value, saved)).toBe(false);
+ });
+
+ it.each([
+ ['dashed', 'solid'],
+ [true, undefined],
+ [undefined, 'ms'],
+ [[{ value: 1 }], undefined],
+ [{ customColors: { a: '#fff' } }, {}],
+ [{ lineStyle: 'solid' }, { lineStyle: 'solid', fillMode: 'none' }],
+ ])('treats %p and saved %p as different', (value, saved) => {
+ expect(isDifferent(value, saved)).toBe(true);
+ });
+});
+
+describe('createFieldResetter', () => {
+ it('restores only the named fields to their saved values', () => {
+ const onChange = jest.fn();
+ const reset = createFieldResetter(
+ { softMin: 1, softMax: 9, isLogScale: true },
+ { softMin: 2, isLogScale: false },
+ onChange,
+ );
+
+ const range = reset('softMin', 'softMax');
+ expect(range.changed).toBe(true);
+ range.onReset();
+
+ expect(onChange).toHaveBeenCalledWith({
+ softMin: 2,
+ softMax: undefined,
+ isLogScale: true,
+ });
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/utils/changes.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/utils/changes.ts
new file mode 100644
index 0000000000..6535738e48
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/ConfigPane/utils/changes.ts
@@ -0,0 +1,49 @@
+import { isEqual, isPlainObject } from 'lodash-es';
+
+/** `undefined`, `null`, `''`, `false` and `[]` all render as the control's default. */
+function isUnset(value: unknown): boolean {
+ return (
+ value === undefined ||
+ value === null ||
+ value === '' ||
+ value === false ||
+ (Array.isArray(value) && value.length === 0)
+ );
+}
+
+/** Whether two slices differ, treating every unset form as equal (fields compare both ways). */
+export function isDifferent(a: unknown, b: unknown): boolean {
+ if (isPlainObject(a) || isPlainObject(b)) {
+ const left = (isPlainObject(a) ? a : {}) as Record<string, unknown>;
+ const right = (isPlainObject(b) ? b : {}) as Record<string, unknown>;
+ const keys = new Set([...Object.keys(left), ...Object.keys(right)]);
+ return [...keys].some((key) => isDifferent(left[key], right[key]));
+ }
+ if (isUnset(a) && isUnset(b)) {
+ return false;
+ }
+ return !isEqual(a, b);
+}
+
+export interface FieldResetProps {
+ changed: boolean;
+ onReset: () => void;
+}
+
+/** Binds a slice to its saved state; call with the field(s) one control owns. */
+export function createFieldResetter<T extends object>(
+ value: T | undefined,
+ savedValue: T | undefined,
+ onChange: (next: T) => void,
+): (...keys: (keyof T)[]) => FieldResetProps {
+ return (...keys) => ({
+ changed: keys.some((key) => isDifferent(value?.[key], savedValue?.[key])),
+ onReset: (): void => {
+ const next = { ...value } as T;
+ keys.forEach((key) => {
+ next[key] = savedValue?.[key] as T[keyof T];
+ });
+ onChange(next);
+ },
+ });
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/Header/Header.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/Header/Header.tsx
index 36c4dbaba6..9a4ade7ba2 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/Header/Header.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/Header/Header.tsx
@@ -12,6 +12,7 @@ import { useConfirmableAction } from 'hooks/useConfirmableAction';
import { DashboardDetailEvents } from 'pages/DashboardPage/constants/events';
import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';
+import { useUnloadPrompt } from '../hooks/useUnloadPrompt';
import styles from './Header.module.scss';
import type { BrandedPermission } from 'lib/authz/hooks/useAuthZ/types';
@@ -41,6 +42,8 @@ function Header({
onSwitchToView,
onClose,
}: HeaderProps): JSX.Element {
+ useUnloadPrompt(isDirty);
+
const discard = useConfirmableAction(
useCallback(async (): Promise<void> => {
// Only reachable after confirming a discard, which is gated on unsaved edits.
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/QueryEditorBody.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/QueryEditorBody.tsx
index b4983b8aa2..03a7266a91 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/QueryEditorBody.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/QueryEditorBody.tsx
@@ -319,6 +319,7 @@ function QueryEditorBody({
panel={draft}
panelId={panelId}
spec={spec}
+ savedSpec={(savedPanel ?? panel).spec}
onChangeSpec={setSpec}
onChangePanelKind={onChangePanelKind}
originalPanelKind={originalPanelKind}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/StaticEditorBody.tsx b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/StaticEditorBody.tsx
index 58db1f0583..5c7c505a0a 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/StaticEditorBody.tsx
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/StaticEditorBody.tsx
@@ -35,6 +35,8 @@ interface StaticEditorBodyProps extends PanelEditorContainerProps {
function StaticEditorBody({
dashboardId,
panelId,
+ panel,
+ savedPanel,
isNew = false,
target,
onClose,
@@ -122,6 +124,7 @@ function StaticEditorBody({
panel={draft}
panelId={panelId}
spec={spec}
+ savedSpec={(savedPanel ?? panel).spec}
onChangeSpec={setSpec}
onChangePanelKind={onChangePanelKind}
originalPanelKind={originalPanelKind}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/__tests__/useUnloadPrompt.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/__tests__/useUnloadPrompt.test.ts
new file mode 100644
index 0000000000..14ce051ae8
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/__tests__/useUnloadPrompt.test.ts
@@ -0,0 +1,32 @@
+import { renderHook } from '@testing-library/react';
+
+import { useUnloadPrompt } from '../useUnloadPrompt';
+
+function fireBeforeUnload(): Event {
+ const event = new Event('beforeunload', { cancelable: true });
+ window.dispatchEvent(event);
+ return event;
+}
+
+describe('useUnloadPrompt', () => {
+ it('asks to confirm a reload while enabled', () => {
+ renderHook(() => useUnloadPrompt(true));
+
+ expect(fireBeforeUnload().defaultPrevented).toBe(true);
+ });
+
+ it('lets the page unload when disabled', () => {
+ renderHook(() => useUnloadPrompt(false));
+
+ expect(fireBeforeUnload().defaultPrevented).toBe(false);
+ });
+
+ it('stops asking once the edits are saved or discarded', () => {
+ const { rerender } = renderHook(({ enabled }) => useUnloadPrompt(enabled), {
+ initialProps: { enabled: true },
+ });
+ rerender({ enabled: false });
+
+ expect(fireBeforeUnload().defaultPrevented).toBe(false);
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/useUnloadPrompt.ts b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/useUnloadPrompt.ts
new file mode 100644
index 0000000000..938c7a91ef
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/PanelEditor/hooks/useUnloadPrompt.ts
@@ -0,0 +1,17 @@
+import { useEffect } from 'react';
+
+/** While `enabled`, a refresh or tab close asks the browser to confirm leaving. */
+export function useUnloadPrompt(enabled: boolean): void {
+ useEffect(() => {
+ if (!enabled) {
+ return undefined;
+ }
+ const handleBeforeUnload = (event: BeforeUnloadEvent): void => {
+ event.preventDefault();
+ };
+ window.addEventListener('beforeunload', handleBeforeUnload);
+ return (): void => {
+ window.removeEventListener('beforeunload', handleBeforeUnload);
+ };
+ }, [enabled]);
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/sections.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/sections.ts
index 3fa8bafac5..597d215047 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/sections.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/types/sections.ts
@@ -229,7 +229,7 @@ export const SECTION_METADATA = {
[SectionKind.Legend]: { title: 'Legend', icon: Signpost },
[SectionKind.ChartAppearance]: { title: 'Chart appearance', icon: Palette },
[SectionKind.Visualization]: { title: 'Visualization', icon: Wallpaper },
- [SectionKind.Buckets]: { title: 'Histogram / Buckets', icon: BarChart },
+ [SectionKind.Buckets]: { title: 'Buckets', icon: BarChart },
[SectionKind.Thresholds]: { title: 'Thresholds', icon: Antenna },
[SectionKind.ContextLinks]: { title: 'Context Links', icon: Link2 },
[SectionKind.Columns]: { title: 'Columns', icon: Columns3 },
@@ -243,7 +243,14 @@ export const SECTION_METADATA = {
*/
export type SectionEditorProps<K extends SectionKind> = {
value: SectionSpecMap[K] | undefined;
+ /** The kind's seeded value for this slice; what an unset field renders as. */
+ defaultValue?: SectionSpecMap[K];
+ /** The slice as last saved; Reset and changed markers compare against it. */
+ savedValue?: SectionSpecMap[K];
onChange: (next: SectionSpecMap[K]) => void;
} & (K extends ControlledSectionKind
? { controls: SectionControls[K] }
: unknown);
+
+export type SectionControlsOf<K extends SectionKind> =
+ K extends ControlledSectionKind ? SectionControls[K] : undefined;
diff --git a/frontend/src/pages/DashboardPage/PanelEditorPage/stories/PanelEditorPage.stories.tsx b/frontend/src/pages/DashboardPage/PanelEditorPage/stories/PanelEditorPage.stories.tsx
index 68bf7317fa..d194a617a1 100644
--- a/frontend/src/pages/DashboardPage/PanelEditorPage/stories/PanelEditorPage.stories.tsx
+++ b/frontend/src/pages/DashboardPage/PanelEditorPage/stories/PanelEditorPage.stories.tsx
@@ -166,6 +166,12 @@ export const ConfigHistogram: Story = {
play: expandConfigSections,
};
+/** A new heatmap panel's config pane, every section expanded. */
+export const ConfigHeatmap: Story = {
+ args: { panel: 'new', newPanelKind: 'heatmap' },
+ play: expandConfigSections,
+};
+
/** A new list panel's config pane, every section expanded. */
export const ConfigList: Story = {
args: { panel: 'new', newPanelKind: 'list' },
@@ -177,3 +183,21 @@ export const ConfigText: Story = {
args: { panel: 'new', newPanelKind: 'text' },
play: expandConfigSections,
};
+
+/**
+ * A saved panel with settings changed: each changed setting and its section
+ * carry the unsaved-changes dot.
+ */
+export const ConfigChanged: Story = {
+ play: async (context) => {
+ const canvas = within(context.canvasElement);
+
+ await expandConfigSections(context);
+ await userEvent.click(
+ await canvas.findByTestId('panel-editor-v2-log-scale-log'),
+ );
+ await userEvent.click(
+ await canvas.findByTestId('panel-editor-v2-line-style-dashed'),
+ );
+ },
+};
diff --git a/frontend/src/pages/DashboardPage/PanelEditorPage/stories/__story_mockdata__/panelEditor.ts b/frontend/src/pages/DashboardPage/PanelEditorPage/stories/__story_mockdata__/panelEditor.ts
index f5d9af35bf..1c44f23c7c 100644
--- a/frontend/src/pages/DashboardPage/PanelEditorPage/stories/__story_mockdata__/panelEditor.ts
+++ b/frontend/src/pages/DashboardPage/PanelEditorPage/stories/__story_mockdata__/panelEditor.ts
@@ -27,6 +27,7 @@ export const NEW_PANEL_KINDS = [
'area-chart',
'pie-chart',
'histogram',
+ 'heatmap',
'list',
'text',
] as const;
@@ -41,6 +42,7 @@ const KIND_BY_OPTION: Record<NewPanelKind, PanelKind> = {
'pie-chart': 'signoz/PieChartPanel',
table: 'signoz/TablePanel',
histogram: 'signoz/HistogramPanel',
+ heatmap: 'signoz/HeatmapPanel',
list: 'signoz/ListPanel',
text: 'signoz/TextPanel',
};