mirror of https://github.com/grafana/grafana
Schema: get all devenv dashboards passing validation (#37857)
* Strip nulls (again) * Add stripnulls script * Add transformations field * Close FieldConfig struct; proper plugin validating * s/graph/viz/ field in histogram dashboard * Use ui.GraphFieldConfig in histogram model * Add models for stat, gauge, barguage panel plugins Also toss necessary shared types into cue/ui/gen.cue, with TODOs to move them appropriately later. * Add required license headers * Heap of updates to cue UI components * Fix barchart types and one old devenv input * Use the GraphFieldConfig directly for timeseries * Add models.cue for a few panel plugins Barchart, state-timeline, and status-history * Enable the test validating all devenv dashboards!! * Fix effects of not checking after making comments * Update packages/grafana-ui/src/options/models.gen.ts Co-authored-by: Ryan McKinley <ryantxu@gmail.com> * Realign and unalign cue with ts types * Update devenv test to sniff for null errors Best option we have right now for helping people to know they need to strip nulls from devenv dashboards. * Add speculative default for barchart stacking * Fixup some dated devenv dashboards timeline-modes needed to be regenerated with the appropriate tooltip values included, per typing requirements, and timeline-demo needed to have the `mode` field removed, as it is not intended to be persisted. * Add necessary missing options for various panels * Regenerate devenv dashboards Co-authored-by: Ryan McKinley <ryantxu@gmail.com>pull/37959/head
parent
368da73ac4
commit
6aba592741
@ -0,0 +1,47 @@ |
||||
// Copyright 2021 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 grafanaschema |
||||
|
||||
import ( |
||||
ui "github.com/grafana/grafana/cue/ui:grafanaschema" |
||||
) |
||||
|
||||
Family: { |
||||
lineages: [ |
||||
[ |
||||
{ |
||||
PanelOptions: { |
||||
ui.OptionsWithLegend |
||||
ui.OptionsWithTooltip |
||||
ui.OptionsWithTextFormatting |
||||
orientation: ui.VizOrientation |
||||
// TODO this default is a guess based on common devenv values |
||||
stacking: ui.StackingMode | *"none" |
||||
showValue: ui.BarValueVisibility |
||||
barWidth: number |
||||
groupWidth: number |
||||
} |
||||
PanelFieldConfig: { |
||||
ui.AxisConfig |
||||
ui.HideableFieldConfig |
||||
lineWidth?: number |
||||
fillOpacity?: number |
||||
gradientMode?: ui.GraphGradientMode |
||||
} |
||||
} |
||||
] |
||||
] |
||||
migrations: [] |
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
// Copyright 2021 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 grafanaschema |
||||
|
||||
import ui "github.com/grafana/grafana/cue/ui:grafanaschema" |
||||
|
||||
Family: { |
||||
lineages: [ |
||||
[ |
||||
{ |
||||
PanelOptions: { |
||||
ui.SingleStatBaseOptions |
||||
displayMode: ui.BarGaugeDisplayMode |
||||
showUnfilled: bool |
||||
} |
||||
} |
||||
] |
||||
] |
||||
migrations: [] |
||||
} |
||||
@ -0,0 +1,32 @@ |
||||
// Copyright 2021 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 grafanaschema |
||||
|
||||
import ui "github.com/grafana/grafana/cue/ui:grafanaschema" |
||||
|
||||
Family: { |
||||
lineages: [ |
||||
[ |
||||
{ |
||||
PanelOptions: { |
||||
ui.SingleStatBaseOptions |
||||
showThresholdLabels: bool |
||||
showThresholdMarkers: bool |
||||
} |
||||
} |
||||
] |
||||
] |
||||
migrations: [] |
||||
} |
||||
@ -0,0 +1,34 @@ |
||||
// Copyright 2021 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 grafanaschema |
||||
|
||||
import ui "github.com/grafana/grafana/cue/ui:grafanaschema" |
||||
|
||||
Family: { |
||||
lineages: [ |
||||
[ |
||||
{ |
||||
PanelOptions: { |
||||
ui.SingleStatBaseOptions |
||||
graphMode: ui.BigValueGraphMode |
||||
colorMode: ui.BigValueColorMode |
||||
justifyMode: ui.BigValueJustifyMode |
||||
textMode: ui.BigValueTextMode |
||||
} |
||||
} |
||||
] |
||||
] |
||||
migrations: [] |
||||
} |
||||
@ -0,0 +1,47 @@ |
||||
// Copyright 2021 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 grafanaschema |
||||
|
||||
import ( |
||||
ui "github.com/grafana/grafana/cue/ui:grafanaschema" |
||||
) |
||||
|
||||
Family: { |
||||
lineages: [ |
||||
[ |
||||
{ |
||||
#TimelineMode: "changes" | "samples" @cuetsy(targetType="enum") |
||||
#TimelineValueAlignment: "center" | "left" | "right" @cuetsy(targetType="type") |
||||
PanelOptions: { |
||||
// FIXME ts comments indicate this shouldn't be in the saved model, but currently is emitted |
||||
mode?: #TimelineMode |
||||
ui.OptionsWithLegend |
||||
ui.OptionsWithTooltip |
||||
showValue: ui.BarValueVisibility | *"auto" |
||||
rowHeight: number | *0.9 |
||||
colWidth?: number |
||||
mergeValues?: bool | *true |
||||
alignValue?: #TimelineValueAlignment | *"left" |
||||
} |
||||
PanelFieldConfig: { |
||||
ui.HideableFieldConfig |
||||
lineWidth?: number | *0 |
||||
fillOpacity?: number | *70 |
||||
} |
||||
} |
||||
] |
||||
] |
||||
migrations: [] |
||||
} |
||||
@ -0,0 +1,42 @@ |
||||
// Copyright 2021 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 grafanaschema |
||||
|
||||
import ( |
||||
ui "github.com/grafana/grafana/cue/ui:grafanaschema" |
||||
) |
||||
|
||||
Family: { |
||||
lineages: [ |
||||
[ |
||||
{ |
||||
PanelOptions: { |
||||
ui.OptionsWithLegend |
||||
ui.OptionsWithTooltip |
||||
showValue: ui.BarValueVisibility |
||||
rowHeight: number |
||||
colWidth?: number |
||||
alignValue: "center" | *"left" | "right" |
||||
} |
||||
PanelFieldConfig: { |
||||
ui.HideableFieldConfig |
||||
lineWidth?: number | *1 |
||||
fillOpacity?: number | *70 |
||||
} |
||||
} |
||||
] |
||||
] |
||||
migrations: [] |
||||
} |
||||
@ -0,0 +1,16 @@ |
||||
#!/bin/bash |
||||
|
||||
# Strip all null values from dashboards within devenv for some particular |
||||
# schema version. Must be run from Grafana root. |
||||
|
||||
# OSX users need to install GNU sed: `brew install gsed` |
||||
SED=$(command -v gsed) |
||||
SED=${SED:-"sed"} |
||||
|
||||
FILES=$(grep -rl '"schemaVersion": 3[01]' devenv) |
||||
set -e |
||||
set -x |
||||
for DASH in ${FILES}; do echo "${DASH}"; grep -v 'null,$' "${DASH}" > "${DASH}-nulless"; mv "${DASH}-nulless" "${DASH}"; done |
||||
for DASH in ${FILES}; do grep -v 'null$' "${DASH}" > "${DASH}-nulless"; mv "${DASH}-nulless" "${DASH}"; done |
||||
# shellcheck disable=SC2016,SC2002 |
||||
for DASH in ${FILES}; do cat "${DASH}" | $SED -E -n 'H; x; s:,(\s*\n\s*}):\1:; P; ${x; p}' | $SED '1 d' > "${DASH}-nulless"; mv "${DASH}-nulless" "${DASH}"; done |
||||
Loading…
Reference in new issue