Files
Sonia Aguilar e219e2a834 Alerting: Recognise & change UI for OnCall notification policy + contact point (#60259)
* Identify and show onCall contact points with a badge in case the plugin is installed

* Add onCall logo for onCall contact points Badge

* Refactor and make Grafana App Receiver type more generic, not only for onCall type

* Show onCall notification policy in the specific routing table with special onCall badge

* Fix tests

* Move onCall badge to the type column in contact points view table

* Fix typos and remove onCallIntegrations from tagTypes in alertingApi

* Fetch only local plugins instead of all (external are not needed) and don't fetch plugin details

* Use directly useGetOnCallIntegrationsQuery and more PR review suggestions

* Move onCall contact point to the top in the drop-down,  in the notification policy view

* Add PR review requested changes
2022-12-21 14:46:55 +01:00

33 lines
938 B
TypeScript

import { BaseQueryFn, createApi } from '@reduxjs/toolkit/query/react';
import { lastValueFrom } from 'rxjs';
import { BackendSrvRequest, getBackendSrv } from '@grafana/runtime';
import { logInfo } from '../Analytics';
export const backendSrvBaseQuery = (): BaseQueryFn<BackendSrvRequest> => async (requestOptions) => {
try {
const requestStartTs = performance.now();
const { data, ...meta } = await lastValueFrom(getBackendSrv().fetch(requestOptions));
logInfo('Request finished', {
loadTimeMs: (performance.now() - requestStartTs).toFixed(0),
url: requestOptions.url,
method: requestOptions.method ?? '',
responseStatus: meta.statusText,
});
return { data, meta };
} catch (error) {
return { error };
}
};
export const alertingApi = createApi({
reducerPath: 'alertingApi',
baseQuery: backendSrvBaseQuery(),
tagTypes: ['AlertmanagerChoice'],
endpoints: () => ({}),
});