minor lint fixes

pull/89995/head
Ryan McKinley 1 year ago
parent 9f2aae1c48
commit fe8a05c648
  1. 2
      pkg/registry/apis/dashboard/legacy/sql_dashboards.go
  2. 2
      pkg/services/apiserver/options/storage.go
  3. 10
      pkg/tests/apis/dashboard/dashboards_test.go
  4. 9
      public/app/features/dashboard-scene/settings/version-history/HistorySrv.ts
  5. 8
      public/app/features/dashboard/components/DashboardSettings/VersionsSettings.test.tsx

@ -115,7 +115,7 @@ func (a *dashboardSqlAccess) getRows(ctx context.Context, query *DashboardQuery)
// } // }
} }
sqlcmd := selector var sqlcmd string
args := []any{query.OrgID} args := []any{query.OrgID}
limit := query.Limit limit := query.Limit

@ -49,7 +49,7 @@ func (o *StorageOptions) Validate() []error {
case StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc: case StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc:
// no-op // no-op
default: default:
errs = append(errs, fmt.Errorf("--grafana-apiserver-storage-type must be one of %s, %s, %s, %s, %s, %s", StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc)) errs = append(errs, fmt.Errorf("--grafana-apiserver-storage-type must be one of %s, %s, %s, %s, %s, %s, %s", StorageTypeFile, StorageTypeEtcd, StorageTypeLegacy, StorageTypeUnified, StorageTypeUnifiedGrpc, StorageTypeUnifiedNext, StorageTypeUnifiedNextGrpc))
} }
if _, _, err := net.SplitHostPort(o.Address); err != nil { if _, _, err := net.SplitHostPort(o.Address); err != nil {

@ -1,6 +1,7 @@
package dashboards package dashboards
import ( import (
"fmt"
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -47,7 +48,7 @@ func TestIntegrationDashboardsApp(t *testing.T) {
t.Run("Check discovery client", func(t *testing.T) { t.Run("Check discovery client", func(t *testing.T) {
disco := helper.GetGroupVersionInfoJSON("dashboard.grafana.app") disco := helper.GetGroupVersionInfoJSON("dashboard.grafana.app")
//fmt.Printf("%s", string(disco)) fmt.Printf("%s", string(disco))
require.JSONEq(t, `[ require.JSONEq(t, `[
{ {
@ -77,10 +78,10 @@ func TestIntegrationDashboardsApp(t *testing.T) {
{ {
"responseKind": { "responseKind": {
"group": "", "group": "",
"kind": "DashboardVersionList", "kind": "PartialObjectMetadataList",
"version": "" "version": ""
}, },
"subresource": "versions", "subresource": "history",
"verbs": [ "verbs": [
"get" "get"
] ]
@ -93,7 +94,8 @@ func TestIntegrationDashboardsApp(t *testing.T) {
"get", "get",
"list", "list",
"patch", "patch",
"update" "update",
"watch"
] ]
} }
], ],

@ -33,7 +33,7 @@ class LegacyHistorySrv implements HistorySrv {
async getDashboardVersion(dashboardUID: string, version: number): Promise<Dashboard | {}> { async getDashboardVersion(dashboardUID: string, version: number): Promise<Dashboard | {}> {
if (typeof dashboardUID !== 'string') { if (typeof dashboardUID !== 'string') {
return Promise.resolve({}) return Promise.resolve({});
} }
const info = await getBackendSrv().get(`api/dashboards/uid/${dashboardUID}/versions/${version}`); const info = await getBackendSrv().get(`api/dashboards/uid/${dashboardUID}/versions/${version}`);
@ -42,7 +42,7 @@ class LegacyHistorySrv implements HistorySrv {
restoreDashboard(dashboardUID: string, version: number): Promise<SaveDashboardResponseDTO | {}> { restoreDashboard(dashboardUID: string, version: number): Promise<SaveDashboardResponseDTO | {}> {
if (typeof dashboardUID !== 'string') { if (typeof dashboardUID !== 'string') {
return Promise.resolve({}) return Promise.resolve({});
} }
const url = `api/dashboards/uid/${dashboardUID}/restore`; const url = `api/dashboards/uid/${dashboardUID}/restore`;
@ -51,12 +51,11 @@ class LegacyHistorySrv implements HistorySrv {
} }
} }
let historySrv: HistorySrv | undefined = undefined; let historySrv: HistorySrv | undefined = undefined;
export function getHistorySrv(): HistorySrv { export function getHistorySrv(): HistorySrv {
if (!historySrv) { if (!historySrv) {
historySrv = new LegacyHistorySrv() historySrv = new LegacyHistorySrv();
} }
return historySrv return historySrv;
} }

@ -135,8 +135,8 @@ describe('VersionSettings', () => {
}); });
test('clicking show more appends results to the table', async () => { test('clicking show more appends results to the table', async () => {
getHistorySrv().getHistoryList getHistorySrv()
// @ts-ignore .getHistoryList// @ts-ignore
.mockImplementationOnce(() => Promise.resolve(versions.slice(0, VERSIONS_FETCH_LIMIT))) .mockImplementationOnce(() => Promise.resolve(versions.slice(0, VERSIONS_FETCH_LIMIT)))
.mockImplementationOnce( .mockImplementationOnce(
() => new Promise((resolve) => setTimeout(() => resolve(versions.slice(VERSIONS_FETCH_LIMIT)), 1000)) () => new Promise((resolve) => setTimeout(() => resolve(versions.slice(VERSIONS_FETCH_LIMIT)), 1000))
@ -166,8 +166,8 @@ describe('VersionSettings', () => {
test('selecting two versions and clicking compare button should render compare view', async () => { test('selecting two versions and clicking compare button should render compare view', async () => {
// @ts-ignore // @ts-ignore
historySrv.getHistoryList.mockResolvedValue(versions.slice(0, VERSIONS_FETCH_LIMIT)); historySrv.getHistoryList.mockResolvedValue(versions.slice(0, VERSIONS_FETCH_LIMIT));
getHistorySrv().getDashboardVersion getHistorySrv()
// @ts-ignore .getDashboardVersion// @ts-ignore
.mockImplementationOnce(() => Promise.resolve(diffs.lhs)) .mockImplementationOnce(() => Promise.resolve(diffs.lhs))
.mockImplementationOnce(() => Promise.resolve(diffs.rhs)); .mockImplementationOnce(() => Promise.resolve(diffs.rhs));

Loading…
Cancel
Save