Alerting: Promote the policy matching functions to stable (#112931)
This commit is contained in:
@@ -1604,11 +1604,6 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"public/app/features/alerting/unified/components/contact-points/utils.ts": {
|
||||
"no-restricted-syntax": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"public/app/features/alerting/unified/components/create-folder/CreateNewFolder.tsx": {
|
||||
"no-restricted-syntax": {
|
||||
"count": 1
|
||||
|
||||
@@ -11,8 +11,32 @@ export { AlertLabels } from './grafana/rules/components/labels/AlertLabels';
|
||||
export { AlertLabel } from './grafana/rules/components/labels/AlertLabel';
|
||||
// keep label utils internal to the app for now
|
||||
|
||||
/**
|
||||
* Notification policies and label matching
|
||||
*/
|
||||
export {
|
||||
useMatchInstancesToRouteTrees,
|
||||
matchInstancesToRouteTrees,
|
||||
type RouteMatch,
|
||||
type InstanceMatchResult,
|
||||
} from './grafana/notificationPolicies/hooks/useMatchPolicies';
|
||||
|
||||
export {
|
||||
type TreeMatch,
|
||||
type RouteMatchResult,
|
||||
matchInstancesToRoute,
|
||||
findMatchingRoutes,
|
||||
getInheritedProperties,
|
||||
computeInheritedTree,
|
||||
} from './grafana/notificationPolicies/utils';
|
||||
|
||||
export { USER_DEFINED_TREE_NAME } from './grafana/notificationPolicies/consts';
|
||||
export * from './grafana/notificationPolicies/types';
|
||||
|
||||
/**
|
||||
* Labels and matchers
|
||||
*/
|
||||
export { type LabelMatcher, type Label } from './grafana/matchers/types';
|
||||
|
||||
// Utilities
|
||||
export { base64UrlEncode } from './grafana/api/util';
|
||||
|
||||
// This is a dummy export so typescript doesn't error importing an "empty module"
|
||||
export const index = {};
|
||||
|
||||
@@ -8,24 +8,6 @@ export { useListContactPoints } from './grafana/contactPoints/hooks/v0alpha1/use
|
||||
export { ContactPointSelector } from './grafana/contactPoints/components/ContactPointSelector/ContactPointSelector';
|
||||
export { getContactPointDescription } from './grafana/contactPoints/utils';
|
||||
|
||||
// Notification Policies
|
||||
export {
|
||||
useMatchInstancesToRouteTrees,
|
||||
matchInstancesToRouteTrees,
|
||||
type RouteMatch,
|
||||
type InstanceMatchResult,
|
||||
} from './grafana/notificationPolicies/hooks/useMatchPolicies';
|
||||
export {
|
||||
type TreeMatch,
|
||||
type RouteMatchResult,
|
||||
matchInstancesToRoute,
|
||||
findMatchingRoutes,
|
||||
getInheritedProperties,
|
||||
computeInheritedTree,
|
||||
} from './grafana/notificationPolicies/utils';
|
||||
export { USER_DEFINED_TREE_NAME } from './grafana/notificationPolicies/consts';
|
||||
export * from './grafana/notificationPolicies/types';
|
||||
|
||||
// Rules
|
||||
export { StateText } from './grafana/rules/components/state/StateText';
|
||||
export { StateIcon } from './grafana/rules/components/state/StateIcon';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { difference, groupBy, take, trim, upperFirst } from 'lodash';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
import { computeInheritedTree } from '@grafana/alerting/unstable';
|
||||
import { computeInheritedTree } from '@grafana/alerting';
|
||||
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';
|
||||
@@ -23,6 +23,7 @@ import { ReceiverPluginMetadata, getOnCallMetadata } from '../receivers/grafanaA
|
||||
import { RECEIVER_META_KEY, RECEIVER_PLUGIN_META_KEY, RECEIVER_STATUS_KEY } from './constants';
|
||||
|
||||
const AUTOGENERATED_RECEIVER_POLICY_MATCHER_KEY = '__grafana_receiver__';
|
||||
const collator = new Intl.Collator();
|
||||
|
||||
// TODO we should really add some type information to these receiver settings...
|
||||
export function getReceiverDescription(receiver: ReceiverConfigWithMetadata): ReactNode | undefined {
|
||||
@@ -168,7 +169,7 @@ export function enhanceContactPointsWithMetadata({
|
||||
};
|
||||
});
|
||||
|
||||
return enhanced.sort((a, b) => a.name.localeCompare(b.name));
|
||||
return enhanced.sort((a, b) => collator.compare(a.name, b.name));
|
||||
}
|
||||
|
||||
function getContactPointIdentifier(contactPoint: Receiver): string {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { defaults } from 'lodash';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { useAsyncFn } from 'react-use';
|
||||
|
||||
import { computeInheritedTree } from '@grafana/alerting/unstable';
|
||||
import { computeInheritedTree } from '@grafana/alerting';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { Alert, Button, Stack } from '@grafana/ui';
|
||||
import { useAppNotification } from 'app/core/copy/appNotification';
|
||||
|
||||
@@ -5,8 +5,7 @@ import * as React from 'react';
|
||||
import { FC, Fragment, ReactNode, useState } from 'react';
|
||||
import { useToggle } from 'react-use';
|
||||
|
||||
import { InheritableProperties } from '@grafana/alerting/internal';
|
||||
import { AlertLabel, getInheritedProperties } from '@grafana/alerting/unstable';
|
||||
import { AlertLabel, getInheritedProperties } from '@grafana/alerting';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import {
|
||||
@@ -55,6 +54,8 @@ import { TimingOptions } from './timingOptions';
|
||||
|
||||
const POLICIES_PER_PAGE = 20;
|
||||
|
||||
type InheritableProperties = ReturnType<typeof getInheritedProperties>;
|
||||
|
||||
interface PolicyComponentProps {
|
||||
receivers?: Receiver[];
|
||||
contactPointsState?: ReceiversState;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
import { LabelMatcher, RouteWithID } from '@grafana/alerting/unstable';
|
||||
import { LabelMatcher, RouteWithID } from '@grafana/alerting';
|
||||
|
||||
import { JourneyPolicyCard } from './JourneyPolicyCard';
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { css } from '@emotion/css';
|
||||
|
||||
import { RouteWithID } from '@grafana/alerting/unstable';
|
||||
import { RouteWithID } from '@grafana/alerting';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Icon, Stack, Text, Tooltip, useStyles2 } from '@grafana/ui';
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { Fragment, useState } from 'react';
|
||||
|
||||
import { AlertLabel, RouteMatchResult, RouteWithID } from '@grafana/alerting/unstable';
|
||||
import { AlertLabel, RouteMatchResult, RouteWithID } from '@grafana/alerting';
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Button, Drawer, Text, TextLink } from '@grafana/ui';
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { css } from '@emotion/css';
|
||||
|
||||
import { AlertLabels, RouteMatchResult, RouteWithID } from '@grafana/alerting/unstable';
|
||||
import { AlertLabels, RouteMatchResult, RouteWithID } from '@grafana/alerting';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { Trans } from '@grafana/i18n';
|
||||
import { Text, useStyles2 } from '@grafana/ui';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { InstanceMatchResult, matchInstancesToRoute } from '@grafana/alerting/unstable';
|
||||
import { InstanceMatchResult, matchInstancesToRoute } from '@grafana/alerting';
|
||||
|
||||
import { AlertmanagerGroup, RouteWithID } from '../../../plugins/datasource/alertmanager/types';
|
||||
import { Labels } from '../../../types/unified-alerting-dto';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { findMatchingRoutes } from '@grafana/alerting/unstable';
|
||||
import { findMatchingRoutes } from '@grafana/alerting';
|
||||
import { AlertmanagerGroup, Route, RouteWithID } from 'app/plugins/datasource/alertmanager/types';
|
||||
|
||||
import { normalizeMatchers, unquoteWithUnescape } from './matchers';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Factory } from 'fishery';
|
||||
|
||||
import { RouteWithID as AlertingRouteWithID } from '@grafana/alerting';
|
||||
import { RouteFactory } from '@grafana/alerting/testing';
|
||||
import { RouteWithID as AlertingRouteWithID } from '@grafana/alerting/unstable';
|
||||
import { MatcherOperator, ObjectMatcher, Route, RouteWithID } from 'app/plugins/datasource/alertmanager/types';
|
||||
|
||||
import { routeAdapter } from './routeAdapter';
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import {
|
||||
Route as AlertingRoute,
|
||||
RouteWithID as AlertingRouteWithID,
|
||||
type LabelMatcher,
|
||||
} from '@grafana/alerting/unstable';
|
||||
import { Route as AlertingRoute, RouteWithID as AlertingRouteWithID } from '@grafana/alerting';
|
||||
import { type LabelMatcher } from '@grafana/alerting/unstable';
|
||||
import {
|
||||
MatcherOperator,
|
||||
type ObjectMatcher,
|
||||
|
||||
Reference in New Issue
Block a user