Schema: Add origin property to AdHocFilterWithLabels (#104320)

* add origin to AdHocFilterWithLabels

* typo

* fix

* use singular for FilterOrigin

* run ./hack/update-codegen.sh

* add canary scenes to verify typechecks

* update dashboard schema json snapshot

* fix

* fix

* update canaries

* fix

* bump scenes version
This commit is contained in:
Victor Marin 2025-04-24 11:13:17 +03:00 committed by GitHub
parent e6414a6690
commit faa33e30a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 64 additions and 21 deletions

View File

@ -704,6 +704,10 @@ VariableRefresh: *"never" | "onDashboardLoad" | "onTimeRangeChanged"
// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing).
VariableHide: *"dontHide" | "hideLabel" | "hideVariable"
// Determine the origin of the adhoc variable filter
// Accepted values are `dashboard` (filter originated from dashboard), or `scope` (filter originated from scope).
FilterOrigin: "dashboard" | "scope"
// FIXME: should we introduce this? --- Variable value option
VariableValueOption: {
label: string
@ -915,6 +919,7 @@ AdHocFilterWithLabels: {
keyLabel?: string
valueLabels?: [...string]
forceEdit?: bool
origin?: FilterOrigin
// @deprecated
condition?: string
}

View File

@ -294,6 +294,8 @@ var _ resource.ListObject = &DashboardList{}
// Copy methods for all subresource types
// DeepCopy creates a full deep copy of DashboardStatus
func (s *DashboardStatus) DeepCopy() *DashboardStatus {
cpy := &DashboardStatus{}

View File

@ -294,6 +294,8 @@ var _ resource.ListObject = &DashboardList{}
// Copy methods for all subresource types
// DeepCopy creates a full deep copy of DashboardStatus
func (s *DashboardStatus) DeepCopy() *DashboardStatus {
cpy := &DashboardStatus{}

View File

@ -708,6 +708,10 @@ VariableRefresh: *"never" | "onDashboardLoad" | "onTimeRangeChanged"
// Accepted values are `dontHide` (show label and value), `hideLabel` (show value only), `hideVariable` (show nothing).
VariableHide: *"dontHide" | "hideLabel" | "hideVariable"
// Determine the origin of the adhoc variable filter
// Accepted values are `dashboard` (filter originated from dashboard), or `scope` (filter originated from scope).
FilterOrigin: "dashboard" | "scope"
// FIXME: should we introduce this? --- Variable value option
VariableValueOption: {
label: string
@ -919,6 +923,7 @@ AdHocFilterWithLabels: {
keyLabel?: string
valueLabels?: [...string]
forceEdit?: bool
origin?: FilterOrigin
// @deprecated
condition?: string
}

View File

@ -1665,13 +1665,14 @@ func NewDashboardAdhocVariableSpec() *DashboardAdhocVariableSpec {
// Define the AdHocFilterWithLabels type
// +k8s:openapi-gen=true
type DashboardAdHocFilterWithLabels struct {
Key string `json:"key"`
Operator string `json:"operator"`
Value string `json:"value"`
Values []string `json:"values,omitempty"`
KeyLabel *string `json:"keyLabel,omitempty"`
ValueLabels []string `json:"valueLabels,omitempty"`
ForceEdit *bool `json:"forceEdit,omitempty"`
Key string `json:"key"`
Operator string `json:"operator"`
Value string `json:"value"`
Values []string `json:"values,omitempty"`
KeyLabel *string `json:"keyLabel,omitempty"`
ValueLabels []string `json:"valueLabels,omitempty"`
ForceEdit *bool `json:"forceEdit,omitempty"`
Origin *DashboardFilterOrigin `json:"origin,omitempty"`
// @deprecated
Condition *string `json:"condition,omitempty"`
}
@ -1681,6 +1682,16 @@ func NewDashboardAdHocFilterWithLabels() *DashboardAdHocFilterWithLabels {
return &DashboardAdHocFilterWithLabels{}
}
// Determine the origin of the adhoc variable filter
// Accepted values are `dashboard` (filter originated from dashboard), or `scope` (filter originated from scope).
// +k8s:openapi-gen=true
type DashboardFilterOrigin string
const (
DashboardFilterOriginDashboard DashboardFilterOrigin = "dashboard"
DashboardFilterOriginScope DashboardFilterOrigin = "scope"
)
// Define the MetricFindValue type
// +k8s:openapi-gen=true
type DashboardMetricFindValue struct {

View File

@ -380,6 +380,12 @@ func schema_pkg_apis_dashboard_v2alpha1_DashboardAdHocFilterWithLabels(ref commo
Format: "",
},
},
"origin": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"condition": {
SchemaProps: spec.SchemaProps{
Description: "@deprecated",

View File

@ -11,6 +11,8 @@ import (
"github.com/grafana/grafana-app-sdk/app"
)
var ()
var appManifestData = app.ManifestData{
AppName: "dashboard",
Group: "dashboard.grafana.app",

View File

@ -274,8 +274,8 @@
"@grafana/plugin-ui": "0.10.5",
"@grafana/prometheus": "workspace:*",
"@grafana/runtime": "workspace:*",
"@grafana/scenes": "^6.8.1",
"@grafana/scenes-react": "^6.8.1",
"@grafana/scenes": "6.10.0",
"@grafana/scenes-react": "6.10.0",
"@grafana/schema": "workspace:*",
"@grafana/sql": "workspace:*",
"@grafana/ui": "workspace:*",

View File

@ -1344,6 +1344,7 @@ export interface AdHocFilterWithLabels {
keyLabel?: string;
valueLabels?: string[];
forceEdit?: boolean;
origin?: FilterOrigin;
// @deprecated
condition?: string;
}
@ -1354,6 +1355,12 @@ export const defaultAdHocFilterWithLabels = (): AdHocFilterWithLabels => ({
value: "",
});
// Determine the origin of the adhoc variable filter
// Accepted values are `dashboard` (filter originated from dashboard), or `scope` (filter originated from scope).
export type FilterOrigin = "dashboard" | "scope";
export const defaultFilterOrigin = (): FilterOrigin => ("dashboard");
// Define the MetricFindValue type
export interface MetricFindValue {
text: string;

View File

@ -1104,6 +1104,9 @@
"type": "string",
"default": ""
}
},
"origin": {
"type": "string"
}
}
},
@ -4585,4 +4588,4 @@
}
}
}
}
}

View File

@ -3439,11 +3439,11 @@ __metadata:
languageName: unknown
linkType: soft
"@grafana/scenes-react@npm:^6.8.1":
version: 6.9.0
resolution: "@grafana/scenes-react@npm:6.9.0"
"@grafana/scenes-react@npm:6.10.0":
version: 6.10.0
resolution: "@grafana/scenes-react@npm:6.10.0"
dependencies:
"@grafana/scenes": "npm:6.9.0"
"@grafana/scenes": "npm:6.10.0"
lru-cache: "npm:^10.2.2"
react-use: "npm:^17.4.0"
peerDependencies:
@ -3455,13 +3455,13 @@ __metadata:
react: ^18.0.0
react-dom: ^18.0.0
react-router-dom: ^6.28.0
checksum: 10/c7c3759671f4497653a586e9396b5f89ac869dd30c9fb3077734ff80353fd612e2857136edc95d71c06607575930145af8d6811a088c9afda0299925c09ca9c7
checksum: 10/559de67feb4005173bc4a08c0c968a32e2e88fc362192825bdae0e5f3e83cf5e78bb4c2a373c66ac2f38a90333622e6623e372989910baf48121135d032291f1
languageName: node
linkType: hard
"@grafana/scenes@npm:6.9.0, @grafana/scenes@npm:^6.8.1":
version: 6.9.0
resolution: "@grafana/scenes@npm:6.9.0"
"@grafana/scenes@npm:6.10.0":
version: 6.10.0
resolution: "@grafana/scenes@npm:6.10.0"
dependencies:
"@floating-ui/react": "npm:^0.26.16"
"@leeoniya/ufuzzy": "npm:^1.0.16"
@ -3479,7 +3479,7 @@ __metadata:
react: ^18.0.0
react-dom: ^18.0.0
react-router-dom: ^6.28.0
checksum: 10/ff02465c53877ce07d11f842696d00b0eb0945ca58d2586664429b66578c7743fb5ac715541649b69d52b2de8eef035340aa2df4cd0e8961c3b782eee9001551
checksum: 10/4f89f59374f6bd20fcd0afec7d236e4e1754f43a379348e704c0021952b241ece2d04134de8d668bc4d4fa286ebcf1c7874403c70004e85b1330bd5f76bb5423
languageName: node
linkType: hard
@ -17376,8 +17376,8 @@ __metadata:
"@grafana/plugin-ui": "npm:0.10.5"
"@grafana/prometheus": "workspace:*"
"@grafana/runtime": "workspace:*"
"@grafana/scenes": "npm:^6.8.1"
"@grafana/scenes-react": "npm:^6.8.1"
"@grafana/scenes": "npm:6.10.0"
"@grafana/scenes-react": "npm:6.10.0"
"@grafana/schema": "workspace:*"
"@grafana/sql": "workspace:*"
"@grafana/tsconfig": "npm:^2.0.0"