mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
parent
6c9d9a2db5
commit
18e0a060e6
@ -0,0 +1,30 @@
|
||||
---
|
||||
keywords:
|
||||
- grafana
|
||||
- schema
|
||||
title: AlertGroupsPanelCfg kind
|
||||
---
|
||||
> Both documentation generation and kinds schemas are in active development and subject to change without prior notice.
|
||||
|
||||
# AlertGroupsPanelCfg kind
|
||||
|
||||
### Maturity: merged
|
||||
### Version: 0.0
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Required | Description |
|
||||
|----------------|-------------------------|----------|-------------|
|
||||
| `PanelOptions` | [object](#paneloptions) | **Yes** | |
|
||||
|
||||
## PanelOptions
|
||||
|
||||
### Properties
|
||||
|
||||
| Property | Type | Required | Description |
|
||||
|----------------|---------|----------|-------------------------------------------------------------|
|
||||
| `alertmanager` | string | **Yes** | Name of the alertmanager used as a source for alerts |
|
||||
| `expandAll` | boolean | **Yes** | Expand all alert groups by default |
|
||||
| `labels` | string | **Yes** | Comma-separated list of values used to filter alert results |
|
||||
|
||||
|
@ -9,13 +9,13 @@
|
||||
"grafanaMaturityCount": 0,
|
||||
"lineageIsGroup": true,
|
||||
"links": {
|
||||
"docs": "n/a",
|
||||
"docs": "https:/grafana.com/docs/grafana/next/developers/kinds/composable/alertgroupspanelcfg/schema-reference",
|
||||
"go": "n/a",
|
||||
"schema": "n/a",
|
||||
"ts": "n/a"
|
||||
"schema": "https:/github.com/grafana/grafana/tree/main/public/app/plugins/panel/alertGroups/panelcfg.cue",
|
||||
"ts": "https:/github.com/grafana/grafana/tree/main/public/app/plugins/panel/alertGroups/panelcfg.gen.ts"
|
||||
},
|
||||
"machineName": "alertgroupspanelcfg",
|
||||
"maturity": "planned",
|
||||
"maturity": "merged",
|
||||
"name": "AlertGroupsPanelCfg",
|
||||
"pluralMachineName": "alertgroupspanelcfgs",
|
||||
"pluralName": "AlertGroupsPanelCfgs",
|
||||
@ -1659,15 +1659,15 @@
|
||||
"merged": {
|
||||
"name": "merged",
|
||||
"items": [
|
||||
"alertgroupspanelcfg",
|
||||
"playlist",
|
||||
"team"
|
||||
],
|
||||
"count": 2
|
||||
"count": 3
|
||||
},
|
||||
"planned": {
|
||||
"name": "planned",
|
||||
"items": [
|
||||
"alertgroupspanelcfg",
|
||||
"alertlistpanelcfg",
|
||||
"alertmanagerdataquery",
|
||||
"alertmanagerdatasourcecfg",
|
||||
@ -1729,7 +1729,7 @@
|
||||
"zipkindataquery",
|
||||
"zipkindatasourcecfg"
|
||||
],
|
||||
"count": 61
|
||||
"count": 60
|
||||
},
|
||||
"stable": {
|
||||
"name": "stable",
|
||||
|
@ -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 };
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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',
|
||||
|
36
public/app/plugins/panel/alertGroups/panelcfg.cue
Normal file
36
public/app/plugins/panel/alertGroups/panelcfg.cue
Normal 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")
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
26
public/app/plugins/panel/alertGroups/panelcfg.gen.ts
Normal file
26
public/app/plugins/panel/alertGroups/panelcfg.gen.ts
Normal 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;
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
export interface AlertGroupPanelOptions {
|
||||
labels: string;
|
||||
alertmanager: string;
|
||||
expandAll: boolean;
|
||||
}
|
@ -16,7 +16,7 @@ package grafanaplugin
|
||||
|
||||
import (
|
||||
"github.com/grafana/thema"
|
||||
ui "github.com/grafana/grafana/packages/grafana-schema/src/common"
|
||||
ui "github.com/grafana/grafana/packages/grafana-schema/src/common"
|
||||
)
|
||||
|
||||
Panel: thema.#Lineage & {
|
||||
@ -26,25 +26,25 @@ Panel: thema.#Lineage & {
|
||||
schemas: [
|
||||
{
|
||||
PanelOptions: {
|
||||
view: MapViewConfig
|
||||
view: MapViewConfig
|
||||
controls: ControlsOptions
|
||||
basemap: ui.MapLayerOptions
|
||||
basemap: ui.MapLayerOptions
|
||||
layers: [...ui.MapLayerOptions]
|
||||
tooltip: TooltipOptions
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
MapViewConfig: {
|
||||
id: string | *"zero"
|
||||
lat?: int64 | *0
|
||||
lon?: int64 | *0
|
||||
zoom?: int64 | *1
|
||||
minZoom?: int64
|
||||
maxZoom?: int64
|
||||
padding?: int64
|
||||
id: string | *"zero"
|
||||
lat?: int64 | *0
|
||||
lon?: int64 | *0
|
||||
zoom?: int64 | *1
|
||||
minZoom?: int64
|
||||
maxZoom?: int64
|
||||
padding?: int64
|
||||
allLayers?: bool | *true
|
||||
lastOnly?: bool
|
||||
layer?: string
|
||||
shared?: bool
|
||||
lastOnly?: bool
|
||||
layer?: string
|
||||
shared?: bool
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
ControlsOptions: {
|
||||
@ -68,7 +68,7 @@ Panel: thema.#Lineage & {
|
||||
|
||||
TooltipMode: "none" | "details" @cuetsy(kind="enum",memberNames="None|Details")
|
||||
|
||||
MapCenterID: "zero"|"coords"|"fit" @cuetsy(kind="enum",members="Zero|Coordinates|Fit")
|
||||
MapCenterID: "zero" | "coords" | "fit" @cuetsy(kind="enum",members="Zero|Coordinates|Fit")
|
||||
},
|
||||
]
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user