[v10.1.x] Alerting: Prevent showing "Permissions denied" alert when not accurate (#74925)

Alerting: Prevent showing "Permissions denied" alert when not accurate (#74887)

* Change way of obtaining external datasources info

* Remove unneeded import

* Create function to getExternalDsAlertManagers in datasource srv

* Remove unused import

(cherry picked from commit db2295bea2)

Co-authored-by: Virginia Cepeda <virginia.cepeda@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2023-09-14 11:55:51 -03:00
committed by GitHub
co-authored by Virginia Cepeda
parent 22cd5b2ae1
commit 8972a1bd5b
2 changed files with 9 additions and 5 deletions
@@ -1,7 +1,6 @@
import { AlertmanagerChoice } from '../../../../../../plugins/datasource/alertmanager/types';
import { alertmanagerApi } from '../../../api/alertmanagerApi';
import { useExternalDataSourceAlertmanagers } from '../../../hooks/useExternalAmSelector';
import { GRAFANA_RULES_SOURCE_NAME } from '../../../utils/datasource';
import { getExternalDsAlertManagers, GRAFANA_RULES_SOURCE_NAME } from '../../../utils/datasource';
export interface AlertManagerNameWithImage {
name: string;
@@ -12,10 +11,11 @@ export const useGetAlertManagersSourceNamesAndImage = () => {
//get current alerting config
const { currentData: amConfigStatus } = alertmanagerApi.useGetAlertmanagerChoiceStatusQuery(undefined);
const externalDsAlertManagers: AlertManagerNameWithImage[] = useExternalDataSourceAlertmanagers().map((ds) => ({
name: ds.dataSource.name,
img: ds.dataSource.meta.info.logos.small,
const externalDsAlertManagers = getExternalDsAlertManagers().map((ds) => ({
name: ds.name,
img: ds.meta.info.logos.small,
}));
const alertmanagerChoice = amConfigStatus?.alertmanagersChoice;
const alertManagerSourceNamesWithImage: AlertManagerNameWithImage[] =
alertmanagerChoice === AlertmanagerChoice.Internal
@@ -47,6 +47,10 @@ export function getAlertManagerDataSources() {
.sort((a, b) => a.name.localeCompare(b.name));
}
export function getExternalDsAlertManagers() {
return getAlertManagerDataSources().filter((ds) => ds.jsonData.handleGrafanaManagedAlerts);
}
const grafanaAlertManagerDataSource: AlertManagerDataSource = {
name: GRAFANA_RULES_SOURCE_NAME,
imgUrl: 'public/img/grafana_icon.svg',