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: added section in panel settings (#10569)

Abhi kumar937ebc1582da
diff --git a/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.styles.scss b/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.styles.scss
index 41866397cb..6bd0c7fec0 100644
--- a/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.styles.scss
+++ b/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.styles.scss
@@ -1,5 +1,7 @@
.column-unit-selector {
- margin-top: 16px;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
.heading {
color: var(--bg-vanilla-400);
@@ -30,6 +32,11 @@
width: 100%;
}
}
+ &-content {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ }
}
.lightMode {
diff --git a/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.tsx b/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.tsx
index 67fc215662..8d4bebde84 100644
--- a/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/ColumnUnitSelector/ColumnUnitSelector.tsx
@@ -72,22 +72,24 @@ export function ColumnUnitSelector(
return (
<section className="column-unit-selector">
<Typography.Text className="heading">Column Units</Typography.Text>
- {aggregationQueries.map(({ value, label }) => {
- const baseQueryName = value.split('.')[0];
- return (
- <YAxisUnitSelectorV2
- value={columnUnits[value] || ''}
- onSelect={(unitValue: string): void =>
- handleColumnUnitSelect(value, unitValue)
- }
- fieldLabel={label}
- key={value}
- selectedQueryName={baseQueryName}
- // Update the column unit value automatically only in create mode
- shouldUpdateYAxisUnit={isNewDashboard}
- />
- );
- })}
+ <div className="column-unit-selector-content">
+ {aggregationQueries.map(({ value, label }) => {
+ const baseQueryName = value.split('.')[0];
+ return (
+ <YAxisUnitSelectorV2
+ value={columnUnits[value] || ''}
+ onSelect={(unitValue: string): void =>
+ handleColumnUnitSelect(value, unitValue)
+ }
+ fieldLabel={label}
+ key={value}
+ selectedQueryName={baseQueryName}
+ // Update the column unit value automatically only in create mode
+ shouldUpdateYAxisUnit={isNewDashboard}
+ />
+ );
+ })}
+ </div>
</section>
);
}
diff --git a/frontend/src/container/NewWidget/RightContainer/ContextLinks/__test__/ContextLinks.test.tsx b/frontend/src/container/NewWidget/RightContainer/ContextLinks/__test__/ContextLinks.test.tsx
index d46380cc40..6486b78373 100644
--- a/frontend/src/container/NewWidget/RightContainer/ContextLinks/__test__/ContextLinks.test.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/ContextLinks/__test__/ContextLinks.test.tsx
@@ -56,9 +56,6 @@ describe('ContextLinks Component', () => {
/>,
);
- // Check that the component renders
- expect(screen.getByText('Context Links')).toBeInTheDocument();
-
// Check that the add button is present
expect(
screen.getByRole('button', { name: /context link/i }),
diff --git a/frontend/src/container/NewWidget/RightContainer/ContextLinks/index.tsx b/frontend/src/container/NewWidget/RightContainer/ContextLinks/index.tsx
index 240d258f25..17d4e70af2 100644
--- a/frontend/src/container/NewWidget/RightContainer/ContextLinks/index.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/ContextLinks/index.tsx
@@ -14,7 +14,7 @@ import {
verticalListSortingStrategy,
} from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
-import { Button, Modal, Typography } from 'antd';
+import { Button, Modal } from 'antd';
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
import { GripVertical, Pencil, Plus, Trash2 } from 'lucide-react';
import {
@@ -134,11 +134,16 @@ function ContextLinks({
return (
<div className="context-links-container">
- <Typography.Text className="context-links-text">
- Context Links
- </Typography.Text>
-
<div className="context-links-list">
+ <Button
+ type="default"
+ className="add-context-link-button"
+ icon={<Plus size={12} />}
+ style={{ width: '100%' }}
+ onClick={handleAddContextLink}
+ >
+ Add Context Link
+ </Button>
<OverlayScrollbar>
<DndContext
sensors={sensors}
@@ -160,16 +165,6 @@ function ContextLinks({
</SortableContext>
</DndContext>
</OverlayScrollbar>
-
- {/* button to add context link */}
- <Button
- type="primary"
- className="add-context-link-button"
- icon={<Plus size={12} />}
- onClick={handleAddContextLink}
- >
- Context Link
- </Button>
</div>
<Modal
diff --git a/frontend/src/container/NewWidget/RightContainer/ContextLinks/styles.scss b/frontend/src/container/NewWidget/RightContainer/ContextLinks/styles.scss
index 8f96a60e5d..753daa3ac6 100644
--- a/frontend/src/container/NewWidget/RightContainer/ContextLinks/styles.scss
+++ b/frontend/src/container/NewWidget/RightContainer/ContextLinks/styles.scss
@@ -2,7 +2,6 @@
display: flex;
flex-direction: column;
gap: 16px;
- margin: 12px;
}
.context-links-text {
@@ -110,10 +109,7 @@
}
.add-context-link-button {
- display: flex;
- align-items: center;
- margin: auto;
- width: fit-content;
+ width: 100%;
}
.lightMode {
diff --git a/frontend/src/container/NewWidget/RightContainer/RightContainer.styles.scss b/frontend/src/container/NewWidget/RightContainer/RightContainer.styles.scss
index ee8654725e..996b9c8f3a 100644
--- a/frontend/src/container/NewWidget/RightContainer/RightContainer.styles.scss
+++ b/frontend/src/container/NewWidget/RightContainer/RightContainer.styles.scss
@@ -24,14 +24,14 @@
letter-spacing: -0.07px;
}
}
-
- .name-description {
+ .control-container {
display: flex;
flex-direction: column;
- padding: 12px 12px 16px 12px;
- border-top: 1px solid var(--bg-slate-500);
- border-bottom: 1px solid var(--bg-slate-500);
gap: 8px;
+ }
+
+ .name-description {
+ padding: 0 0 4px 0;
.typography {
color: var(--bg-vanilla-400);
@@ -88,9 +88,6 @@
.panel-config {
display: flex;
flex-direction: column;
- padding: 12px 12px 16px 12px;
- gap: 8px;
- border-bottom: 1px solid var(--bg-slate-500);
.typography {
color: var(--bg-vanilla-400);
@@ -104,6 +101,7 @@
}
.panel-type-select {
+ width: 100%;
.ant-select-selector {
display: flex;
height: 32px;
@@ -137,7 +135,6 @@
}
.fill-gaps {
- margin-top: 16px;
display: flex;
padding: 12px;
justify-content: space-between;
@@ -156,31 +153,24 @@
letter-spacing: 0.52px;
text-transform: uppercase;
}
+ .fill-gaps-text-description {
+ color: var(--bg-vanilla-400);
+ font-family: Inter;
+ font-size: 12px;
+ font-style: normal;
+ font-weight: 400;
+ opacity: 0.6;
+ line-height: 16px; /* 133.333% */
+ }
}
.log-scale,
- .decimal-precision-selector {
- margin-top: 16px;
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- gap: 8px;
- }
-
+ .decimal-precision-selector,
.legend-position {
- margin-top: 16px;
- display: flex;
justify-content: space-between;
- flex-direction: column;
- gap: 8px;
- }
-
- .legend-colors {
- margin-top: 16px;
}
.panel-time-text {
- margin-top: 16px;
color: var(--bg-vanilla-400);
font-family: 'Space Mono';
font-size: 13px;
@@ -193,7 +183,6 @@
.y-axis-unit-selector,
.y-axis-unit-selector-v2 {
- margin-top: 16px;
display: flex;
flex-direction: column;
gap: 8px;
@@ -278,11 +267,8 @@
}
.stack-chart {
- margin-top: 16px;
- display: flex;
+ flex-direction: row;
justify-content: space-between;
- gap: 8px;
-
.label {
color: var(--bg-vanilla-400);
font-family: 'Space Mono';
@@ -296,11 +282,6 @@
}
.bucket-config {
- margin-top: 16px;
- display: flex;
- flex-direction: column;
- gap: 8px;
-
.label {
color: var(--bg-vanilla-400);
font-family: 'Space Mono';
@@ -352,16 +333,13 @@
}
}
- .context-links {
- border-bottom: 1px solid var(--bg-slate-500);
- }
-
.alerts {
display: flex;
- padding: 12px;
align-items: center;
justify-content: space-between;
- border-bottom: 1px solid var(--bg-slate-500);
+ padding: 12px;
+ min-height: 44px;
+ border-top: 1px solid var(--bg-slate-500);
cursor: pointer;
.left-section {
@@ -387,6 +365,16 @@
color: var(--bg-vanilla-400);
}
}
+
+ .context-links {
+ padding: 12px 12px 16px 12px;
+ border-bottom: 1px solid var(--bg-slate-500);
+ }
+
+ .thresholds-section {
+ padding: 12px 12px 16px 12px;
+ border-top: 1px solid var(--bg-slate-500);
+ }
}
.select-option {
@@ -418,9 +406,6 @@
}
.name-description {
- border-top: 1px solid var(--bg-vanilla-300);
- border-bottom: 1px solid var(--bg-vanilla-300);
-
.typography {
color: var(--bg-ink-400);
}
@@ -441,8 +426,6 @@
}
.panel-config {
- border-bottom: 1px solid var(--bg-vanilla-300);
-
.typography {
color: var(--bg-ink-400);
}
@@ -478,6 +461,9 @@
.fill-gaps-text {
color: var(--bg-ink-400);
}
+ .fill-gaps-text-description {
+ color: var(--bg-ink-400);
+ }
}
.bucket-config {
@@ -530,7 +516,7 @@
}
.alerts {
- border-bottom: 1px solid var(--bg-vanilla-300);
+ border-top: 1px solid var(--bg-vanilla-300);
.left-section {
.bell-icon {
@@ -549,6 +535,10 @@
.context-links {
border-bottom: 1px solid var(--bg-vanilla-300);
}
+
+ .thresholds-section {
+ border-top: 1px solid var(--bg-vanilla-300);
+ }
}
.select-option {
diff --git a/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.styles.scss b/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.styles.scss
index c010d0db9d..4a2dbf193a 100644
--- a/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.styles.scss
+++ b/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.styles.scss
@@ -1,5 +1,4 @@
.threshold-selector-container {
- padding: 12px;
padding-bottom: 80px;
.threshold-select {
diff --git a/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.tsx b/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.tsx
index d7cb156553..483be7c9e3 100644
--- a/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/Threshold/ThresholdSelector.tsx
@@ -1,10 +1,10 @@
import { useCallback } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
-import { Typography } from 'antd';
+import { Button } from 'antd';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useGetQueryLabels } from 'hooks/useGetQueryLabels';
-import { Antenna, Plus } from 'lucide-react';
+import { Plus } from 'lucide-react';
import { v4 as uuid } from 'uuid';
import Threshold from './Threshold';
@@ -68,11 +68,14 @@ function ThresholdSelector({
<DndProvider backend={HTML5Backend}>
<div className="threshold-selector-container">
<div className="threshold-select" onClick={addThresholdHandler}>
- <div className="left-section">
- <Antenna size={14} className="icon" />
- <Typography.Text className="text">Thresholds</Typography.Text>
- </div>
- <Plus size={14} onClick={addThresholdHandler} className="icon" />
+ <Button
+ type="default"
+ icon={<Plus size={14} />}
+ style={{ width: '100%' }}
+ onClick={addThresholdHandler}
+ >
+ Add Threshold
+ </Button>
</div>
{thresholds.map((threshold, idx) => (
<Threshold
diff --git a/frontend/src/container/NewWidget/RightContainer/components/SettingsSection/SettingsSection.styles.scss b/frontend/src/container/NewWidget/RightContainer/components/SettingsSection/SettingsSection.styles.scss
new file mode 100644
index 0000000000..1e911fc094
--- /dev/null
+++ b/frontend/src/container/NewWidget/RightContainer/components/SettingsSection/SettingsSection.styles.scss
@@ -0,0 +1,68 @@
+.settings-section {
+ border-top: 1px solid var(--bg-slate-500);
+}
+
+.settings-section-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ width: 100%;
+ padding: 12px 12px;
+ min-height: 44px;
+ background: transparent;
+ border: none;
+ outline: none;
+ cursor: pointer;
+
+ .settings-section-title {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ color: var(--bg-vanilla-400);
+ font-family: 'Space Mono';
+ font-size: 13px;
+ font-weight: 400;
+ text-transform: uppercase;
+ }
+
+ .chevron-icon {
+ color: var(--bg-vanilla-400);
+ transition: transform 0.2s ease-in-out;
+
+ &.open {
+ transform: rotate(180deg);
+ }
+ }
+}
+
+.settings-section-content {
+ padding: 0 12px 0 12px;
+ display: flex;
+ flex-direction: column;
+ gap: 20px;
+ max-height: 0;
+ overflow: hidden;
+ opacity: 0;
+ transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease;
+
+ &.open {
+ padding-bottom: 24px;
+ max-height: 1000px;
+ opacity: 1;
+ }
+}
+
+.lightMode {
+ .settings-section-header {
+ .chevron-icon {
+ color: var(--bg-ink-400);
+ }
+ .settings-section-title {
+ color: var(--bg-ink-400);
+ }
+ }
+
+ .settings-section {
+ border-top: 1px solid var(--bg-vanilla-300);
+ }
+}
diff --git a/frontend/src/container/NewWidget/RightContainer/components/SettingsSection/SettingsSection.tsx b/frontend/src/container/NewWidget/RightContainer/components/SettingsSection/SettingsSection.tsx
new file mode 100644
index 0000000000..930ff126f8
--- /dev/null
+++ b/frontend/src/container/NewWidget/RightContainer/components/SettingsSection/SettingsSection.tsx
@@ -0,0 +1,51 @@
+import { ReactNode, useState } from 'react';
+import { ChevronDown } from 'lucide-react';
+
+import './SettingsSection.styles.scss';
+
+export interface SettingsSectionProps {
+ title: string;
+ defaultOpen?: boolean;
+ children: ReactNode;
+ icon?: ReactNode;
+}
+
+function SettingsSection({
+ title,
+ defaultOpen = false,
+ children,
+ icon,
+}: SettingsSectionProps): JSX.Element {
+ const [isOpen, setIsOpen] = useState(defaultOpen);
+
+ const toggleOpen = (): void => {
+ setIsOpen((prev) => !prev);
+ };
+
+ return (
+ <section className="settings-section">
+ <button
+ type="button"
+ className="settings-section-header"
+ onClick={toggleOpen}
+ >
+ <span className="settings-section-title">
+ {icon ? icon : null} {title}
+ </span>
+ <ChevronDown
+ size={16}
+ className={isOpen ? 'chevron-icon open' : 'chevron-icon'}
+ />
+ </button>
+ <div
+ className={
+ isOpen ? 'settings-section-content open' : 'settings-section-content'
+ }
+ >
+ {children}
+ </div>
+ </section>
+ );
+}
+
+export default SettingsSection;
diff --git a/frontend/src/container/NewWidget/RightContainer/index.tsx b/frontend/src/container/NewWidget/RightContainer/index.tsx
index 201890c523..00b9208bae 100644
--- a/frontend/src/container/NewWidget/RightContainer/index.tsx
+++ b/frontend/src/container/NewWidget/RightContainer/index.tsx
@@ -14,7 +14,6 @@ import {
Input,
InputNumber,
Select,
- Space,
Switch,
Typography,
} from 'antd';
@@ -28,9 +27,16 @@ import { useDashboardVariables } from 'hooks/dashboard/useDashboardVariables';
import useCreateAlerts from 'hooks/queryBuilder/useCreateAlerts';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import {
+ Antenna,
+ Axis3D,
ConciergeBell,
+ Layers,
+ LayoutDashboard,
LineChart,
+ Link,
+ Pencil,
Plus,
+ SlidersHorizontal,
Spline,
SquareArrowOutUpRight,
} from 'lucide-react';
@@ -46,6 +52,7 @@ import { DataSource } from 'types/common/queryBuilder';
import { popupContainer } from 'utils/selectPopupContainer';
import { ColumnUnitSelector } from './ColumnUnitSelector/ColumnUnitSelector';
+import SettingsSection from './components/SettingsSection/SettingsSection';
import {
panelTypeVsBucketConfig,
panelTypeVsColumnUnitPreferences,
@@ -178,6 +185,21 @@ function RightContainer({
}));
}, [dashboardVariables]);
+ const isAxisSectionVisible = useMemo(() => allowSoftMinMax || allowLogScale, [
+ allowSoftMinMax,
+ allowLogScale,
+ ]);
+
+ const isFormattingSectionVisible = useMemo(
+ () => allowYAxisUnit || allowDecimalPrecision || allowPanelColumnPreference,
+ [allowYAxisUnit, allowDecimalPrecision, allowPanelColumnPreference],
+ );
+
+ const isLegendSectionVisible = useMemo(
+ () => allowLegendPosition || allowLegendColors,
+ [allowLegendPosition, allowLegendColors],
+ );
+
const updateCursorAndDropdown = (value: string, pos: number): void => {
setCursorPos(pos);
const lastDollar = value.lastIndexOf('$', pos - 1);
@@ -193,6 +215,15 @@ function RightContainer({
}, 0);
};
+ const decimapPrecisionOptions = useMemo(() => {
+ return [
+ { label: '0 decimals', value: PrecisionOptionsEnum.ZERO },
+ { label: '1 decimal', value: PrecisionOptionsEnum.ONE },
+ { label: '2 decimals', value: PrecisionOptionsEnum.TWO },
+ { label: '3 decimals', value: PrecisionOptionsEnum.THREE },
+ ];
+ }, []);
+
const handleInputCursor = (): void => {
const pos = inputRef.current?.input?.selectionStart ?? 0;
updateCursorAndDropdown(inputValue, pos);
@@ -263,269 +294,297 @@ function RightContainer({
<div className="right-container">
<section className="header">
<div className="purple-dot" />
- <Typography.Text className="header-text">Panel details</Typography.Text>
+ <Typography.Text className="header-text">Panel Settings</Typography.Text>
</section>
- <section className="name-description">
- <Typography.Text className="typography">Name</Typography.Text>
- <AutoComplete
- options={dashboardVariableOptions}
- value={inputValue}
- onChange={onInputChange}
- onSelect={onSelect}
- filterOption={filterOption}
- style={{ width: '100%' }}
- getPopupContainer={popupContainer}
- placeholder="Enter the panel name here..."
- open={autoCompleteOpen}
- >
- <Input
- rootClassName="name-input"
- ref={inputRef}
- onSelect={handleInputCursor}
- onClick={handleInputCursor}
- onBlur={(): void => setAutoCompleteOpen(false)}
- />
- </AutoComplete>
- <Typography.Text className="typography">Description</Typography.Text>
- <TextArea
- placeholder="Enter the panel description here..."
- bordered
- allowClear
- value={description}
- onChange={(event): void =>
- onChangeHandler(setDescription, event.target.value)
- }
- rootClassName="description-input"
- />
- </section>
- <section className="panel-config">
- <Typography.Text className="typography">Panel Type</Typography.Text>
- <Select
- onChange={setGraphHandler}
- value={selectedGraph}
- style={{ width: '100%' }}
- className="panel-type-select"
- data-testid="panel-change-select"
- data-stacking-state={stackedBarChart ? 'true' : 'false'}
- >
- {graphTypes.map((item) => (
- <Option key={item.name} value={item.name}>
- <div className="select-option">
- <div className="icon">{item.icon}</div>
- <Typography.Text className="display">{item.display}</Typography.Text>
- </div>
- </Option>
- ))}
- </Select>
-
- {allowFillSpans && (
- <Space className="fill-gaps">
- <Typography className="fill-gaps-text">Fill gaps</Typography>
- <Switch
- checked={isFillSpans}
- size="small"
- onChange={(checked): void => setIsFillSpans(checked)}
- />
- </Space>
- )}
- {allowPanelTimePreference && (
- <>
- <Typography.Text className="panel-time-text">
- Panel Time Preference
- </Typography.Text>
- <TimePreference
- {...{
- selectedTime,
- setSelectedTime,
- }}
+ <SettingsSection title="General" defaultOpen icon={<Pencil size={14} />}>
+ <section className="name-description control-container">
+ <Typography.Text className="typography">Name</Typography.Text>
+ <AutoComplete
+ options={dashboardVariableOptions}
+ value={inputValue}
+ onChange={onInputChange}
+ onSelect={onSelect}
+ filterOption={filterOption}
+ style={{ width: '100%' }}
+ getPopupContainer={popupContainer}
+ placeholder="Enter the panel name here..."
+ open={autoCompleteOpen}
+ >
+ <Input
+ rootClassName="name-input"
+ ref={inputRef}
+ onSelect={handleInputCursor}
+ onClick={handleInputCursor}
+ onBlur={(): void => setAutoCompleteOpen(false)}
/>
- </>
- )}
-
- {allowPanelColumnPreference && (
- <ColumnUnitSelector
- columnUnits={columnUnits}
- setColumnUnits={setColumnUnits}
- isNewDashboard={isNewDashboard}
- />
- )}
-
- {allowYAxisUnit && (
- <DashboardYAxisUnitSelectorWrapper
- onSelect={setYAxisUnit}
- value={yAxisUnit || ''}
- fieldLabel={
- selectedGraphType === PanelDisplay.VALUE ||
- selectedGraphType === PanelDisplay.PIE
- ? 'Unit'
- : 'Y Axis Unit'
+ </AutoComplete>
+ <Typography.Text className="typography">Description</Typography.Text>
+ <TextArea
+ placeholder="Enter the panel description here..."
+ bordered
+ allowClear
+ value={description}
+ onChange={(event): void =>
+ onChangeHandler(setDescription, event.target.value)
}
- // Only update the y-axis unit value automatically in create mode
- shouldUpdateYAxisUnit={isNewDashboard}
+ rootClassName="description-input"
/>
- )}
+ </section>
+ </SettingsSection>
- {allowDecimalPrecision && (
- <section className="decimal-precision-selector">
- <Typography.Text className="typography">
- Decimal Precision
- </Typography.Text>
+ <section className="panel-config">
+ <SettingsSection
+ title="Visualization"
+ defaultOpen
+ icon={<LayoutDashboard size={14} />}
+ >
+ <section className="panel-type control-container">
+ <Typography.Text className="typography">Panel Type</Typography.Text>
<Select
- options={[
- { label: '0 decimals', value: PrecisionOptionsEnum.ZERO },
- { label: '1 decimal', value: PrecisionOptionsEnum.ONE },
- { label: '2 decimals', value: PrecisionOptionsEnum.TWO },
- { label: '3 decimals', value: PrecisionOptionsEnum.THREE },
- { label: '4 decimals', value: PrecisionOptionsEnum.FOUR },
- { label: 'Full Precision', value: PrecisionOptionsEnum.FULL },
- ]}
- value={decimalPrecision}
- style={{ width: '100%' }}
+ onChange={setGraphHandler}
+ value={selectedGraph}
className="panel-type-select"
- defaultValue={PrecisionOptionsEnum.TWO}
- onChange={(val: PrecisionOption): void => setDecimalPrecision(val)}
- />
+ data-testid="panel-change-select"
+ data-stacking-state={stackedBarChart ? 'true' : 'false'}
+ >
+ {graphTypes.map((item) => (
+ <Option key={item.name} value={item.name}>
+ <div className="select-option">
+ <div className="icon">{item.icon}</div>
+ <Typography.Text className="display">{item.display}</Typography.Text>
+ </div>
+ </Option>
+ ))}
+ </Select>
</section>
- )}
- {allowSoftMinMax && (
- <section className="soft-min-max">
- <section className="container">
- <Typography.Text className="text">Soft Min</Typography.Text>
- <InputNumber
- type="number"
- value={softMin}
- onChange={softMinHandler}
- rootClassName="input"
+ {allowPanelTimePreference && (
+ <section className="panel-time-preference control-container">
+ <Typography.Text className="panel-time-text">
+ Panel Time Preference
+ </Typography.Text>
+ <TimePreference
+ {...{
+ selectedTime,
+ setSelectedTime,
+ }}
/>
</section>
- <section className="container">
- <Typography.Text className="text">Soft Max</Typography.Text>
- <InputNumber
- value={softMax}
- type="number"
- rootClassName="input"
- onChange={softMaxHandler}
+ )}
+
+ {allowStackingBarChart && (
+ <section className="stack-chart control-container">
+ <Typography.Text className="label">Stack series</Typography.Text>
+ <Switch
+ checked={stackedBarChart}
+ size="small"
+ onChange={(checked): void => setStackedBarChart(checked)}
/>
</section>
- </section>
- )}
-
- {allowStackingBarChart && (
- <section className="stack-chart">
- <Typography.Text className="label">Stack series</Typography.Text>
- <Switch
- checked={stackedBarChart}
- size="small"
- onChange={(checked): void => setStackedBarChart(checked)}
- />
- </section>
- )}
-
- {allowBucketConfig && (
- <section className="bucket-config">
- <Typography.Text className="label">Number of buckets</Typography.Text>
- <InputNumber
- value={bucketCount || null}
- type="number"
- min={0}
- rootClassName="bucket-input"
- placeholder="Default: 30"
- onChange={(val): void => {
- setBucketCount(val || 0);
- }}
- />
- <Typography.Text className="label bucket-size-label">
- Bucket width
- </Typography.Text>
- <InputNumber
- value={bucketWidth || null}
- type="number"
- precision={2}
- placeholder="Default: Auto"
- step={0.1}
- min={0.0}
- rootClassName="bucket-input"
- onChange={(val): void => {
- setBucketWidth(val || 0);
- }}
- />
- <section className="combine-hist">
- <Typography.Text className="label">
- Merge all series into one
- </Typography.Text>
+ )}
+
+ {allowFillSpans && (
+ <section className="fill-gaps">
+ <div className="fill-gaps-text-container">
+ <Typography className="fill-gaps-text">Fill gaps</Typography>
+ <Typography.Text className="fill-gaps-text-description">
+ Fill gaps in data with 0 for continuity
+ </Typography.Text>
+ </div>
<Switch
- checked={combineHistogram}
+ checked={isFillSpans}
size="small"
- onChange={(checked): void => setCombineHistogram(checked)}
+ onChange={(checked): void => setIsFillSpans(checked)}
/>
</section>
- </section>
+ )}
+ </SettingsSection>
+
+ {isFormattingSectionVisible && (
+ <SettingsSection
+ title="Formatting & Units"
+ icon={<SlidersHorizontal size={14} />}
+ >
+ {allowYAxisUnit && (
+ <DashboardYAxisUnitSelectorWrapper
+ onSelect={setYAxisUnit}
+ value={yAxisUnit || ''}
+ fieldLabel={
+ selectedGraphType === PanelDisplay.VALUE ||
+ selectedGraphType === PanelDisplay.PIE
+ ? 'Unit'
+ : 'Y Axis Unit'
+ }
+ // Only update the y-axis unit value automatically in create mode
+ shouldUpdateYAxisUnit={isNewDashboard}
+ />
+ )}
+
+ {allowDecimalPrecision && (
+ <section className="decimal-precision-selector control-container">
+ <Typography.Text className="typography">
+ Decimal Precision
+ </Typography.Text>
+ <Select
+ options={decimapPrecisionOptions}
+ value={decimalPrecision}
+ style={{ width: '100%' }}
+ className="panel-type-select"
+ defaultValue={PrecisionOptionsEnum.TWO}
+ onChange={(val: PrecisionOption): void => setDecimalPrecision(val)}
+ />
+ </section>
+ )}
+
+ {allowPanelColumnPreference && (
+ <ColumnUnitSelector
+ columnUnits={columnUnits}
+ setColumnUnits={setColumnUnits}
+ isNewDashboard={isNewDashboard}
+ />
+ )}
+ </SettingsSection>
)}
- {allowLogScale && (
- <section className="log-scale">
- <Typography.Text className="typography">Y Axis Scale</Typography.Text>
- <Select
- onChange={(value): void => setIsLogScale(value === LogScale.LOGARITHMIC)}
- value={isLogScale ? LogScale.LOGARITHMIC : LogScale.LINEAR}
- style={{ width: '100%' }}
- className="panel-type-select"
- defaultValue={LogScale.LINEAR}
- >
- <Option value={LogScale.LINEAR}>
- <div className="select-option">
- <div className="icon">
- <LineChart size={16} />
- </div>
- <Typography.Text className="display">Linear</Typography.Text>
- </div>
- </Option>
- <Option value={LogScale.LOGARITHMIC}>
- <div className="select-option">
- <div className="icon">
- <Spline size={16} />
- </div>
- <Typography.Text className="display">Logarithmic</Typography.Text>
- </div>
- </Option>
- </Select>
- </section>
+ {isAxisSectionVisible && (
+ <SettingsSection title="Axes" icon={<Axis3D size={14} />}>
+ {allowSoftMinMax && (
+ <section className="soft-min-max">
+ <section className="container">
+ <Typography.Text className="text">Soft Min</Typography.Text>
+ <InputNumber
+ type="number"
+ value={softMin}
+ onChange={softMinHandler}
+ rootClassName="input"
+ />
+ </section>
+ <section className="container">
+ <Typography.Text className="text">Soft Max</Typography.Text>
+ <InputNumber
+ value={softMax}
+ type="number"
+ rootClassName="input"
+ onChange={softMaxHandler}
+ />
+ </section>
+ </section>
+ )}
+
+ {allowLogScale && (
+ <section className="log-scale control-container">
+ <Typography.Text className="typography">Y Axis Scale</Typography.Text>
+ <Select
+ onChange={(value): void =>
+ setIsLogScale(value === LogScale.LOGARITHMIC)
+ }
+ value={isLogScale ? LogScale.LOGARITHMIC : LogScale.LINEAR}
+ style={{ width: '100%' }}
+ className="panel-type-select"
+ defaultValue={LogScale.LINEAR}
+ >
+ <Option value={LogScale.LINEAR}>
+ <div className="select-option">
+ <div className="icon">
+ <LineChart size={16} />
+ </div>
+ <Typography.Text className="display">Linear</Typography.Text>
+ </div>
+ </Option>
+ <Option value={LogScale.LOGARITHMIC}>
+ <div className="select-option">
+ <div className="icon">
+ <Spline size={16} />
+ </div>
+ <Typography.Text className="display">Logarithmic</Typography.Text>
+ </div>
+ </Option>
+ </Select>
+ </section>
+ )}
+ </SettingsSection>
)}
- {allowLegendPosition && (
- <section className="legend-position">
- <Typography.Text className="typography">Legend Position</Typography.Text>
- <Select
- onChange={(value: LegendPosition): void => setLegendPosition(value)}
- value={legendPosition}
- style={{ width: '100%' }}
- className="panel-type-select"
- defaultValue={LegendPosition.BOTTOM}
- >
- <Option value={LegendPosition.BOTTOM}>
- <div className="select-option">
- <Typography.Text className="display">Bottom</Typography.Text>
- </div>
- </Option>
- <Option value={LegendPosition.RIGHT}>
- <div className="select-option">
- <Typography.Text className="display">Right</Typography.Text>
- </div>
- </Option>
- </Select>
- </section>
+ {isLegendSectionVisible && (
+ <SettingsSection title="Legend" icon={<Layers size={14} />}>
+ {allowLegendPosition && (
+ <section className="legend-position control-container">
+ <Typography.Text className="typography">Position</Typography.Text>
+ <Select
+ onChange={(value: LegendPosition): void => setLegendPosition(value)}
+ value={legendPosition}
+ style={{ width: '100%' }}
+ className="panel-type-select"
+ defaultValue={LegendPosition.BOTTOM}
+ >
+ <Option value={LegendPosition.BOTTOM}>
+ <div className="select-option">
+ <Typography.Text className="display">Bottom</Typography.Text>
+ </div>
+ </Option>
+ <Option value={LegendPosition.RIGHT}>
+ <div className="select-option">
+ <Typography.Text className="display">Right</Typography.Text>
+ </div>
+ </Option>
+ </Select>
+ </section>
+ )}
+
+ {allowLegendColors && (
+ <section className="legend-colors">
+ <LegendColors
+ customLegendColors={customLegendColors}
+ setCustomLegendColors={setCustomLegendColors}
+ queryResponse={queryResponse}
+ />
+ </section>
+ )}
+ </SettingsSection>
)}
- {allowLegendColors && (
- <section className="legend-colors">
- <LegendColors
- customLegendColors={customLegendColors}
- setCustomLegendColors={setCustomLegendColors}
- queryResponse={queryResponse}
- />
- </section>
+ {allowBucketConfig && (
+ <SettingsSection title="Histogram / Buckets">
+ <section className="bucket-config control-container">
+ <Typography.Text className="label">Number of buckets</Typography.Text>
+ <InputNumber
+ value={bucketCount || null}
+ type="number"
+ min={0}
+ rootClassName="bucket-input"
+ placeholder="Default: 30"
+ onChange={(val): void => {
+ setBucketCount(val || 0);
+ }}
+ />
+ <Typography.Text className="label bucket-size-label">
+ Bucket width
+ </Typography.Text>
+ <InputNumber
+ value={bucketWidth || null}
+ type="number"
+ precision={2}
+ placeholder="Default: Auto"
+ step={0.1}
+ min={0.0}
+ rootClassName="bucket-input"
+ onChange={(val): void => {
+ setBucketWidth(val || 0);
+ }}
+ />
+ <section className="combine-hist">
+ <Typography.Text className="label">
+ Merge all series into one
+ </Typography.Text>
+ <Switch
+ checked={combineHistogram}
+ size="small"
+ onChange={(checked): void => setCombineHistogram(checked)}
+ />
+ </section>
+ </section>
+ </SettingsSection>
)}
</section>
@@ -541,17 +600,25 @@ function RightContainer({
)}
{allowContextLinks && (
- <section className="context-links">
+ <SettingsSection
+ title="Context Links"
+ icon={<Link size={14} />}
+ defaultOpen={!!contextLinks.linksData.length}
+ >
<ContextLinks
contextLinks={contextLinks}
setContextLinks={setContextLinks}
selectedWidget={selectedWidget}
/>
- </section>
+ </SettingsSection>
)}
{allowThreshold && (
- <section>
+ <SettingsSection
+ title="Thresholds"
+ icon={<Antenna size={14} />}
+ defaultOpen={!!thresholds.length}
+ >
<ThresholdSelector
thresholds={thresholds}
setThresholds={setThresholds}
@@ -559,7 +626,7 @@ function RightContainer({
selectedGraph={selectedGraph}
columnUnits={columnUnits}
/>
- </section>
+ </SettingsSection>
)}
</div>
);
diff --git a/frontend/src/container/NewWidget/__test__/NewWidget.test.tsx b/frontend/src/container/NewWidget/__test__/NewWidget.test.tsx
index b305c91744..6425db00b5 100644
--- a/frontend/src/container/NewWidget/__test__/NewWidget.test.tsx
+++ b/frontend/src/container/NewWidget/__test__/NewWidget.test.tsx
@@ -36,7 +36,7 @@ const checkStackSeriesState = (
expect(getByTextUtil(container, 'Stack series')).toBeInTheDocument();
const stackSeriesSection = container.querySelector(
- 'section > .stack-chart',
+ '.stack-chart',
) as HTMLElement;
expect(stackSeriesSection).toBeInTheDocument();
@@ -326,7 +326,7 @@ describe('Stacking bar in new panel', () => {
expect(getByText('Stack series')).toBeInTheDocument();
// Verify section exists
- const section = container.querySelector('section > .stack-chart');
+ const section = container.querySelector('.stack-chart');
expect(section).toBeInTheDocument();
// Verify switch is present and enabled (ant-switch-checked)