Skip to content

Commit 9aecd40

Browse files
authored
Add InternalDataLink type (#662)
* Add InternalDataLink type * Fix lint
1 parent 80d7acd commit 9aecd40

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

data/field_config.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"math"
66
"strconv"
7+
"time"
78
)
89

910
// FieldConfig represents the display properties for a Field.
@@ -158,11 +159,45 @@ func (fc *FieldConfig) SetFilterable(b bool) *FieldConfig {
158159

159160
// DataLink define what
160161
type DataLink struct { //revive:disable-line
161-
Title string `json:"title,omitempty"`
162-
TargetBlank bool `json:"targetBlank,omitempty"`
163-
URL string `json:"url,omitempty"`
162+
Title string `json:"title,omitempty"`
163+
TargetBlank bool `json:"targetBlank,omitempty"`
164+
URL string `json:"url,omitempty"`
165+
Internal *InternalDataLink `json:"internal,omitempty"`
164166
}
165167

168+
// InternalDataLink definition to allow Explore links to be constructed in the backend
169+
type InternalDataLink struct {
170+
Query any `json:"query,omitempty"`
171+
DatasourceUID string `json:"datasourceUid,omitempty"`
172+
DatasourceName string `json:"datasourceName,omitempty"`
173+
ExplorePanelsState *ExplorePanelsState `json:"panelsState,omitempty"`
174+
Transformations *[]LinkTransformationConfig `json:"transformations,omitempty"`
175+
Range *TimeRange `json:"timeRange,omitempty"`
176+
}
177+
178+
// This is an object constructed with the keys as the values of the enum VisType and the value being a bag of properties
179+
type ExplorePanelsState any
180+
181+
// Redefining this to avoid an import cycle
182+
type TimeRange struct {
183+
From time.Time `json:"from,omitempty"`
184+
To time.Time `json:"to,omitempty"`
185+
}
186+
187+
type LinkTransformationConfig struct {
188+
Type SupportedTransformationTypes `json:"type,omitempty"`
189+
Field string `json:"field,omitempty"`
190+
Expression string `json:"expression,omitempty"`
191+
MapValue string `json:"mapValue,omitempty"`
192+
}
193+
194+
type SupportedTransformationTypes string
195+
196+
const (
197+
Regex SupportedTransformationTypes = "regex"
198+
Logfmt SupportedTransformationTypes = "logfmt"
199+
)
200+
166201
// ThresholdsConfig setup thresholds
167202
type ThresholdsConfig struct {
168203
Mode ThresholdsMode `json:"mode"`

0 commit comments

Comments
 (0)