Compare commits

..

2 Commits

Author SHA1 Message Date
Ishan Uniyal
05de988a67 fix: updated testcase 2026-03-09 09:37:22 +05:30
Ishan Uniyal
53ed4b47b8 fix: updated fallback color 2026-03-09 09:12:49 +05:30
6 changed files with 14 additions and 20 deletions

View File

@@ -4,8 +4,8 @@ import { getColorsForSeverityLabels, isRedLike } from '../utils';
describe('getColorsForSeverityLabels', () => {
it('should return slate for blank labels', () => {
expect(getColorsForSeverityLabels('', 0)).toBe(Color.BG_SLATE_300);
expect(getColorsForSeverityLabels(' ', 0)).toBe(Color.BG_SLATE_300);
expect(getColorsForSeverityLabels('', 0)).toBe(Color.BG_VANILLA_400);
expect(getColorsForSeverityLabels(' ', 0)).toBe(Color.BG_VANILLA_400);
});
it('should return correct colors for known severity variants', () => {

View File

@@ -79,7 +79,7 @@ export function getColorsForSeverityLabels(
const trimmed = label.trim();
if (!trimmed) {
return Color.BG_SLATE_300;
return Color.BG_VANILLA_400; // Default color for empty labels
}
const variantColor = SEVERITY_VARIANT_COLORS[trimmed];
@@ -119,6 +119,6 @@ export function getColorsForSeverityLabels(
return (
SAFE_FALLBACK_COLORS[index % SAFE_FALLBACK_COLORS.length] ||
Color.BG_SLATE_400
Color.BG_VANILLA_400
);
}

View File

@@ -33,8 +33,6 @@ import { ALL_TIME_ZONES } from 'utils/timeZoneUtil';
import 'dayjs/locale/en';
import { SOMETHING_WENT_WRONG } from '../../constants/api';
import { showErrorNotification } from '../../utils/error';
import { AlertRuleTags } from './PlannedDowntimeList';
import {
createEditDowntimeSchedule,
@@ -177,14 +175,14 @@ export function PlannedDowntimeForm(
} else {
notifications.error({
message: 'Error',
description:
typeof response.error === 'string'
? response.error
: response.error?.message || SOMETHING_WENT_WRONG,
description: response.error || 'unexpected_error',
});
}
} catch (e: unknown) {
showErrorNotification(notifications, e as Error);
} catch (e) {
notifications.error({
message: 'Error',
description: 'unexpected_error',
});
}
setSaveLoading(false);
},

View File

@@ -25,7 +25,6 @@ import { CalendarClock, PenLine, Trash2 } from 'lucide-react';
import { useAppContext } from 'providers/App/App';
import { USER_ROLES } from 'types/roles';
import { showErrorNotification } from '../../utils/error';
import {
formatDateTime,
getAlertOptionsFromIds,
@@ -360,7 +359,7 @@ export function PlannedDowntimeList({
useEffect(() => {
if (downtimeSchedules.isError) {
showErrorNotification(notifications, downtimeSchedules.error);
notifications.error(downtimeSchedules.error);
}
}, [downtimeSchedules.error, downtimeSchedules.isError, notifications]);

View File

@@ -137,10 +137,7 @@ export const deleteDowntimeHandler = ({
export const createEditDowntimeSchedule = async (
props: DowntimeScheduleUpdatePayload,
): Promise<
| SuccessResponse<PayloadProps>
| ErrorResponse<{ code: string; message: string } | string>
> => {
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
if (props.id) {
return updateDowntimeSchedule({ ...props });
}

View File

@@ -3,10 +3,10 @@ import { ErrorStatusCode, SuccessStatusCode } from 'types/common';
export type ApiResponse<T> = { data: T };
export interface ErrorResponse<ErrorObject = string> {
export interface ErrorResponse {
statusCode: ErrorStatusCode;
payload: null;
error: ErrorObject;
error: string;
message: string | null;
body?: string | null;
}