Alerting: Move alerting file to an alerting folder (#110257)

* move alerting.ts to alerting folder

* fix CODEOWNERS

* update betterer

* prettier ✨

* lint

---------

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
Sonia Aguilar
2025-08-28 12:11:19 +00:00
committed by GitHub
co-authored by Gilles De Mey
parent 7b78971455
commit 58e649a956
30 changed files with 68 additions and 35 deletions
+7 -7
View File
@@ -1534,6 +1534,13 @@ exports[`better eslint`] = {
"public/app/features/alerting/unified/rule-list/StateView.tsx:5381": [
[0, 0, 0, "Using localeCompare() can cause performance issues when sorting large datasets. Consider using Intl.Collator for better performance when sorting arrays, or add an eslint-disable comment if sorting a small, known dataset.", "0"]
],
"public/app/features/alerting/unified/types/alerting.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/features/alerting/unified/types/receiver-form.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
@@ -4064,13 +4071,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/types/alerting.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
],
"public/app/types/dashboard.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
-1
View File
@@ -969,7 +969,6 @@ playwright.storybook.config.ts @grafana/grafana-frontend-platform
/public/app/routes/ @grafana/grafana-search-navigate-organise
/public/app/store/ @grafana/grafana-frontend-platform
/public/app/types/ @grafana/grafana-frontend-platform
/public/app/types/alerting.ts @grafana/alerting-frontend
/public/app/types/unified-alerting-dto.ts @grafana/alerting-frontend
/public/app/types/unified-alerting.ts @grafana/alerting-frontend
/public/dashboards/ @grafana/dashboards-squad
@@ -1,5 +1,10 @@
import { dateTime } from '@grafana/data';
import { AlertRuleDTO, AlertRulesState, NotificationChannelState, NotifierDTO } from 'app/types/alerting';
import {
AlertRuleDTO,
AlertRulesState,
NotificationChannelState,
NotifierDTO,
} from 'app/features/alerting/unified/types/alerting';
import { reducerTester } from '../../../../test/core/redux/reducerTester';
@@ -8,7 +8,7 @@ import {
NotificationChannelOption,
NotificationChannelState,
NotifierDTO,
} from 'app/types/alerting';
} from 'app/features/alerting/unified/types/alerting';
import unifiedAlertingReducer from '../unified/state/reducers';
@@ -1,4 +1,4 @@
import { AlertRulesState } from 'app/types/alerting';
import { AlertRulesState } from 'app/features/alerting/unified/types/alerting';
import { StoreState } from 'app/types/store';
import { getAlertRuleItems, getSearchQuery } from './selectors';
@@ -1,4 +1,4 @@
import { AlertRule, AlertRulesState, NotificationChannelState } from 'app/types/alerting';
import { AlertRule, AlertRulesState, NotificationChannelState } from 'app/features/alerting/unified/types/alerting';
import { StoreState } from 'app/types/store';
export const getSearchQuery = (state: AlertRulesState) => state.searchQuery;
@@ -1,8 +1,12 @@
import { isEmpty } from 'lodash';
import {
NotificationChannelOption,
NotifierDTO,
ReceiversStateDTO,
} from 'app/features/alerting/unified/types/alerting';
import { encodeMatcher } from 'app/features/alerting/unified/utils/matchers';
import { dispatch } from 'app/store/store';
import { NotificationChannelOption, NotifierDTO, ReceiversStateDTO } from 'app/types/alerting';
import {
AlertManagerCortexConfig,
@@ -1,4 +1,4 @@
import { ReceiversStateDTO } from 'app/types/alerting';
import { ReceiversStateDTO } from 'app/features/alerting/unified/types/alerting';
import { contactPointsStateDtoToModel, getIntegrationType, parseIntegrationName } from './grafana';
@@ -1,7 +1,7 @@
import { lastValueFrom } from 'rxjs';
import { getBackendSrv } from '@grafana/runtime';
import { ContactPointsState, ReceiverState, ReceiversStateDTO } from 'app/types/alerting';
import { ContactPointsState, ReceiverState, ReceiversStateDTO } from 'app/features/alerting/unified/types/alerting';
import { getDatasourceAPIUid } from '../utils/datasource';
@@ -1,6 +1,6 @@
/** @deprecated To be deleted - use alertingApiServer API instead */
import { ContactPointsState } from 'app/types/alerting';
import { ContactPointsState } from 'app/features/alerting/unified/types/alerting';
import { CONTACT_POINTS_STATE_INTERVAL_MS } from '../utils/constants';
@@ -10,8 +10,8 @@ import { ContactPointHeader } from 'app/features/alerting/unified/components/con
import { useDeleteContactPointModal } from 'app/features/alerting/unified/components/contact-points/components/Modals';
import { useDeleteContactPoint } from 'app/features/alerting/unified/components/contact-points/useContactPoints';
import { useAlertmanager } from 'app/features/alerting/unified/state/AlertmanagerContext';
import { GrafanaNotifierType, NotifierStatus } from 'app/features/alerting/unified/types/alerting';
import { receiverTypeNames } from 'app/plugins/datasource/alertmanager/consts';
import { GrafanaNotifierType, NotifierStatus } from 'app/types/alerting';
import { INTEGRATION_ICONS } from '../../types/contact-points';
import { MetaText } from '../MetaText';
@@ -2,6 +2,7 @@ import { difference, groupBy, take, trim, upperFirst } from 'lodash';
import { ReactNode } from 'react';
import { t } from '@grafana/i18n';
import { NotifierDTO, NotifierStatus, ReceiversStateDTO } from 'app/features/alerting/unified/types/alerting';
import { canAdminEntity, shouldUseK8sApi } from 'app/features/alerting/unified/utils/k8s/utils';
import {
AlertManagerCortexConfig,
@@ -11,7 +12,6 @@ import {
Receiver,
Route,
} from 'app/plugins/datasource/alertmanager/types';
import { NotifierDTO, NotifierStatus, ReceiversStateDTO } from 'app/types/alerting';
import { OnCallIntegrationDTO } from '../../api/onCallApi';
import { computeInheritedTree } from '../../utils/notification-policies';
@@ -5,13 +5,13 @@ import { Route, Routes } from 'react-router-dom-v5-compat';
import { render } from 'test/test-utils';
import { contextSrv } from 'app/core/core';
import { ReceiversState } from 'app/features/alerting/unified/types/alerting';
import {
AlertmanagerGroup,
MatcherOperator,
ObjectMatcher,
RouteWithID,
} from 'app/plugins/datasource/alertmanager/types';
import { ReceiversState } from 'app/types/alerting';
import { useAlertmanagerAbilities } from '../../hooks/useAbilities';
import { mockReceiversState } from '../../mocks';
@@ -25,6 +25,7 @@ import ConditionalWrap from 'app/features/alerting/unified/components/Conditiona
import MoreButton from 'app/features/alerting/unified/components/MoreButton';
import { PrimaryText } from 'app/features/alerting/unified/components/common/TextVariants';
import { ContactPointReceiverSummary } from 'app/features/alerting/unified/components/contact-points/ContactPoint';
import { ReceiversState } from 'app/features/alerting/unified/types/alerting';
import {
AlertmanagerGroup,
MatcherOperator,
@@ -32,7 +33,6 @@ import {
Receiver,
RouteWithID,
} from 'app/plugins/datasource/alertmanager/types';
import { ReceiversState } from 'app/types/alerting';
import { AlertmanagerAction, useAlertmanagerAbilities, useAlertmanagerAbility } from '../../hooks/useAbilities';
import { getAmMatcherFormatter } from '../../utils/alertmanager';
@@ -2,7 +2,11 @@ import * as React from 'react';
import { DeepMap, FieldError, FieldErrors, useFormContext } from 'react-hook-form';
import { Field, SecretInput } from '@grafana/ui';
import { NotificationChannelOption, NotificationChannelSecureFields, OptionMeta } from 'app/types/alerting';
import {
NotificationChannelOption,
NotificationChannelSecureFields,
OptionMeta,
} from 'app/features/alerting/unified/types/alerting';
import {
ChannelValues,
@@ -7,7 +7,7 @@ import { Controller, FieldErrors, useFormContext } from 'react-hook-form';
import { GrafanaTheme2, SelectableValue } from '@grafana/data';
import { Trans, t } from '@grafana/i18n';
import { Alert, Button, Field, Select, Stack, Text, useStyles2 } from '@grafana/ui';
import { NotificationChannelOption } from 'app/types/alerting';
import { NotificationChannelOption } from 'app/features/alerting/unified/types/alerting';
import { useUnifiedAlertingSelector } from '../../../hooks/useUnifiedAlertingSelector';
import {
@@ -14,7 +14,11 @@ import {
TextArea,
useStyles2,
} from '@grafana/ui';
import { NotificationChannelOption, NotificationChannelSecureFields, OptionMeta } from 'app/types/alerting';
import {
NotificationChannelOption,
NotificationChannelSecureFields,
OptionMeta,
} from 'app/features/alerting/unified/types/alerting';
import { KeyValueMapInput } from './KeyValueMapInput';
import { StringArrayInput } from './StringArrayInput';
@@ -3,7 +3,11 @@ import { DeepMap, FieldError, useFormContext } from 'react-hook-form';
import { Trans, t } from '@grafana/i18n';
import { Button, useStyles2 } from '@grafana/ui';
import { useControlledFieldArray } from 'app/features/alerting/unified/hooks/useControlledFieldArray';
import { NotificationChannelOption, NotificationChannelSecureFields, OptionMeta } from 'app/types/alerting';
import {
NotificationChannelOption,
NotificationChannelSecureFields,
OptionMeta,
} from 'app/features/alerting/unified/types/alerting';
import { ActionIcon } from '../../../rules/ActionIcon';
import { CollapsibleSection } from '../CollapsibleSection';
@@ -3,7 +3,11 @@ import { DeepMap, FieldError, useFormContext } from 'react-hook-form';
import { Trans, t } from '@grafana/i18n';
import { Button, useStyles2 } from '@grafana/ui';
import { NotificationChannelOption, NotificationChannelSecureFields, OptionMeta } from 'app/types/alerting';
import {
NotificationChannelOption,
NotificationChannelSecureFields,
OptionMeta,
} from 'app/features/alerting/unified/types/alerting';
import { ActionIcon } from '../../../rules/ActionIcon';
@@ -6,11 +6,11 @@ import { setupMswServer } from 'app/features/alerting/unified/mockApi';
import { grantUserPermissions } from 'app/features/alerting/unified/mocks';
import { getAlertmanagerConfig } from 'app/features/alerting/unified/mocks/server/entities/alertmanagers';
import { AlertmanagerProvider } from 'app/features/alerting/unified/state/AlertmanagerContext';
import { NotificationChannelOption } from 'app/features/alerting/unified/types/alerting';
import { GRAFANA_RULES_SOURCE_NAME } from 'app/features/alerting/unified/utils/datasource';
import { PROVENANCE_NONE } from 'app/features/alerting/unified/utils/k8s/constants';
import { DEFAULT_TEMPLATES } from 'app/features/alerting/unified/utils/template-constants';
import { AccessControlAction } from 'app/types/accessControl';
import { NotificationChannelOption } from 'app/types/alerting';
import { TemplatesPicker, getTemplateOptions } from './TemplateSelector';
import { parseTemplates } from './utils';
@@ -28,7 +28,7 @@ import {
useNotificationTemplates,
} from 'app/features/alerting/unified/components/contact-points/useNotificationTemplates';
import { useAlertmanager } from 'app/features/alerting/unified/state/AlertmanagerContext';
import { NotificationChannelOption } from 'app/types/alerting';
import { NotificationChannelOption } from 'app/features/alerting/unified/types/alerting';
import { defaultPayloadString } from '../../TemplateForm';
@@ -1,6 +1,6 @@
import { ReactElement } from 'react';
import { NotifierDTO } from 'app/types/alerting';
import { NotifierDTO } from 'app/features/alerting/unified/types/alerting';
export interface NotifierMetadata {
enabled: boolean;
@@ -5,8 +5,8 @@ import { SelectableValue } from '@grafana/data';
import { t } from '@grafana/i18n';
import { isFetchError } from '@grafana/runtime';
import { Badge } from '@grafana/ui';
import { NotifierDTO } from 'app/features/alerting/unified/types/alerting';
import { getIrmIfPresentOrOnCallPluginId } from 'app/features/alerting/unified/utils/config';
import { NotifierDTO } from 'app/types/alerting';
import { useAppNotification } from '../../../../../../../core/copy/appNotification';
import { Receiver } from '../../../../../../../plugins/datasource/alertmanager/types';
@@ -1,4 +1,4 @@
import { GrafanaNotifierType, NotifierDTO } from 'app/types/alerting';
import { GrafanaNotifierType, NotifierDTO } from 'app/features/alerting/unified/types/alerting';
export const grafanaAlertNotifiers: Record<GrafanaNotifierType, NotifierDTO> = {
dingding: {
@@ -12,6 +12,7 @@ import {
import { DataQuery, defaultDashboard } from '@grafana/schema';
import { contextSrv } from 'app/core/services/context_srv';
import { MOCK_GRAFANA_ALERT_RULE_TITLE } from 'app/features/alerting/unified/mocks/server/handlers/grafanaRuler';
import { NotifiersState, ReceiversState } from 'app/features/alerting/unified/types/alerting';
import { ExpressionQuery, ExpressionQueryType, ReducerMode } from 'app/features/expressions/types';
import {
AlertManagerCortexConfig,
@@ -26,7 +27,6 @@ import {
} from 'app/plugins/datasource/alertmanager/types';
import { configureStore } from 'app/store/configureStore';
import { AccessControlAction } from 'app/types/accessControl';
import { NotifiersState, ReceiversState } from 'app/types/alerting';
import { DashboardDTO } from 'app/types/dashboard';
import { FolderDTO } from 'app/types/folders';
import { StoreState } from 'app/types/store';
@@ -1,7 +1,7 @@
import * as React from 'react';
import { CloudNotifierType, NotifierType } from 'app/features/alerting/unified/types/alerting';
import { GrafanaManagedReceiverConfig } from 'app/plugins/datasource/alertmanager/types';
import { CloudNotifierType, NotifierType } from 'app/types/alerting';
import { ControlledField } from '../hooks/useControlledFieldArray';
@@ -1,5 +1,9 @@
import { config } from '@grafana/runtime';
import { CloudNotifierType, NotificationChannelOption, NotifierDTO } from 'app/types/alerting';
import {
CloudNotifierType,
NotificationChannelOption,
NotifierDTO,
} from 'app/features/alerting/unified/types/alerting';
import { option } from './notifier-types';
@@ -1,4 +1,4 @@
import { NotificationChannelOption } from 'app/types/alerting';
import { NotificationChannelOption } from 'app/features/alerting/unified/types/alerting';
export function option(
propertyName: string,
@@ -1,5 +1,11 @@
import { has, isArray, isNil, omitBy, pickBy } from 'lodash';
import {
CloudNotifierType,
NotificationChannelOption,
NotifierDTO,
NotifierType,
} from 'app/features/alerting/unified/types/alerting';
import {
AlertmanagerReceiver,
GrafanaManagedContactPoint,
@@ -7,7 +13,6 @@ import {
GrafanaManagedReceiverSecureFields,
Receiver,
} from 'app/plugins/datasource/alertmanager/types';
import { CloudNotifierType, NotificationChannelOption, NotifierDTO, NotifierType } from 'app/types/alerting';
import {
ChannelValues,