mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 05:43:00 +08:00

* Replace icons in dashboard and settings * Replace icons in alerting * Update batch of icons * Implement icons accross various files * Style updates * Search: Fix recent and starred icons * Update styling and details * Replace new icon created by unicons * Fix e2e test, styling * Minor styling updates Co-authored-by: Clarity-89 <homes89@ukr.net>
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { AppNotification, AppNotificationSeverity, AppNotificationTimeout } from 'app/types';
|
|
import { getMessageFromError } from 'app/core/utils/errors';
|
|
|
|
const defaultSuccessNotification = {
|
|
title: '',
|
|
text: '',
|
|
severity: AppNotificationSeverity.Success,
|
|
icon: 'check',
|
|
timeout: AppNotificationTimeout.Success,
|
|
};
|
|
|
|
const defaultWarningNotification = {
|
|
title: '',
|
|
text: '',
|
|
severity: AppNotificationSeverity.Warning,
|
|
icon: 'exclamation-triangle',
|
|
timeout: AppNotificationTimeout.Warning,
|
|
};
|
|
|
|
const defaultErrorNotification = {
|
|
title: '',
|
|
text: '',
|
|
severity: AppNotificationSeverity.Error,
|
|
icon: 'exclamation-triangle',
|
|
timeout: AppNotificationTimeout.Error,
|
|
};
|
|
|
|
export const createSuccessNotification = (title: string, text = ''): AppNotification => ({
|
|
...defaultSuccessNotification,
|
|
title: title,
|
|
text: text,
|
|
id: Date.now(),
|
|
});
|
|
|
|
export const createErrorNotification = (title: string, text = '', component?: React.ReactElement): AppNotification => {
|
|
return {
|
|
...defaultErrorNotification,
|
|
text: getMessageFromError(text),
|
|
title,
|
|
id: Date.now(),
|
|
component,
|
|
};
|
|
};
|
|
|
|
export const createWarningNotification = (title: string, text = ''): AppNotification => ({
|
|
...defaultWarningNotification,
|
|
title: title,
|
|
text: text,
|
|
id: Date.now(),
|
|
});
|