Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboards): Added a new field called excluded in dashboard variables' (Testing PR) #1239

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/dashboards/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const getDashboardEntityQuery = `query ($guid: EntityGuid!) {
}
name
options {
excluded
ignoreTimeRange
}
nrqlQuery {
Expand Down
2 changes: 2 additions & 0 deletions pkg/dashboards/dashboards_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions pkg/dashboards/dashboards_api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {

// Test vars
dashboardName := "newrelic-client-go test-dashboard-" + mock.RandSeq(5)
ignoreTimeRangeValue := true
excludedValue := true
dashboardInput := DashboardInput{
Description: "Test description",
Name: dashboardName,
Expand Down Expand Up @@ -314,7 +316,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
},
Name: "variable",
Options: &DashboardVariableOptionsInput{
IgnoreTimeRange: true,
IgnoreTimeRange: &ignoreTimeRangeValue,
Excluded: &excludedValue,
},
NRQLQuery: &DashboardVariableNRQLQueryInput{
AccountIDs: []int{testAccountID},
Expand Down Expand Up @@ -347,10 +350,12 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
assert.Equal(t, dashboardInput.Name, dash.Name)
assert.Equal(t, entities.DashboardEntityPermissions(string(dashboardInput.Permissions)), dash.Permissions)

if dash.Variables[0].Options.IgnoreTimeRange != dashboardInput.Variables[0].Options.IgnoreTimeRange {
t.Errorf("Expected value to be %v but got %v\n", dashboardInput.Variables[0].Options.IgnoreTimeRange, dash.Variables[0].Options.IgnoreTimeRange)
if dash.Variables[0].Options.IgnoreTimeRange != *dashboardInput.Variables[0].Options.IgnoreTimeRange {
t.Errorf("Expected value to be %v but got %v\n", *dashboardInput.Variables[0].Options.IgnoreTimeRange, dash.Variables[0].Options.IgnoreTimeRange)
}
if dash.Variables[0].Options.Excluded != *dashboardInput.Variables[0].Options.Excluded {
t.Errorf("Expected value to be %v but got %v\n", *dashboardInput.Variables[0].Options.Excluded, dash.Variables[0].Options.Excluded)
}

// Input and Pages are different types so we can not easily compare them...
assert.Equal(t, len(dashboardInput.Pages), len(dash.Pages))
require.Equal(t, 1, len(dash.Pages))
Expand All @@ -362,6 +367,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
assert.Greater(t, len(dash.Pages[0].Widgets[0].RawConfiguration), 1)

// Test: DashboardUpdate
ignoreTimeRangeValue = false
excludedValue = false
updatedDashboard := DashboardInput{
Name: dash.Name,
Permissions: result.EntityResult.Permissions,
Expand Down Expand Up @@ -396,7 +403,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
},
Name: "variableUpdated",
Options: &DashboardVariableOptionsInput{
IgnoreTimeRange: true,
IgnoreTimeRange: &ignoreTimeRangeValue,
Excluded: &excludedValue,
},
NRQLQuery: &DashboardVariableNRQLQueryInput{
AccountIDs: []int{testAccountID},
Expand Down
6 changes: 5 additions & 1 deletion pkg/dashboards/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,18 @@ type DashboardVariableNRQLQueryInput struct {

// DashboardVariableOptions - Options applied to the variable.
type DashboardVariableOptions struct {
// With this turned on, query condition defined with the variable will not be included in the query.
Excluded bool `json:"excluded,omitempty"`
// Only applies to variables of type NRQL. With this turned on, the time range for the NRQL query will override the time picker on dashboards and other pages. Turn this off to use the time picker as normal.
IgnoreTimeRange bool `json:"ignoreTimeRange,omitempty"`
}

// DashboardVariableOptionsInput - Options applied to the variable
type DashboardVariableOptionsInput struct {
// With this turned on, query condition defined with the variable will not be included in the query.
Excluded *bool `json:"excluded,omitempty"`
// Only applies to variables of type NRQL. With this turned on, the time range for the NRQL query will override the time picker on dashboards and other pages. Turn this off to use the time picker as normal.
IgnoreTimeRange bool `json:"ignoreTimeRange"`
IgnoreTimeRange *bool `json:"ignoreTimeRange,omitempty"`
}

// DashboardWidgetConfigurationInput - Typed configuration for known visualizations. At most one may be populated.
Expand Down
1 change: 1 addition & 0 deletions pkg/entities/entities_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/entities/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
USER: "USER",
}

// AgentApplicationSettingsBrowserLoader - Determines which browser loader will be configured. Some allowed return values are specified for backwards-compatability and do not represent currently allowed values for new applications.

Check failure on line 31 in pkg/entities/types.go

View workflow job for this annotation

GitHub Actions / lint

"compatability" is a misspelling of "compatibility"
// See [documentation](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/#agent-types) for further information.
type AgentApplicationSettingsBrowserLoader string

Expand All @@ -45,7 +45,7 @@
RUM AgentApplicationSettingsBrowserLoader
// Pro+SPA: This is the default installed agent when you enable browser monitoring. Gives you access to all of the Browser Pro features and to Single Page App (SPA) monitoring. Provides detailed page timing data and the most up-to-date New Relic features, including distributed tracing, for all types of applications.
SPA AgentApplicationSettingsBrowserLoader
// This value is specified for backwards-compatability.

Check failure on line 48 in pkg/entities/types.go

View workflow job for this annotation

GitHub Actions / lint

"compatability" is a misspelling of "compatibility"
XHR AgentApplicationSettingsBrowserLoader
}{
// Use PRO instead
Expand All @@ -60,7 +60,7 @@
RUM: "RUM",
// Pro+SPA: This is the default installed agent when you enable browser monitoring. Gives you access to all of the Browser Pro features and to Single Page App (SPA) monitoring. Provides detailed page timing data and the most up-to-date New Relic features, including distributed tracing, for all types of applications.
SPA: "SPA",
// This value is specified for backwards-compatability.

Check failure on line 63 in pkg/entities/types.go

View workflow job for this annotation

GitHub Actions / lint

"compatability" is a misspelling of "compatibility"
XHR: "XHR",
}

Expand Down Expand Up @@ -5312,6 +5312,8 @@

// DashboardVariableOptions - Options applied to the variable.
type DashboardVariableOptions struct {
// With this turned on, query condition defined with the variable will not be included in the query.
Excluded bool `json:"excluded,omitempty"`
// Only applies to variables of type NRQL. With this turned on, the time range for the NRQL query will override the time picker on dashboards and other pages. Turn this off to use the time picker as normal.
IgnoreTimeRange bool `json:"ignoreTimeRange,omitempty"`
}
Expand Down
Loading