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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: fix the issue of save button incorrectly enabled when cold_storage_ttl_days is -1 (#9458)
Shaheer Kochai3eff689c8593
diff --git a/frontend/src/container/GeneralSettings/GeneralSettings.tsx b/frontend/src/container/GeneralSettings/GeneralSettings.tsxindex 71e62ddfbf..5951013d12 100644--- a/frontend/src/container/GeneralSettings/GeneralSettings.tsx+++ b/frontend/src/container/GeneralSettings/GeneralSettings.tsx@@ -137,8 +137,7 @@ function GeneralSettings({if (logsCurrentTTLValues) {setLogsTotalRetentionPeriod(logsCurrentTTLValues.default_ttl_days * 24);setLogsS3RetentionPeriod(- logsCurrentTTLValues.cold_storage_ttl_days &&- logsCurrentTTLValues.cold_storage_ttl_days > 0+ logsCurrentTTLValues.cold_storage_ttl_days? logsCurrentTTLValues.cold_storage_ttl_days * 24: null,);diff --git a/frontend/src/container/GeneralSettings/__tests__/GeneralSettings.test.tsx b/frontend/src/container/GeneralSettings/__tests__/GeneralSettings.test.tsxindex 81f5d5fd2c..046de1c578 100644--- a/frontend/src/container/GeneralSettings/__tests__/GeneralSettings.test.tsx+++ b/frontend/src/container/GeneralSettings/__tests__/GeneralSettings.test.tsx@@ -94,6 +94,9 @@ const mockDisksWithoutS3: IDiskType[] = [];describe('GeneralSettings - S3 Logs Retention', () => {+ const BUTTON_SELECTOR = 'button[type="button"]';+ const PRIMARY_BUTTON_CLASS = 'ant-btn-primary';+beforeEach(() => {jest.clearAllMocks();(setRetentionApiV2 as jest.Mock).mockResolvedValue({@@ -155,10 +158,10 @@ describe('GeneralSettings - S3 Logs Retention', () => {await user.type(s3Input, '5');// Find the save button in the Logs card- const buttons = logsCard?.querySelectorAll('button[type="button"]');+ const buttons = logsCard?.querySelectorAll(BUTTON_SELECTOR);// The primary button should be the save buttonconst saveButton = Array.from(buttons || []).find((btn) =>- btn.className.includes('ant-btn-primary'),+ btn.className.includes(PRIMARY_BUTTON_CLASS),) as HTMLButtonElement;expect(saveButton).toBeInTheDocument();@@ -262,9 +265,9 @@ describe('GeneralSettings - S3 Logs Retention', () => {await user.type(totalInput, '60');// Find the save button- const buttons = logsCard?.querySelectorAll('button[type="button"]');+ const buttons = logsCard?.querySelectorAll(BUTTON_SELECTOR);const saveButton = Array.from(buttons || []).find((btn) =>- btn.className.includes('ant-btn-primary'),+ btn.className.includes(PRIMARY_BUTTON_CLASS),) as HTMLButtonElement;expect(saveButton).toBeInTheDocument();@@ -329,4 +332,59 @@ describe('GeneralSettings - S3 Logs Retention', () => {expect(dropdowns?.[1]).toHaveTextContent('Days');});});++ describe('Test 4: Save Button State with S3 Disabled', () => {+ it('should disable save button when cold_storage_ttl_days is -1 and no changes made', async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });++ render(+ <GeneralSettings+ metricsTtlValuesPayload={mockMetricsRetention}+ tracesTtlValuesPayload={mockTracesRetention}+ logsTtlValuesPayload={mockLogsRetentionWithoutS3}+ getAvailableDiskPayload={mockDisksWithS3}+ metricsTtlValuesRefetch={jest.fn()}+ tracesTtlValuesRefetch={jest.fn()}+ logsTtlValuesRefetch={jest.fn()}+ />,+ );++ // Find the Logs card+ const logsCard = screen.getByText('Logs').closest('.ant-card');+ expect(logsCard).toBeInTheDocument();++ // Find the save button+ const buttons = logsCard?.querySelectorAll(BUTTON_SELECTOR);+ const saveButton = Array.from(buttons || []).find((btn) =>+ btn.className.includes(PRIMARY_BUTTON_CLASS),+ ) as HTMLButtonElement;++ expect(saveButton).toBeInTheDocument();++ // Verify save button is disabled on initial load (no changes, S3 disabled with -1)+ expect(saveButton).toBeDisabled();++ // Find the total retention input+ const inputs = logsCard?.querySelectorAll('input[type="text"]');+ const totalInput = inputs?.[0] as HTMLInputElement;++ // Change total retention value to trigger button enable+ await user.clear(totalInput);+ await user.type(totalInput, '60');++ // Button should now be enabled after change+ await waitFor(() => {+ expect(saveButton).not.toBeDisabled();+ });++ // Revert to original value (30 days displays as 1 Month)+ await user.clear(totalInput);+ await user.type(totalInput, '1');++ // Button should be disabled again (back to original state)+ await waitFor(() => {+ expect(saveButton).toBeDisabled();+ });+ });+ });});diff --git a/frontend/src/container/GeneralSettings/utils.ts b/frontend/src/container/GeneralSettings/utils.tsindex 230e4f446d..cf2948d431 100644--- a/frontend/src/container/GeneralSettings/utils.ts+++ b/frontend/src/container/GeneralSettings/utils.ts@@ -46,8 +46,7 @@ export const convertHoursValueToRelevantUnit = (availableUnits?: ITimeUnit[],): ITimeUnitConversion => {const unitsToConsider = availableUnits?.length ? availableUnits : TimeUnits;-- if (value) {+ if (value >= 0) {for (let idx = unitsToConsider.length - 1; idx >= 0; idx -= 1) {const timeUnit = unitsToConsider[idx];const convertedValue = timeUnit.multiplier * value;@@ -62,7 +61,7 @@ export const convertHoursValueToRelevantUnit = (}// Fallback to the first available unit- return { value, timeUnitValue: unitsToConsider[0].value };+ return { value: -1, timeUnitValue: unitsToConsider[0].value };};export const convertHoursValueToRelevantUnitString = (