diff --git a/pkg/services/publicdashboards/commands/generate_datasources/generate.go b/pkg/services/publicdashboards/commands/generate_datasources/generate.go index 9a98454badc..2c6f50cb39d 100644 --- a/pkg/services/publicdashboards/commands/generate_datasources/generate.go +++ b/pkg/services/publicdashboards/commands/generate_datasources/generate.go @@ -6,8 +6,12 @@ import ( "net/http" "sort" "sync" + + "github.com/grafana/grafana/pkg/expr" ) +var grafanaDatasources = []string{expr.DatasourceType, "datasource"} + type listPluginResponse struct { Items []struct { Slug string `json:"slug"` @@ -41,6 +45,8 @@ func GetCompatibleDatasources(baseUrl string) ([]string, error) { } } + supported = append(supported, grafanaDatasources...) + sort.Strings(supported) return supported, nil } diff --git a/pkg/services/publicdashboards/commands/generate_datasources/main.go b/pkg/services/publicdashboards/commands/generate_datasources/main.go index 62ce8f15884..1bdda91f4df 100644 --- a/pkg/services/publicdashboards/commands/generate_datasources/main.go +++ b/pkg/services/publicdashboards/commands/generate_datasources/main.go @@ -13,7 +13,7 @@ import ( var tsDatasourcesTemplate = ` // Code generated by go generate; DO NOT EDIT. -export const supportedDatasources = new Set([ +export const supportedDatasources = new Set([ {{- range . }} '{{ printf "%s" . }}', {{- end }} diff --git a/pkg/services/publicdashboards/commands/generate_datasources/main_test.go b/pkg/services/publicdashboards/commands/generate_datasources/main_test.go index f535446fac8..6707f80eb7f 100644 --- a/pkg/services/publicdashboards/commands/generate_datasources/main_test.go +++ b/pkg/services/publicdashboards/commands/generate_datasources/main_test.go @@ -3,6 +3,7 @@ package generate_datasources import ( "net/http" "net/http/httptest" + "sort" "testing" "github.com/stretchr/testify/assert" @@ -31,6 +32,14 @@ func TestCanGetCompatibleDatasources(t *testing.T) { datasources, err := GetCompatibleDatasources(server.URL) require.NoError(t, err) - assert.Len(t, datasources, 1) - assert.Equal(t, "postgres", datasources[0]) + + expectedDatasources := []string{"postgres"} + expectedDatasources = append(expectedDatasources, grafanaDatasources...) + sort.Strings(expectedDatasources) + + assert.Len(t, datasources, len(expectedDatasources)) + + for i := range expectedDatasources { + assert.Equal(t, expectedDatasources[i], datasources[i]) + } } diff --git a/pkg/services/publicdashboards/public_dashboard_service_mock.go b/pkg/services/publicdashboards/public_dashboard_service_mock.go index 3b5d0c6815e..0aa2eb1d568 100644 --- a/pkg/services/publicdashboards/public_dashboard_service_mock.go +++ b/pkg/services/publicdashboards/public_dashboard_service_mock.go @@ -254,7 +254,7 @@ func (_m *FakePublicDashboardService) FindDashboard(ctx context.Context, orgId i return r0, r1 } -// FindEnabledDashboardAndDashboardByAccessToken provides a mock function with given fields: ctx, accessToken +// FindEnabledPublicDashboardAndDashboardByAccessToken provides a mock function with given fields: ctx, accessToken func (_m *FakePublicDashboardService) FindEnabledPublicDashboardAndDashboardByAccessToken(ctx context.Context, accessToken string) (*models.PublicDashboard, *dashboards.Dashboard, error) { ret := _m.Called(ctx, accessToken) diff --git a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboardUtils.test.tsx b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboardUtils.test.tsx index f96138f55a8..c270394a370 100644 --- a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboardUtils.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SharePublicDashboardUtils.test.tsx @@ -56,6 +56,12 @@ describe('getUnsupportedDashboardDatasources', () => { { datasource: { type: 'prometheus' } as DataSourceRef, } as DataQuery, + { + datasource: { type: '__expr__' } as DataSourceRef, + } as DataQuery, + { + datasource: { type: 'datasource' } as DataSourceRef, + } as DataQuery, ] as DataQuery[], } as PanelModel; const panelArray: PanelModel[] = [pm]; diff --git a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SupportedPubdashDatasources.ts b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SupportedPubdashDatasources.ts index 11afee3e72f..68d73f2ab4e 100644 --- a/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SupportedPubdashDatasources.ts +++ b/public/app/features/dashboard/components/ShareModal/SharePublicDashboard/SupportedPubdashDatasources.ts @@ -1,8 +1,10 @@ // Code generated by go generate; DO NOT EDIT. export const supportedDatasources = new Set([ + '__expr__', 'aquaqanalytics-kdbbackend-datasource', 'cloudwatch', + 'datasource', 'dlopes7-appdynamics-datasource', 'doitintl-bigquery-datasource', 'elasticsearch', @@ -19,6 +21,7 @@ export const supportedDatasources = new Set([ 'grafana-dynatrace-datasource', 'grafana-es-open-distro-datasource', 'grafana-github-datasource', + 'grafana-gitlab-datasource', 'grafana-honeycomb-datasource', 'grafana-iot-sitewise-datasource', 'grafana-jira-datasource',