AlertGroups: Generate models.gen.ts from models.cue (#61227)

* AlertGroups: Generate models.gen.ts from models.cue

* Update structure

* Update report

* Fix filenames

* Add missing file
This commit is contained in:
Alex Khomenko
2023-01-24 13:46:35 +02:00
committed by GitHub
parent 6c9d9a2db5
commit 18e0a060e6
9 changed files with 121 additions and 34 deletions

View File

@@ -17,7 +17,7 @@ import { setDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
import { configureStore } from 'app/store/configureStore';
import { AlertGroupsPanel } from './AlertGroupsPanel';
import { AlertGroupPanelOptions } from './types';
import { PanelOptions } from './panelcfg.gen';
jest.mock('app/features/alerting/unified/api/alertmanager');
@@ -44,13 +44,13 @@ const dataSources = {
}),
};
const defaultOptions: AlertGroupPanelOptions = {
const defaultOptions: PanelOptions = {
labels: '',
alertmanager: 'Alertmanager',
expandAll: false,
};
const defaultProps: PanelProps<AlertGroupPanelOptions> = {
const defaultProps: PanelProps<PanelOptions> = {
data: { state: LoadingState.Done, series: [], timeRange: getDefaultTimeRange() },
id: 1,
timeRange: getDefaultTimeRange(),
@@ -78,7 +78,7 @@ const defaultProps: PanelProps<AlertGroupPanelOptions> = {
width: 320,
};
const renderPanel = (options: AlertGroupPanelOptions = defaultOptions) => {
const renderPanel = (options: PanelOptions = defaultOptions) => {
const store = configureStore();
const dash: any = { id: 1, formatDate: (time: number) => new Date(time).toISOString() };
const dashSrv: any = { getCurrent: () => dash };

View File

@@ -12,10 +12,10 @@ import { AlertmanagerGroup, Matcher } from 'app/plugins/datasource/alertmanager/
import { useDispatch } from 'app/types';
import { AlertGroup } from './AlertGroup';
import { AlertGroupPanelOptions } from './types';
import { PanelOptions } from './panelcfg.gen';
import { useFilteredGroups } from './useFilteredGroups';
export const AlertGroupsPanel = (props: PanelProps<AlertGroupPanelOptions>) => {
export const AlertGroupsPanel = (props: PanelProps<PanelOptions>) => {
const dispatch = useDispatch();
const isAlertingEnabled = config.unifiedAlertingEnabled;

View File

@@ -8,9 +8,9 @@ import {
} from 'app/features/alerting/unified/utils/datasource';
import { AlertGroupsPanel } from './AlertGroupsPanel';
import { AlertGroupPanelOptions } from './types';
import { PanelOptions } from './panelcfg.gen';
export const plugin = new PanelPlugin<AlertGroupPanelOptions>(AlertGroupsPanel).setPanelOptions((builder) => {
export const plugin = new PanelPlugin<PanelOptions>(AlertGroupsPanel).setPanelOptions((builder) => {
return builder
.addCustomEditor({
name: 'Alertmanager',

View File

@@ -0,0 +1,36 @@
// Copyright 2023 Grafana Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package grafanaplugin
composableKinds: PanelCfg: {
lineage: {
seqs: [
{
schemas: [
{
PanelOptions: {
// Comma-separated list of values used to filter alert results
labels: string
// Name of the alertmanager used as a source for alerts
alertmanager: string
// Expand all alert groups by default
expandAll: bool
} @cuetsy(kind="interface")
},
]
},
]
}
}

View File

@@ -0,0 +1,26 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
//
// Generated by:
// public/app/plugins/gen.go
// Using jennies:
// TSTypesJenny
// PluginTSTypesJenny
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface PanelOptions {
/**
* Name of the alertmanager used as a source for alerts
*/
alertmanager: string;
/**
* Expand all alert groups by default
*/
expandAll: boolean;
/**
* Comma-separated list of values used to filter alert results
*/
labels: string;
}

View File

@@ -1,5 +0,0 @@
export interface AlertGroupPanelOptions {
labels: string;
alertmanager: string;
expandAll: boolean;
}