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.

fix(planned-downtime): timezone handling (#11318)

Jatinderjit Singhc73fdd1f816f
diff --git a/frontend/orval.config.ts b/frontend/orval.config.ts
index 222f21c04f..3a963a3afc 100644
--- a/frontend/orval.config.ts
+++ b/frontend/orval.config.ts
@@ -34,7 +34,7 @@ export default defineConfig({
signal: true,
useOperationIdAsQueryKey: false,
},
- useDates: true,
+ useDates: false,
useNamedParameters: true,
enumGenerationType: 'enum',
mutator: {
diff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.ts
index 46a5dd7728..04ac8743f6 100644
--- a/frontend/src/api/generated/services/sigNoz.schemas.ts
+++ b/frontend/src/api/generated/services/sigNoz.schemas.ts
@@ -9,7 +9,7 @@ export interface AlertmanagertypesChannelDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -34,7 +34,7 @@ export interface AlertmanagertypesChannelDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface ModelLabelSetDTO {
@@ -62,7 +62,7 @@ export interface AlertmanagertypesDeprecatedGettableAlertDTO {
* @type string
* @format date-time
*/
- endsAt?: Date;
+ endsAt?: string;
/**
* @type string
*/
@@ -80,7 +80,7 @@ export interface AlertmanagertypesDeprecatedGettableAlertDTO {
* @type string
* @format date-time
*/
- startsAt?: Date;
+ startsAt?: string;
status?: TypesAlertStatusDTO;
}
@@ -97,7 +97,7 @@ export interface AlertmanagertypesGettableRoutePolicyDTO {
* @type string
* @format date-time
*/
- createdAt: Date;
+ createdAt: string;
/**
* @type string,null
*/
@@ -127,7 +127,7 @@ export interface AlertmanagertypesGettableRoutePolicyDTO {
* @type string
* @format date-time
*/
- updatedAt: Date;
+ updatedAt: string;
/**
* @type string,null
*/
@@ -1834,7 +1834,7 @@ export interface AuthtypesGettableAuthDomainDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -1851,7 +1851,7 @@ export interface AuthtypesGettableAuthDomainDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface AuthtypesGettableTokenDTO {
@@ -2009,7 +2009,7 @@ export interface AuthtypesRoleDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -2034,7 +2034,7 @@ export interface AuthtypesRoleDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface AuthtypesSessionContextDTO {
@@ -2062,7 +2062,7 @@ export interface AuthtypesUserRoleDTO {
* @type string
* @format date-time
*/
- createdAt: Date;
+ createdAt: string;
/**
* @type string
*/
@@ -2076,7 +2076,7 @@ export interface AuthtypesUserRoleDTO {
* @type string
* @format date-time
*/
- updatedAt: Date;
+ updatedAt: string;
/**
* @type string
*/
@@ -2088,7 +2088,7 @@ export interface AuthtypesUserWithRolesDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -2117,7 +2117,7 @@ export interface AuthtypesUserWithRolesDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
/**
* @type array,null
*/
@@ -2284,7 +2284,7 @@ export interface CloudintegrationtypesAccountDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -2305,12 +2305,12 @@ export interface CloudintegrationtypesAccountDTO {
* @type string,null
* @format date-time
*/
- removedAt: Date | null;
+ removedAt: string | null;
/**
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface DashboardtypesStorableDashboardDataDTO {
@@ -2441,7 +2441,7 @@ export type CloudintegrationtypesCloudIntegrationServiceDTOAnyOf = {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -2451,7 +2451,7 @@ export type CloudintegrationtypesCloudIntegrationServiceDTOAnyOf = {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
};
/**
@@ -2645,12 +2645,12 @@ export interface CloudintegrationtypesGettableAgentCheckInDTO {
* @type string,null
* @format date-time
*/
- removed_at: Date | null;
+ removed_at: string | null;
/**
* @type string,null
* @format date-time
*/
- removedAt: Date | null;
+ removedAt: string | null;
}
export interface CloudintegrationtypesServiceMetadataDTO {
@@ -2885,7 +2885,7 @@ export interface DashboardtypesDashboardDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -2907,7 +2907,7 @@ export interface DashboardtypesDashboardDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
/**
* @type string
*/
@@ -3089,7 +3089,7 @@ export interface GatewaytypesLimitDTO {
* @type string
* @format date-time
*/
- created_at?: Date;
+ created_at?: string;
/**
* @type string
*/
@@ -3111,7 +3111,7 @@ export interface GatewaytypesLimitDTO {
* @type string
* @format date-time
*/
- updated_at?: Date;
+ updated_at?: string;
}
export interface GatewaytypesIngestionKeyDTO {
@@ -3119,12 +3119,12 @@ export interface GatewaytypesIngestionKeyDTO {
* @type string
* @format date-time
*/
- created_at?: Date;
+ created_at?: string;
/**
* @type string
* @format date-time
*/
- expires_at?: Date;
+ expires_at?: string;
/**
* @type string
*/
@@ -3145,7 +3145,7 @@ export interface GatewaytypesIngestionKeyDTO {
* @type string
* @format date-time
*/
- updated_at?: Date;
+ updated_at?: string;
/**
* @type string
*/
@@ -3169,7 +3169,7 @@ export interface GatewaytypesPostableIngestionKeyDTO {
* @type string
* @format date-time
*/
- expires_at?: Date;
+ expires_at?: string;
/**
* @type string
*/
@@ -4439,7 +4439,7 @@ export interface LlmpricingruletypesLLMPricingRuleDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -4478,13 +4478,13 @@ export interface LlmpricingruletypesLLMPricingRuleDTO {
* @type string,null
* @format date-time
*/
- syncedAt?: Date | null;
+ syncedAt?: string | null;
unit: LlmpricingruletypesLLMPricingRuleUnitDTO;
/**
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
/**
* @type string
*/
@@ -5710,7 +5710,7 @@ export interface Querybuildertypesv5RawRowDTO {
* @type string
* @format date-time
*/
- timestamp?: Date;
+ timestamp?: string;
}
export interface Querybuildertypesv5RawDataDTO {
@@ -6179,7 +6179,7 @@ export interface RuletypesRecurrenceDTO {
* @type string,null
* @format date-time
*/
- endTime?: Date | null;
+ endTime?: string | null;
/**
* @type array,null
*/
@@ -6189,7 +6189,7 @@ export interface RuletypesRecurrenceDTO {
* @type string
* @format date-time
*/
- startTime: Date;
+ startTime: string;
}
export interface RuletypesScheduleDTO {
@@ -6197,13 +6197,13 @@ export interface RuletypesScheduleDTO {
* @type string
* @format date-time
*/
- endTime?: Date;
+ endTime?: string;
recurrence?: RuletypesRecurrenceDTO;
/**
* @type string
* @format date-time
*/
- startTime?: Date;
+ startTime?: string;
/**
* @type string
*/
@@ -6219,7 +6219,7 @@ export interface RuletypesPlannedMaintenanceDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -6243,7 +6243,7 @@ export interface RuletypesPlannedMaintenanceDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
/**
* @type string
*/
@@ -6406,7 +6406,7 @@ export interface RuletypesRuleDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -6455,7 +6455,7 @@ export interface RuletypesRuleDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
/**
* @type string
*/
@@ -6474,7 +6474,7 @@ export interface ServiceaccounttypesGettableFactorAPIKeyDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type integer
* @minimum 0
@@ -6488,7 +6488,7 @@ export interface ServiceaccounttypesGettableFactorAPIKeyDTO {
* @type string
* @format date-time
*/
- lastObservedAt: Date;
+ lastObservedAt: string;
/**
* @type string
*/
@@ -6501,7 +6501,7 @@ export interface ServiceaccounttypesGettableFactorAPIKeyDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface ServiceaccounttypesGettableFactorAPIKeyWithKeyDTO {
@@ -6546,7 +6546,7 @@ export interface ServiceaccounttypesServiceAccountDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -6571,7 +6571,7 @@ export interface ServiceaccounttypesServiceAccountDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface ServiceaccounttypesServiceAccountRoleDTO {
@@ -6579,7 +6579,7 @@ export interface ServiceaccounttypesServiceAccountRoleDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -6597,7 +6597,7 @@ export interface ServiceaccounttypesServiceAccountRoleDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface ServiceaccounttypesServiceAccountWithRolesDTO {
@@ -6605,7 +6605,7 @@ export interface ServiceaccounttypesServiceAccountWithRolesDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -6634,7 +6634,7 @@ export interface ServiceaccounttypesServiceAccountWithRolesDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface ServiceaccounttypesUpdatableFactorAPIKeyDTO {
@@ -6676,7 +6676,7 @@ export interface SpantypesSpanMapperGroupDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -6701,7 +6701,7 @@ export interface SpantypesSpanMapperGroupDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
/**
* @type string
*/
@@ -6770,7 +6770,7 @@ export interface SpantypesSpanMapperDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -6796,7 +6796,7 @@ export interface SpantypesSpanMapperDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
/**
* @type string
*/
@@ -7163,7 +7163,7 @@ export interface TypesDeprecatedUserDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -7196,7 +7196,7 @@ export interface TypesDeprecatedUserDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface TypesIdentifiableDTO {
@@ -7211,7 +7211,7 @@ export interface TypesInviteDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -7244,7 +7244,7 @@ export interface TypesInviteDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface TypesOrganizationDTO {
@@ -7256,7 +7256,7 @@ export interface TypesOrganizationDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -7278,7 +7278,7 @@ export interface TypesOrganizationDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface TypesPostableInviteDTO {
@@ -7345,7 +7345,7 @@ export interface TypesResetPasswordTokenDTO {
* @type string
* @format date-time
*/
- expiresAt?: Date;
+ expiresAt?: string;
/**
* @type string
*/
@@ -7372,7 +7372,7 @@ export interface TypesUserDTO {
* @type string
* @format date-time
*/
- createdAt?: Date;
+ createdAt?: string;
/**
* @type string
*/
@@ -7401,7 +7401,7 @@ export interface TypesUserDTO {
* @type string
* @format date-time
*/
- updatedAt?: Date;
+ updatedAt?: string;
}
export interface ZeustypesHostDTO {
diff --git a/frontend/src/components/EditMemberDrawer/EditMemberDrawer.tsx b/frontend/src/components/EditMemberDrawer/EditMemberDrawer.tsx
index 4050d3f48a..b8ab9d1b13 100644
--- a/frontend/src/components/EditMemberDrawer/EditMemberDrawer.tsx
+++ b/frontend/src/components/EditMemberDrawer/EditMemberDrawer.tsx
@@ -59,7 +59,7 @@ function getDeleteTooltip(
function getInviteButtonLabel(
isLoading: boolean,
- existingToken: { expiresAt?: Date } | undefined,
+ existingToken: { expiresAt?: string } | undefined,
isExpired: boolean,
notFound: boolean,
): string {
diff --git a/frontend/src/components/ServiceAccountDrawer/__tests__/EditKeyModal.test.tsx b/frontend/src/components/ServiceAccountDrawer/__tests__/EditKeyModal.test.tsx
index 78e017bd07..f2d351ab34 100644
--- a/frontend/src/components/ServiceAccountDrawer/__tests__/EditKeyModal.test.tsx
+++ b/frontend/src/components/ServiceAccountDrawer/__tests__/EditKeyModal.test.tsx
@@ -28,7 +28,7 @@ const mockKey: ServiceaccounttypesGettableFactorAPIKeyDTO = {
id: 'key-1',
name: 'Original Key Name',
expiresAt: 0,
- lastObservedAt: null as unknown as Date,
+ lastObservedAt: null as unknown as string,
serviceAccountId: 'sa-1',
};
diff --git a/frontend/src/components/ServiceAccountDrawer/__tests__/KeysTab.test.tsx b/frontend/src/components/ServiceAccountDrawer/__tests__/KeysTab.test.tsx
index 2c58c9dee7..8b632271c1 100644
--- a/frontend/src/components/ServiceAccountDrawer/__tests__/KeysTab.test.tsx
+++ b/frontend/src/components/ServiceAccountDrawer/__tests__/KeysTab.test.tsx
@@ -29,14 +29,14 @@ const keys: ServiceaccounttypesGettableFactorAPIKeyDTO[] = [
id: 'key-1',
name: 'Production Key',
expiresAt: 0,
- lastObservedAt: null as unknown as Date,
+ lastObservedAt: null as unknown as string,
serviceAccountId: 'sa-1',
},
{
id: 'key-2',
name: 'Staging Key',
expiresAt: 1924905600, // 2030-12-31
- lastObservedAt: new Date('2026-03-10T10:00:00Z'),
+ lastObservedAt: '2026-03-10T10:00:00Z',
serviceAccountId: 'sa-1',
},
];
diff --git a/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx b/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx
index a204dd6b6f..40d35fdccf 100644
--- a/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx
+++ b/frontend/src/container/IngestionSettings/MultiIngestionSettings.tsx
@@ -438,9 +438,7 @@ function MultiIngestionSettings(): JSX.Element {
data: {
name: values.name,
tags: updatedTags,
- expires_at: new Date(
- dayjs(values.expires_at).endOf('day').toISOString(),
- ),
+ expires_at: dayjs(values.expires_at).endOf('day').toISOString(),
},
},
{
@@ -471,13 +469,11 @@ function MultiIngestionSettings(): JSX.Element {
const requestPayload = {
name: values.name,
tags: updatedTags,
- expires_at: new Date(dayjs(values.expires_at).endOf('day').toISOString()),
+ expires_at: dayjs(values.expires_at).endOf('day').toISOString(),
};
createIngestionKey(
- {
- data: requestPayload,
- },
+ { data: requestPayload },
{
onSuccess: (_data) => {
notifications.success({
diff --git a/frontend/src/container/IngestionSettings/__tests__/MultiIngestionSettings.test.tsx b/frontend/src/container/IngestionSettings/__tests__/MultiIngestionSettings.test.tsx
index c6f57d9ceb..2ed2347639 100644
--- a/frontend/src/container/IngestionSettings/__tests__/MultiIngestionSettings.test.tsx
+++ b/frontend/src/container/IngestionSettings/__tests__/MultiIngestionSettings.test.tsx
@@ -79,12 +79,12 @@ describe('MultiIngestionSettings Page', () => {
keys: [
{
name: 'Key One',
- expires_at: new Date(TEST_EXPIRES_AT),
+ expires_at: TEST_EXPIRES_AT,
value: 'secret',
workspace_id: TEST_WORKSPACE_ID,
id: 'k1',
- created_at: new Date(TEST_CREATED_UPDATED),
- updated_at: new Date(TEST_CREATED_UPDATED),
+ created_at: TEST_CREATED_UPDATED,
+ updated_at: TEST_CREATED_UPDATED,
tags: [],
limits: [
{
@@ -160,12 +160,12 @@ describe('MultiIngestionSettings Page', () => {
keys: [
{
name: 'Key Logs',
- expires_at: new Date(TEST_EXPIRES_AT),
+ expires_at: TEST_EXPIRES_AT,
value: 'secret',
workspace_id: TEST_WORKSPACE_ID,
id: 'k2',
- created_at: new Date(TEST_CREATED_UPDATED),
- updated_at: new Date(TEST_CREATED_UPDATED),
+ created_at: TEST_CREATED_UPDATED,
+ updated_at: TEST_CREATED_UPDATED,
tags: [],
limits: [
{
@@ -238,12 +238,12 @@ describe('MultiIngestionSettings Page', () => {
keys: [
{
name: KEY_NAME,
- expires_at: new Date(TEST_EXPIRES_AT),
+ expires_at: TEST_EXPIRES_AT,
value: 'secret',
workspace_id: TEST_WORKSPACE_ID,
id: 'k1',
- created_at: new Date(TEST_CREATED_UPDATED),
- updated_at: new Date(TEST_CREATED_UPDATED),
+ created_at: TEST_CREATED_UPDATED,
+ updated_at: TEST_CREATED_UPDATED,
tags: [],
limits: [
{
@@ -299,12 +299,12 @@ describe('MultiIngestionSettings Page', () => {
keys: [
{
name: 'Key Regular',
- expires_at: new Date(TEST_EXPIRES_AT),
+ expires_at: TEST_EXPIRES_AT,
value: 'secret1',
workspace_id: TEST_WORKSPACE_ID,
id: 'k1',
- created_at: new Date(TEST_CREATED_UPDATED),
- updated_at: new Date(TEST_CREATED_UPDATED),
+ created_at: TEST_CREATED_UPDATED,
+ updated_at: TEST_CREATED_UPDATED,
tags: [],
limits: [],
},
@@ -319,12 +319,12 @@ describe('MultiIngestionSettings Page', () => {
keys: [
{
name: 'Key Search Result',
- expires_at: new Date(TEST_EXPIRES_AT),
+ expires_at: TEST_EXPIRES_AT,
value: 'secret2',
workspace_id: TEST_WORKSPACE_ID,
id: 'k2',
- created_at: new Date(TEST_CREATED_UPDATED),
- updated_at: new Date(TEST_CREATED_UPDATED),
+ created_at: TEST_CREATED_UPDATED,
+ updated_at: TEST_CREATED_UPDATED,
tags: [],
limits: [],
},
diff --git a/frontend/src/container/ListAlertRules/__test__/utils.test.ts b/frontend/src/container/ListAlertRules/__test__/utils.test.ts
index 07a1e67bb0..73bcfb3b72 100644
--- a/frontend/src/container/ListAlertRules/__test__/utils.test.ts
+++ b/frontend/src/container/ListAlertRules/__test__/utils.test.ts
@@ -13,9 +13,9 @@ describe('filterAlerts', () => {
const mockAlertBase: Partial<RuletypesRuleDTO> = {
state: 'active' as RuletypesAlertStateDTO,
disabled: false,
- createdAt: new Date('2024-01-01T00:00:00Z'),
+ createdAt: '2024-01-01T00:00:00Z',
createdBy: 'test-user',
- updatedAt: new Date('2024-01-01T00:00:00Z'),
+ updatedAt: '2024-01-01T00:00:00Z',
updatedBy: 'test-user',
version: '1',
condition: {
diff --git a/frontend/src/container/MembersSettings/__tests__/MembersSettings.integration.test.tsx b/frontend/src/container/MembersSettings/__tests__/MembersSettings.integration.test.tsx
index d26390fc8b..0fd37add04 100644
--- a/frontend/src/container/MembersSettings/__tests__/MembersSettings.integration.test.tsx
+++ b/frontend/src/container/MembersSettings/__tests__/MembersSettings.integration.test.tsx
@@ -20,7 +20,7 @@ const mockUsers: TypesUserDTO[] = [
displayName: 'Alice Smith',
status: 'active',
- createdAt: new Date('2024-01-01T00:00:00.000Z'),
+ createdAt: '2024-01-01T00:00:00.000Z',
orgId: 'org-1',
},
{
@@ -28,7 +28,7 @@ const mockUsers: TypesUserDTO[] = [
displayName: 'Bob Jones',
status: 'active',
- createdAt: new Date('2024-01-02T00:00:00.000Z'),
+ createdAt: '2024-01-02T00:00:00.000Z',
orgId: 'org-1',
},
{
@@ -36,7 +36,7 @@ const mockUsers: TypesUserDTO[] = [
displayName: '',
status: 'pending_invite',
- createdAt: new Date('2024-01-03T00:00:00.000Z'),
+ createdAt: '2024-01-03T00:00:00.000Z',
orgId: 'org-1',
},
{
@@ -44,7 +44,7 @@ const mockUsers: TypesUserDTO[] = [
displayName: 'Dave Deleted',
status: 'deleted',
- createdAt: new Date('2024-01-04T00:00:00.000Z'),
+ createdAt: '2024-01-04T00:00:00.000Z',
orgId: 'org-1',
},
];
diff --git a/frontend/src/container/PlannedDowntime/PlannedDowntime.tsx b/frontend/src/container/PlannedDowntime/PlannedDowntime.tsx
index 92ffe792b9..8d5ce9d086 100644
--- a/frontend/src/container/PlannedDowntime/PlannedDowntime.tsx
+++ b/frontend/src/container/PlannedDowntime/PlannedDowntime.tsx
@@ -24,7 +24,7 @@ import { PlannedDowntimeDeleteModal } from './PlannedDowntimeDeleteModal';
import { PlannedDowntimeForm } from './PlannedDowntimeForm';
import { PlannedDowntimeList } from './PlannedDowntimeList';
import {
- defautlInitialValues,
+ defaultInitialValues,
deleteDowntimeHandler,
} from './PlannedDowntimeutils';
@@ -48,9 +48,7 @@ export function PlannedDowntime(): JSX.Element {
const urlQuery = useUrlQuery();
const [initialValues, setInitialValues] =
- useState<Partial<RuletypesPlannedMaintenanceDTO & { editMode: boolean }>>(
- defautlInitialValues,
- );
+ useState<Partial<RuletypesPlannedMaintenanceDTO>>(defaultInitialValues);
const downtimeSchedules = useListDowntimeSchedules();
const alertOptions = React.useMemo(
@@ -148,7 +146,7 @@ export function PlannedDowntime(): JSX.Element {
<Button
type="primary"
onClick={(): void => {
- setInitialValues({ ...defautlInitialValues, editMode: false });
+ setInitialValues(defaultInitialValues);
setIsOpen(true);
setEditMode(false);
form.resetFields();
diff --git a/frontend/src/container/PlannedDowntime/PlannedDowntimeForm.tsx b/frontend/src/container/PlannedDowntime/PlannedDowntimeForm.tsx
index 273b84f1c8..b40b4a3bf4 100644
--- a/frontend/src/container/PlannedDowntime/PlannedDowntimeForm.tsx
+++ b/frontend/src/container/PlannedDowntime/PlannedDowntimeForm.tsx
@@ -46,8 +46,6 @@ import { AlertRuleTags } from './PlannedDowntimeList';
import {
getAlertOptionsFromIds,
getDurationInfo,
- getEndTime,
- handleTimeConversion,
isScheduleRecurring,
recurrenceOptions,
recurrenceOptionWithSubmenu,
@@ -64,11 +62,19 @@ const TIME_FORMAT = DATE_TIME_FORMATS.TIME;
const DATE_FORMAT = DATE_TIME_FORMATS.ORDINAL_DATE;
const ORDINAL_FORMAT = DATE_TIME_FORMATS.ORDINAL_ONLY;
+const TZ_OPTIONS: DefaultOptionType[] = ALL_TIME_ZONES.map(
+ (timezone: string) => ({
+ label: timezone,
+ value: timezone,
+ key: timezone,
+ }),
+);
+
interface PlannedDowntimeFormData {
name: string;
- startTime: dayjs.Dayjs | string;
- endTime: dayjs.Dayjs | string;
- recurrence?: RuletypesRecurrenceDTO | null;
+ startTime: dayjs.Dayjs | null;
+ endTime: dayjs.Dayjs | null;
+ recurrence?: RuletypesRecurrenceDTO;
alertRules: DefaultOptionType[];
recurrenceSelect?: RuletypesRecurrenceDTO;
timezone?: string;
@@ -77,11 +83,7 @@ interface PlannedDowntimeFormData {
const customFormat = DATE_TIME_FORMATS.ORDINAL_DATETIME;
interface PlannedDowntimeFormProps {
- initialValues: Partial<
- RuletypesPlannedMaintenanceDTO & {
- editMode: boolean;
- }
- >;
+ initialValues: Partial<RuletypesPlannedMaintenanceDTO>;
alertOptions: DefaultOptionType[];
isError: boolean;
isLoading: boolean;
@@ -89,7 +91,7 @@ interface PlannedDowntimeFormProps {
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
refetchAllSchedules: () => void;
isEditMode: boolean;
- form: FormInstance<any>;
+ form: FormInstance;
}
export function PlannedDowntimeForm(
@@ -107,66 +109,46 @@ export function PlannedDowntimeForm(
form,
} = props;
- const [selectedTags, setSelectedTags] = React.useState<
- DefaultOptionType | DefaultOptionType[]
- >([]);
+ const [selectedTags, setSelectedTags] = React.useState<DefaultOptionType[]>(
+ [],
+ );
const alertRuleFormName = 'alertRules';
const [saveLoading, setSaveLoading] = useState(false);
const [durationUnit, setDurationUnit] = useState<string>(
- getDurationInfo(initialValues.schedule?.recurrence?.duration as string)
- ?.unit || 'm',
+ getDurationInfo(initialValues.schedule?.recurrence?.duration)?.unit || 'm',
);
const [formData, setFormData] = useState<Partial<PlannedDowntimeFormData>>({
timezone: initialValues.schedule?.timezone,
});
- const [recurrenceType, setRecurrenceType] = useState<string | null>(
- (initialValues.schedule?.recurrence?.repeatType as string) ||
+ const [recurrenceType, setRecurrenceType] = useState<string>(
+ initialValues.schedule?.recurrence?.repeatType ||
recurrenceOptions.doesNotRepeat.value,
);
- const timezoneInitialValue = !isEmpty(initialValues.schedule?.timezone)
- ? (initialValues.schedule?.timezone as string)
- : undefined;
-
const { notifications } = useNotifications();
const { showErrorModal } = useErrorModal();
+ const requiredFieldRule = [{ required: true }];
+
const datePickerFooter = (mode: any): any =>
mode === 'time' ? (
<span style={{ color: 'gray' }}>Please select the time</span>
) : null;
- const saveHanlder = useCallback(
+ const saveHandler = useCallback(
async (values: PlannedDowntimeFormData) => {
- const shouldKeepLocalTime = !isEditMode;
const data: RuletypesPostablePlannedMaintenanceDTO = {
alertIds: values.alertRules
.map((alert) => alert.value)
.filter((alert) => alert !== undefined) as string[],
name: values.name,
schedule: {
- startTime: new Date(
- handleTimeConversion(
- values.startTime,
- timezoneInitialValue,
- values.timezone,
- shouldKeepLocalTime,
- ),
- ),
- timezone: values.timezone as string,
- endTime: values.endTime
- ? new Date(
- handleTimeConversion(
- values.endTime,
- timezoneInitialValue,
- values.timezone,
- shouldKeepLocalTime,
- ),
- )
- : undefined,
- recurrence: values.recurrence as RuletypesRecurrenceDTO,
+ startTime: values.startTime?.format(),
+ endTime: values.endTime?.format(),
+ timezone: values.timezone!,
+ recurrence: values.recurrence,
},
};
@@ -198,50 +180,58 @@ export function PlannedDowntimeForm(
notifications,
refetchAllSchedules,
setIsOpen,
- timezoneInitialValue,
showErrorModal,
],
);
const onFinish = async (values: PlannedDowntimeFormData): Promise<void> => {
+ const { recurrence } = values;
const recurrenceData =
- values?.recurrence?.repeatType === recurrenceOptions.doesNotRepeat.value
+ !recurrence ||
+ recurrence.repeatType === recurrenceOptions.doesNotRepeat.value
? undefined
: {
- duration: values.recurrence?.duration
- ? `${values.recurrence?.duration}${durationUnit}`
- : undefined,
- endTime: !isEmpty(values.endTime)
- ? handleTimeConversion(
- values.endTime,
- timezoneInitialValue,
- values.timezone,
- !isEditMode,
- )
- : undefined,
- startTime: handleTimeConversion(
- values.startTime,
- timezoneInitialValue,
- values.timezone,
- !isEditMode,
- ),
- repeatOn: !values.recurrence?.repeatOn?.length
- ? undefined
- : values.recurrence?.repeatOn,
- repeatType: values.recurrence?.repeatType,
+ duration: recurrence.duration
+ ? `${recurrence.duration}${durationUnit}`
+ : '',
+ startTime: values.startTime!.format(),
+ endTime: values.endTime?.format(),
+ repeatOn: recurrence.repeatOn,
+ repeatType: recurrence.repeatType,
};
- const payloadValues = {
+ await saveHandler({
...values,
- recurrence: recurrenceData as RuletypesRecurrenceDTO | undefined,
- };
- await saveHanlder(payloadValues);
+ recurrence: recurrenceData,
+ });
};
- const formValidationRules = [
- {
- required: true,
- },
- ];
+ const handleFormData = (data: Partial<PlannedDowntimeFormData>): void => {
+ const { startTime, endTime, timezone } = data;
+ const update: Partial<PlannedDowntimeFormData> = {};
+
+ // If the set timezone doesn't match, update it.
+ if (
+ startTime &&
+ timezone &&
+ startTime.format() !== startTime.tz(timezone, true).format()
+ ) {
+ update.startTime = startTime.tz(timezone, true);
+ }
+ if (
+ endTime &&
+ timezone &&
+ endTime.format() !== endTime.tz(timezone, true).format()
+ ) {
+ update.endTime = endTime.tz(timezone, true);
+ }
+
+ if (!isEmpty(update)) {
+ data = { ...data, ...update };
+ form.setFieldsValue({ ...update });
+ }
+
+ setFormData(data);
+ };
const handleOk = async (): Promise<void> => {
await form.validateFields().catch(() => {
@@ -249,16 +239,11 @@ export function PlannedDowntimeForm(
});
};
- const handleCancel = (): void => {
- setIsOpen(false);
- };
+ const handleCancel = (): void => setIsOpen(false);
- const handleChange = (
- _value: string,
- options: DefaultOptionType | DefaultOptionType[],
- ): void => {
+ const handleAlertRulesChange: SelectProps['onChange'] = (_value, options) => {
form.setFieldValue(alertRuleFormName, options);
- setSelectedTags(options);
+ setSelectedTags(Array.isArray(options) ? options : [options]);
};
const noTagRenderer: SelectProps['tagRender'] = () => <></>;
@@ -267,113 +252,51 @@ export function PlannedDowntimeForm(
if (!removedTag) {
return;
}
- const newTags = selectedTags.filter(
- (tag: DefaultOptionType) => tag.value !== removedTag,
- );
+ const newTags = selectedTags.filter((tag) => tag.value !== removedTag);
form.setFieldValue(alertRuleFormName, newTags);
setSelectedTags(newTags);
};
- const formatedInitialValues = useMemo(() => {
- const formData: PlannedDowntimeFormData = {
+ const formattedInitialValues = useMemo((): PlannedDowntimeFormData => {
+ const { schedule } = initialValues;
+ const startTime = schedule?.recurrence?.startTime || schedule?.startTime;
+ const endTime = schedule?.recurrence?.endTime || schedule?.endTime;
+
+ return {
name: defaultTo(initialValues.name, ''),
alertRules: getAlertOptionsFromIds(
initialValues.alertIds || [],
alertOptions,
),
- endTime: getEndTime(initialValues) ? dayjs(getEndTime(initialValues)) : '',
- startTime: initialValues.schedule?.startTime
- ? dayjs(initialValues.schedule?.startTime)
- : '',
+ startTime: startTime ? dayjs(startTime).tz(schedule.timezone) : null,
+ endTime: endTime ? dayjs(endTime).tz(schedule.timezone) : null,
recurrence: {
- ...initialValues.schedule?.recurrence,
- repeatType: (!isScheduleRecurring(initialValues?.schedule)
+ ...schedule?.recurrence,
+ repeatType: !isScheduleRecurring(schedule)
? recurrenceOptions.doesNotRepeat.value
- : initialValues.schedule?.recurrence
- ?.repeatType) as RuletypesRecurrenceDTO['repeatType'],
- duration: String(
- getDurationInfo(initialValues.schedule?.recurrence?.duration as string)
- ?.value ?? '',
- ),
+ : schedule?.recurrence?.repeatType,
+ duration: getDurationInfo(schedule?.recurrence?.duration)?.value ?? '',
} as RuletypesRecurrenceDTO,
- timezone: initialValues.schedule?.timezone as string,
+ timezone: schedule?.timezone as string,
};
- return formData;
}, [initialValues, alertOptions]);
useEffect(() => {
- setSelectedTags(formatedInitialValues.alertRules);
- form.setFieldsValue({ ...formatedInitialValues });
- }, [form, formatedInitialValues, initialValues]);
-
- const timeZoneItems: DefaultOptionType[] = ALL_TIME_ZONES.map(
- (timezone: string) => ({
- label: timezone,
- value: timezone,
- key: timezone,
- }),
- );
-
- const getTimezoneFormattedTime = (
- time: string | dayjs.Dayjs,
- timeZone?: string,
- isEditMode?: boolean,
- format?: string,
- ): string => {
- if (!time) {
- return '';
- }
- if (!timeZone) {
- return dayjs(time).format(format);
- }
- return dayjs(time).tz(timeZone, isEditMode).format(format);
- };
+ setSelectedTags(formattedInitialValues.alertRules);
+ form.setFieldsValue({ ...formattedInitialValues });
+ }, [form, formattedInitialValues, initialValues]);
const startTimeText = useMemo((): string => {
- let startTime = formData?.startTime;
- if (recurrenceType !== recurrenceOptions.doesNotRepeat.value) {
- startTime =
- (formData?.recurrence?.startTime
- ? dayjs(formData.recurrence.startTime).toISOString()
- : '') ||
- formData?.startTime ||
- '';
- }
-
+ const startTime = formData.startTime;
if (!startTime) {
return '';
}
- if (formData.timezone) {
- startTime = handleTimeConversion(
- startTime,
- timezoneInitialValue,
- formData?.timezone,
- !isEditMode,
- );
- }
- const daysOfWeek = formData?.recurrence?.repeatOn;
-
- const formattedStartTime = getTimezoneFormattedTime(
- startTime,
- formData.timezone,
- !isEditMode,
- TIME_FORMAT,
- );
-
- const formattedStartDate = getTimezoneFormattedTime(
- startTime,
- formData.timezone,
- !isEditMode,
- DATE_FORMAT,
- );
-
- const ordinalFormat = getTimezoneFormattedTime(
- startTime,
- formData.timezone,
- !isEditMode,
- ORDINAL_FORMAT,
- );
+ const daysOfWeek = formData.recurrence?.repeatOn;
+
+ const formattedStartTime = startTime.format(TIME_FORMAT);
+ const formattedStartDate = startTime.format(DATE_FORMAT);
+ const ordinalFormat = startTime.format(ORDINAL_FORMAT);
const formattedDaysOfWeek = daysOfWeek?.join(', ');
switch (recurrenceType) {
@@ -388,49 +311,18 @@ export function PlannedDowntimeForm(
default:
return `Scheduled for ${formattedStartDate} starting at ${formattedStartTime}.`;
}
- }, [formData, recurrenceType, isEditMode, timezoneInitialValue]);
+ }, [formData, recurrenceType, timezone]);
const endTimeText = useMemo((): string => {
- let endTime = formData?.endTime;
- if (recurrenceType !== recurrenceOptions.doesNotRepeat.value) {
- endTime =
- (formData?.recurrence?.endTime
- ? dayjs(formData.recurrence.endTime).toISOString()
- : '') || '';
-
- if (!isEditMode && !endTime) {
- endTime = formData?.endTime || '';
- }
- }
-
+ const endTime = formData.endTime;
if (!endTime) {
return '';
}
- if (formData.timezone) {
- endTime = handleTimeConversion(
- endTime,
- timezoneInitialValue,
- formData?.timezone,
- !isEditMode,
- );
- }
-
- const formattedEndTime = getTimezoneFormattedTime(
- endTime,
- formData.timezone,
- !isEditMode,
- TIME_FORMAT,
- );
-
- const formattedEndDate = getTimezoneFormattedTime(
- endTime,
- formData.timezone,
- !isEditMode,
- DATE_FORMAT,
- );
+ const formattedEndTime = endTime.format(TIME_FORMAT);
+ const formattedEndDate = endTime.format(DATE_FORMAT);
return `Scheduled to end maintenance on ${formattedEndDate} at ${formattedEndTime}.`;
- }, [formData, recurrenceType, isEditMode, timezoneInitialValue]);
+ }, [formData, recurrenceType, timezone]);
return (
<Modal
@@ -446,33 +338,28 @@ export function PlannedDowntimeForm(
footer={null}
>
<Form<PlannedDowntimeFormData>
- name={initialValues.editMode ? 'edit-form' : 'create-form'}
+ name={isEditMode ? 'edit-form' : 'create-form'}
form={form}
layout="vertical"
className="createForm"
onFinish={onFinish}
onValuesChange={(): void => {
setRecurrenceType(form.getFieldValue('recurrence')?.repeatType as string);
- setFormData(form.getFieldsValue());
+ handleFormData(form.getFieldsValue());
}}
autoComplete="off"
>
- <Form.Item label="Name" name="name" rules={formValidationRules}>
+ <Form.Item label="Name" name="name" rules={requiredFieldRule}>
<Input placeholder="e.g. Upgrade downtime" />
</Form.Item>
<Form.Item
label="Starts from"
name="startTime"
- rules={formValidationRules}
+ rules={requiredFieldRule}
className={!isEmpty(startTimeText) ? 'formItemWithBullet' : ''}
- getValueProps={(value): any => ({
- value: value ? dayjs(value).tz(timezoneInitialValue) : undefined,
- })}
>
<DatePicker
- format={(date): string =>
- dayjs(date).tz(timezoneInitialValue).format(customFormat)
- }
+ format={(date) => date.format(customFormat)}
showTime
renderExtraFooter={datePickerFooter}
showNow={false}
@@ -485,7 +372,7 @@ export function PlannedDowntimeForm(
<Form.Item
label="Repeats every"
name={['recurrence', 'repeatType']}
- rules={formValidationRules}
+ rules={requiredFieldRule}
>
<Select
placeholder="Select option..."
@@ -496,7 +383,7 @@ export function PlannedDowntimeForm(
<Form.Item
label="Weekly occurernce"
name={['recurrence', 'repeatOn']}
- rules={formValidationRules}
+ rules={requiredFieldRule}
>
<Select
placeholder="Select option..."
@@ -510,16 +397,14 @@ export function PlannedDowntimeForm(
<Form.Item
label="Duration"
name={['recurrence', 'duration']}
- rules={formValidationRules}
+ rules={requiredFieldRule}
>
<Input
addonAfter={
<Select
defaultValue="m"
value={durationUnit}
- onChange={(value): void => {
- setDurationUnit(value);
- }}
+ onChange={(value): void => setDurationUnit(value)}
>
<Select.Option value="m">Mins</Select.Option>
<Select.Option value="h">Hours</Select.Option>
@@ -533,8 +418,8 @@ export function PlannedDowntimeForm(
/>
</Form.Item>
)}
- <Form.Item label="Timezone" name="timezone" rules={formValidationRules}>
- <Select options={timeZoneItems} placeholder="Select timezone" showSearch />
+ <Form.Item label="Timezone" name="timezone" rules={requiredFieldRule}>
+ <Select options={TZ_OPTIONS} placeholder="Select timezone" showSearch />
</Form.Item>
<Form.Item
label="Ends on"
@@ -546,14 +431,9 @@ export function PlannedDowntimeForm(
},
]}
className={!isEmpty(endTimeText) ? 'formItemWithBullet' : ''}
- getValueProps={(value): any => ({
- value: value ? dayjs(value).tz(timezoneInitialValue) : undefined,
- })}
>
<DatePicker
- format={(date): string =>
- dayjs(date).tz(timezoneInitialValue).format(customFormat)
- }
+ format={(date) => date.format(customFormat)}
showTime
showNow={false}
renderExtraFooter={datePickerFooter}
@@ -584,7 +464,7 @@ export function PlannedDowntimeForm(
status={isError ? 'error' : undefined}
loading={isLoading}
tagRender={noTagRenderer}
- onChange={handleChange}
+ onChange={handleAlertRulesChange}
showSearch
options={alertOptions}
filterOption={(input, option): boolean =>
diff --git a/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx b/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx
index f3647e30aa..88251872f6 100644
--- a/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx
+++ b/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx
@@ -1,4 +1,4 @@
-import { ReactNode, useEffect } from 'react';
+import React, { ReactNode, useEffect } from 'react';
import { UseQueryResult } from 'react-query';
import { Color } from '@signozhq/design-tokens';
import { Collapse, Flex, Space, Table, TableProps, Tag, Tooltip } from 'antd';
@@ -8,7 +8,7 @@ import type {
ListDowntimeSchedules200,
RenderErrorResponseDTO,
RuletypesPlannedMaintenanceDTO,
- RuletypesRecurrenceDTO,
+ RuletypesScheduleDTO,
} from 'api/generated/services/sigNoz.schemas';
import type { ErrorType } from 'api/generatedAPIInstance';
import cx from 'classnames';
@@ -19,12 +19,11 @@ import { CalendarClock, PenLine, Trash2 } from '@signozhq/icons';
import { useAppContext } from 'providers/App/App';
import { USER_ROLES } from 'types/roles';
-import { showErrorNotification } from '../../utils/error';
+import { showErrorNotification } from 'utils/error';
import {
formatDateTime,
getAlertOptionsFromIds,
getDuration,
- getEndTime,
recurrenceInfo,
} from './PlannedDowntimeutils';
@@ -126,29 +125,28 @@ export function CollapseListContent({
created_at,
created_by_name,
created_by_email,
- timeframe,
- repeats,
+ schedule,
updated_at,
updated_by_name,
alertOptions,
- timezone,
}: {
created_at?: string;
created_by_name?: string;
created_by_email?: string;
- timeframe: [string | undefined | null, string | undefined | null];
- repeats?: RuletypesRecurrenceDTO | null;
+ schedule?: RuletypesScheduleDTO;
updated_at?: string;
updated_by_name?: string;
alertOptions?: DefaultOptionType[];
- timezone?: string;
}): JSX.Element {
+ const repeats = schedule?.recurrence;
const renderItems = (title: string, value: ReactNode): JSX.Element => (
<div className="render-item-collapse-list">
<Typography>{title}</Typography>
<div className="render-item-value">{value}</div>
</div>
);
+ const startTime = formatDateTime(schedule?.startTime, schedule?.timezone);
+ const endTime = formatDateTime(schedule?.endTime, schedule?.timezone);
return (
<Flex vertical>
@@ -183,16 +181,20 @@ export function CollapseListContent({
{renderItems(
'Timeframe',
- timeframe[0] || timeframe[1] ? (
- <Typography>{`${formatDateTime(timeframe[0])} ⎯ ${formatDateTime(
- timeframe[1],
- )}`}</Typography>
+ schedule?.startTime ? (
+ <Typography>{`${startTime} ⎯ ${endTime}`}</Typography>
) : (
'-'
),
)}
- {renderItems('Timezone', <Typography>{timezone || '-'}</Typography>)}
- {renderItems('Repeats', <Typography>{recurrenceInfo(repeats)}</Typography>)}
+ {renderItems(
+ 'Timezone',
+ <Typography>{schedule?.timezone || '-'}</Typography>,
+ )}
+ {renderItems(
+ 'Repeats',
+ <Typography>{recurrenceInfo(repeats, schedule?.timezone)}</Typography>,
+ )}
{renderItems(
'Alerts silenced',
alertOptions?.length ? (
@@ -232,22 +234,12 @@ export function CustomCollapseList(
setModalOpen,
handleDeleteDowntime,
setEditMode,
- kind,
} = props;
const scheduleTime = schedule?.startTime
- ? dayjs(schedule.startTime).toISOString()
- : createdAt
- ? dayjs(createdAt).toISOString()
- : '';
- // Combine time and date
- const formattedDateAndTime = `Start time ⎯ ${formatDateTime(
- defaultTo(scheduleTime, ''),
- )} ${schedule?.timezone}`;
- const endTime = getEndTime({
- kind,
- schedule,
- } as Partial<RuletypesPlannedMaintenanceDTO>);
+ ? dayjs(schedule.startTime).tz(schedule.timezone)
+ : createdAt || '';
+ const formattedDateAndTime = `Start time ⎯ ${formatDateTime(scheduleTime)} ${schedule?.timezone}`;
return (
<>
@@ -257,21 +249,16 @@ export function CustomCollapseList(
<HeaderComponent
duration={
schedule?.recurrence?.duration
- ? (schedule?.recurrence?.duration as string)
- : getDuration(
- schedule?.startTime ? dayjs(schedule.startTime).toISOString() : '',
- schedule?.endTime ? dayjs(schedule.endTime).toISOString() : '',
- )
+ ? schedule.recurrence.duration
+ : getDuration(schedule?.startTime || '', schedule?.endTime || '')
}
name={defaultTo(name, '')}
- handleEdit={(): void => {
+ handleEdit={() => {
setInitialValues({ ...props });
setModalOpen(true);
setEditMode(true);
}}
- handleDelete={(): void => {
- handleDeleteDowntime(id ?? '', name || '');
- }}
+ handleDelete={() => handleDeleteDowntime(id ?? '', name || '')}
/>
}
key={id ?? ''}
@@ -279,17 +266,10 @@ export function CustomCollapseList(
<CollapseListContent
created_at={createdAt ? dayjs(createdAt).toISOString() : ''}
created_by_name={defaultTo(createdBy, '')}
- timeframe={[
- schedule?.startTime?.toString(),
- typeof endTime === 'string' ? endTime : endTime?.toString(),
- ]}
- repeats={
- schedule?.recurrence as RuletypesRecurrenceDTO | null | undefined
- }
+ schedule={schedule}
updated_at={updatedAt ? dayjs(updatedAt).toISOString() : ''}
updated_by_name={defaultTo(updatedBy, '')}
alertOptions={alertOptions}
- timezone={defaultTo(schedule?.timezone, '')}
/>
</Panel>
</Collapse>
diff --git a/frontend/src/container/PlannedDowntime/PlannedDowntimeutils.ts b/frontend/src/container/PlannedDowntime/PlannedDowntimeutils.ts
index 09677ca795..4006cc6d24 100644
--- a/frontend/src/container/PlannedDowntime/PlannedDowntimeutils.ts
+++ b/frontend/src/container/PlannedDowntime/PlannedDowntimeutils.ts
@@ -11,8 +11,8 @@ import type {
import type { ErrorType } from 'api/generatedAPIInstance';
import { AxiosError } from 'axios';
import { DATE_TIME_FORMATS } from 'constants/dateTimeFormats';
-import dayjs from 'dayjs';
-import { isEmpty, isEqual } from 'lodash-es';
+import dayjs, { Dayjs } from 'dayjs';
+import { isEmpty } from 'lodash-es';
import APIError from 'types/api/error';
type DateTimeString = string | null | undefined;
@@ -38,14 +38,20 @@ export const getDuration = (
return `${hours} hours`;
};
-export const formatDateTime = (dateTimeString?: string | null): string => {
+export const formatDateTime = (
+ dateTimeString?: string | Dayjs | null,
+ timezone?: string,
+): string => {
if (!dateTimeString) {
return 'N/A';
}
- return dayjs(dateTimeString.slice(0, 19)).format(
- DATE_TIME_FORMATS.MONTH_DATETIME,
- );
+ let dt = dayjs(dateTimeString);
+ if (timezone) {
+ dt = dt.tz(timezone);
+ }
+
+ return dt.format(DATE_TIME_FORMATS.MONTH_DATETIME);
};
export const getAlertOptionsFromIds = (
@@ -61,6 +67,7 @@ export const getAlertOptionsFromIds = (
export const recurrenceInfo = (
recurrence?: RuletypesRecurrenceDTO | null,
+ timezone?: string,
): string => {
if (!recurrence) {
return 'No';
@@ -69,10 +76,10 @@ export const recurrenceInfo = (
const { startTime, duration, repeatOn, repeatType, endTime } = recurrence;
const formattedStartTime = startTime
- ? formatDateTime(dayjs(startTime).toISOString())
+ ? formatDateTime(startTime, timezone)
: '';
const formattedEndTime = endTime
- ? `to ${formatDateTime(dayjs(endTime).toISOString())}`
+ ? `to ${formatDateTime(endTime, timezone)}`
: '';
const weeklyRepeatString = repeatOn ? `on ${repeatOn.join(', ')}` : '';
const durationString = duration ? `- Duration: ${duration}` : '';
@@ -80,9 +87,7 @@ export const recurrenceInfo = (
return `Repeats - ${repeatType} ${weeklyRepeatString} from ${formattedStartTime} ${formattedEndTime} ${durationString}`;
};
-export const defautlInitialValues: Partial<
- RuletypesPlannedMaintenanceDTO & { editMode: boolean }
-> = {
+export const defaultInitialValues: Partial<RuletypesPlannedMaintenanceDTO> = {
name: '',
description: '',
schedule: {
@@ -94,7 +99,6 @@ export const defautlInitialValues: Partial<
alertIds: [],
createdAt: undefined,
createdBy: undefined,
- editMode: false,
};
type DeleteDowntimeScheduleProps = {
@@ -210,75 +214,6 @@ export const recurrenceOptionWithSubmenu: Option[] = [
recurrenceOptions.monthly,
];
-export const getRecurrenceOptionFromValue = (
- value?: string | Option | null,
-): Option | null | undefined => {
- if (!value) {
- return null;
- }
- if (typeof value === 'string') {
- return Object.values(recurrenceOptions).find(
- (option) => option.value === value,
- );
- }
- return value;
-};
-
-export const getEndTime = ({
- kind,
- schedule,
-}: Partial<
- RuletypesPlannedMaintenanceDTO & {
- editMode: boolean;
- }
->): string | dayjs.Dayjs => {
- if (kind === 'fixed') {
- return schedule?.endTime ? dayjs(schedule.endTime).toISOString() : '';
- }
-
- return schedule?.recurrence?.endTime
- ? dayjs(schedule.recurrence.endTime).toISOString()
- : '';
-};
-
export const isScheduleRecurring = (
schedule?: RuletypesPlannedMaintenanceDTO['schedule'] | null,
): boolean => (schedule ? !isEmpty(schedule?.recurrence) : false);
-
-function convertUtcOffsetToTimezoneOffset(offsetMinutes: number): string {
- const sign = offsetMinutes >= 0 ? '+' : '-';
- const absOffset = Math.abs(offsetMinutes);
- const hours = String(Math.floor(absOffset / 60)).padStart(2, '0');
- const minutes = String(absOffset % 60).padStart(2, '0');
- return `${sign}${hours}:${minutes}`;
-}
-
-export function formatWithTimezone(
- dateValue?: string | dayjs.Dayjs,
- timezone?: string,
-): string {
- const parsedDate =
- typeof dateValue === 'string' ? dateValue : dateValue?.format();
-
- // Get the target timezone offset
- const targetOffset = convertUtcOffsetToTimezoneOffset(
- dayjs(dateValue).tz(timezone).utcOffset(),
- );
-
- return `${parsedDate?.substring(0, 19)}${targetOffset}`;
-}
-
-export function handleTimeConversion(
- dateValue: string | dayjs.Dayjs,
- timezoneInit?: string,
- timezone?: string,
- shouldKeepLocalTime?: boolean,
-): string {
- const timezoneChanged = !isEqual(timezoneInit, timezone);
- const initialTime = dayjs(dateValue).tz(timezoneInit);
-
- const formattedTime = formatWithTimezone(initialTime, timezone);
- return timezoneChanged
- ? formattedTime
- : dayjs(dateValue).tz(timezone, shouldKeepLocalTime).format();
-}
diff --git a/frontend/src/container/PlannedDowntime/__test__/PlannedDowntime.test.tsx b/frontend/src/container/PlannedDowntime/__test__/PlannedDowntime.test.tsx
index c6f01084a9..e485c3af7e 100644
--- a/frontend/src/container/PlannedDowntime/__test__/PlannedDowntime.test.tsx
+++ b/frontend/src/container/PlannedDowntime/__test__/PlannedDowntime.test.tsx
@@ -27,10 +27,10 @@ const MOCK_DATE_3 = '2024-01-03';
const MOCK_DOWNTIME_1 = createMockDowntime({
id: '1',
name: MOCK_DOWNTIME_1_NAME,
- createdAt: new Date(MOCK_DATE_1),
- updatedAt: new Date(MOCK_DATE_1),
+ createdAt: MOCK_DATE_1,
+ updatedAt: MOCK_DATE_1,
schedule: buildSchedule({
- startTime: new Date(MOCK_DATE_1),
+ startTime: MOCK_DATE_1,
timezone: 'UTC',
}),
alertIds: [],
@@ -39,10 +39,10 @@ const MOCK_DOWNTIME_1 = createMockDowntime({
const MOCK_DOWNTIME_2 = createMockDowntime({
id: '2',
name: MOCK_DOWNTIME_2_NAME,
- createdAt: new Date(MOCK_DATE_2),
- updatedAt: new Date(MOCK_DATE_2),
+ createdAt: MOCK_DATE_2,
+ updatedAt: MOCK_DATE_2,
schedule: buildSchedule({
- startTime: new Date(MOCK_DATE_2),
+ startTime: MOCK_DATE_2,
timezone: 'UTC',
}),
alertIds: [],
@@ -51,10 +51,10 @@ const MOCK_DOWNTIME_2 = createMockDowntime({
const MOCK_DOWNTIME_3 = createMockDowntime({
id: '3',
name: MOCK_DOWNTIME_3_NAME,
- createdAt: new Date(MOCK_DATE_3),
- updatedAt: new Date(MOCK_DATE_3),
+ createdAt: MOCK_DATE_3,
+ updatedAt: MOCK_DATE_3,
schedule: buildSchedule({
- startTime: new Date(MOCK_DATE_3),
+ startTime: MOCK_DATE_3,
timezone: 'UTC',
}),
alertIds: [],
diff --git a/frontend/src/container/PlannedDowntime/__test__/testUtils.ts b/frontend/src/container/PlannedDowntime/__test__/testUtils.ts
index bb9b62e8dd..611c735e84 100644
--- a/frontend/src/container/PlannedDowntime/__test__/testUtils.ts
+++ b/frontend/src/container/PlannedDowntime/__test__/testUtils.ts
@@ -24,7 +24,7 @@ export const createMockDowntime = (
description: overrides.description ?? '',
schedule: buildSchedule({
timezone: 'UTC',
- startTime: new Date('2024-01-01'),
+ startTime: '2024-01-01',
...overrides.schedule,
}),
alertIds: overrides.alertIds ?? [],
diff --git a/frontend/src/mocks-server/__mockdata__/roles.ts b/frontend/src/mocks-server/__mockdata__/roles.ts
index 70fa7e70b5..dd9b5d51f0 100644
--- a/frontend/src/mocks-server/__mockdata__/roles.ts
+++ b/frontend/src/mocks-server/__mockdata__/roles.ts
@@ -5,8 +5,8 @@ const orgId = '019ba2bb-2fa1-7b24-8159-cfca08617ef9';
export const managedRoles: AuthtypesRoleDTO[] = [
{
id: '019c24aa-2248-756f-9833-984f1ab63819',
- createdAt: new Date('2026-02-03T18:00:55.624356Z'),
- updatedAt: new Date('2026-02-03T18:00:55.624356Z'),
+ createdAt: '2026-02-03T18:00:55.624356Z',
+ updatedAt: '2026-02-03T18:00:55.624356Z',
name: 'signoz-admin',
description:
'Role assigned to users who have full administrative access to SigNoz resources.',
@@ -15,8 +15,8 @@ export const managedRoles: AuthtypesRoleDTO[] = [
},
{
id: '019c24aa-2248-757c-9faf-7b1e899751e0',
- createdAt: new Date('2026-02-03T18:00:55.624359Z'),
- updatedAt: new Date('2026-02-03T18:00:55.624359Z'),
+ createdAt: '2026-02-03T18:00:55.624359Z',
+ updatedAt: '2026-02-03T18:00:55.624359Z',
name: 'signoz-editor',
description:
'Role assigned to users who can create, edit, and manage SigNoz resources but do not have full administrative privileges.',
@@ -25,8 +25,8 @@ export const managedRoles: AuthtypesRoleDTO[] = [
},
{
id: '019c24aa-2248-7585-a129-4188b3473c27',
- createdAt: new Date('2026-02-03T18:00:55.624362Z'),
- updatedAt: new Date('2026-02-03T18:00:55.624362Z'),
+ createdAt: '2026-02-03T18:00:55.624362Z',
+ updatedAt: '2026-02-03T18:00:55.624362Z',
name: 'signoz-viewer',
description:
'Role assigned to users who have read-only access to SigNoz resources.',
@@ -38,8 +38,8 @@ export const managedRoles: AuthtypesRoleDTO[] = [
export const customRoles: AuthtypesRoleDTO[] = [
{
id: '019c24aa-3333-0001-aaaa-111111111111',
- createdAt: new Date('2026-02-10T10:30:00.000Z'),
- updatedAt: new Date('2026-02-12T14:20:00.000Z'),
+ createdAt: '2026-02-10T10:30:00.000Z',
+ updatedAt: '2026-02-12T14:20:00.000Z',
name: 'billing-manager',
description: 'Custom role for managing billing and invoices.',
type: 'custom',
@@ -47,8 +47,8 @@ export const customRoles: AuthtypesRoleDTO[] = [
},
{
id: '019c24aa-3333-0002-bbbb-222222222222',
- createdAt: new Date('2026-02-11T09:00:00.000Z'),
- updatedAt: new Date('2026-02-13T11:45:00.000Z'),
+ createdAt: '2026-02-11T09:00:00.000Z',
+ updatedAt: '2026-02-13T11:45:00.000Z',
name: 'dashboard-creator',
description: 'Custom role allowing users to create and manage dashboards.',
type: 'custom',