-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
Dashboards links
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package converter | ||
|
||
import ( | ||
grabana "github.com/K-Phoen/grabana/decoder" | ||
"github.com/K-Phoen/sdk" | ||
) | ||
|
||
func (converter *JSON) convertDashboardLink(link sdk.Link) *grabana.DashboardInternalLink { | ||
extLink := &grabana.DashboardInternalLink{ | ||
Title: link.Title, | ||
Tags: link.Tags, | ||
IncludeVariableValues: link.IncludeVars, | ||
} | ||
|
||
if link.AsDropdown != nil { | ||
extLink.AsDropdown = *link.AsDropdown | ||
} | ||
if link.TargetBlank != nil { | ||
extLink.OpenInNewTab = *link.TargetBlank | ||
} | ||
if link.KeepTime != nil { | ||
extLink.IncludeTimeRange = *link.KeepTime | ||
} | ||
|
||
return extLink | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package converter | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/K-Phoen/sdk" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func TestConvertDashboardLink(t *testing.T) { | ||
req := require.New(t) | ||
|
||
externalLink := sdk.Link{ | ||
Title: "joe", | ||
Tags: []string{"my-service"}, | ||
Type: "dashboards", | ||
IncludeVars: true, | ||
AsDropdown: boolPtr(true), | ||
KeepTime: boolPtr(true), | ||
TargetBlank: boolPtr(true), | ||
} | ||
converter := NewJSON(zap.NewNop()) | ||
link := converter.convertDashboardLink(externalLink) | ||
|
||
req.Equal("joe", link.Title) | ||
req.ElementsMatch([]string{"my-service"}, link.Tags) | ||
req.True(link.OpenInNewTab) | ||
req.True(link.IncludeTimeRange) | ||
req.True(link.AsDropdown) | ||
req.True(link.IncludeVariableValues) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.