From 7891233812629cb091760a685b9500783ad017f0 Mon Sep 17 00:00:00 2001 From: Tobias Skarhed Date: Tue, 30 Jul 2019 15:49:32 +0200 Subject: [PATCH] Chore: noImplicitAny Sub 500 errors (#18287) --- package.json | 5 ++- .../DashboardSettings/SettingsCtrl.ts | 20 +++++---- .../SaveDashboardAsModalCtrl.test.ts | 22 ++++++---- .../SaveModals/SaveDashboardAsModalCtrl.ts | 10 +++-- .../SaveModals/SaveDashboardModalCtrl.test.ts | 8 ++-- .../SaveModals/SaveDashboardModalCtrl.ts | 11 ++--- .../SaveProvisionedDashboardModalCtrl.test.ts | 2 +- .../SaveProvisionedDashboardModalCtrl.ts | 3 +- .../ShareModal/ShareModalCtrl.test.ts | 4 +- .../components/ShareModal/ShareModalCtrl.ts | 15 ++++++- .../ShareModal/ShareSnapshotCtrl.ts | 27 ++++++++---- .../components/SubMenu/SubMenuCtrl.ts | 9 ++-- .../UnsavedChangesModalCtrl.ts | 2 +- .../VersionHistory/HistoryListCtrl.test.ts | 23 +++++----- .../VersionHistory/HistoryListCtrl.ts | 29 ++++++------ .../VersionHistory/HistorySrv.test.ts | 10 ++--- .../components/VersionHistory/HistorySrv.ts | 3 +- .../VersionHistory/__mocks__/history.ts | 4 +- .../containers/DashboardPage.test.tsx | 2 +- .../dashboard/dashgrid/DashboardGrid.test.tsx | 2 +- .../dashboard/dashgrid/DashboardGrid.tsx | 1 + .../dashboard/dashgrid/DashboardPanel.tsx | 2 +- .../dashboard/dashgrid/PanelResizer.tsx | 2 +- .../dashboard/panel_editor/EditorTabBody.tsx | 8 ++-- .../dashboard/panel_editor/GeneralTab.tsx | 2 +- .../dashboard/panel_editor/QueriesTab.tsx | 6 +-- .../dashboard/panel_editor/QueryInspector.tsx | 8 ++-- .../dashboard/panel_editor/QueryOptions.tsx | 10 +++-- .../dashboard/services/ChangeTracker.test.ts | 4 +- .../dashboard/services/ChangeTracker.ts | 23 +++++----- .../dashboard/services/DashboardLoaderSrv.ts | 44 ++++++++++--------- .../dashboard/services/DashboardSrv.ts | 22 ++++++---- .../dashboard/services/TimeSrv.test.ts | 2 +- .../dashboard/services/UnsavedChangesSrv.ts | 17 +++++-- .../dashboard/state/DashboardMigrator.test.ts | 17 +++---- .../dashboard/state/DashboardMigrator.ts | 34 +++++++------- .../state/DashboardModel.repeat.test.ts | 12 ++--- .../dashboard/state/PanelModel.test.ts | 4 +- .../dashboard/state/PanelQueryState.test.ts | 2 +- .../dashboard/state/PanelQueryState.ts | 2 +- .../app/features/dashboard/state/actions.ts | 2 +- .../dashboard/state/initDashboard.test.ts | 2 +- .../datasources/DataSourceDashboards.tsx | 4 +- .../datasources/__mocks__/dataSourcesMocks.ts | 4 +- .../features/datasources/state/selectors.ts | 22 +++++----- .../app/features/explore/AdHocFilterField.tsx | 2 +- public/app/features/explore/ErrorBoundary.tsx | 8 ++-- .../app/features/explore/ExploreToolbar.tsx | 2 +- public/app/features/explore/Graph.tsx | 10 ++--- .../app/features/explore/GraphContainer.tsx | 3 +- public/app/features/explore/JSONViewer.tsx | 2 +- public/app/features/explore/LogLabel.tsx | 2 +- .../app/features/explore/LogMessageAnsi.tsx | 3 +- public/app/features/explore/Logs.tsx | 5 ++- public/app/features/explore/LogsContainer.tsx | 5 ++- public/app/features/explore/QueryRow.tsx | 1 + public/app/features/explore/QueryStatus.tsx | 2 +- public/app/features/explore/Table.tsx | 8 ++-- .../app/features/explore/TableContainer.tsx | 3 +- .../explore/slate-plugins/braces.test.ts | 1 + .../features/explore/slate-plugins/braces.ts | 4 +- .../explore/slate-plugins/clear.test.ts | 1 + .../features/explore/slate-plugins/clear.ts | 2 +- .../features/explore/slate-plugins/newline.ts | 4 +- .../explore/slate-plugins/prism/index.tsx | 12 ++--- .../features/explore/slate-plugins/runner.ts | 4 +- .../epics/processQueryResultsEpic.test.ts | 12 ++--- .../state/epics/runQueriesBatchEpic.test.ts | 8 ++-- .../state/epics/runQueriesEpic.test.ts | 2 +- .../features/explore/state/epics/timeEpic.ts | 2 +- .../features/explore/state/reducers.test.ts | 4 +- .../azure_monitor/azure_monitor_datasource.ts | 2 +- scripts/ci-frontend-metrics.sh | 2 +- yarn.lock | 22 +++++++++- 74 files changed, 351 insertions(+), 254 deletions(-) diff --git a/package.json b/package.json index dd45244e631..307ee191590 100644 --- a/package.json +++ b/package.json @@ -175,11 +175,14 @@ "@types/angular-route": "1.7.0", "@types/d3-scale-chromatic": "1.3.1", "@types/enzyme-adapter-react-16": "1.0.5", + "@types/file-saver": "2.0.1", "@types/marked": "0.6.5", "@types/prismjs": "1.16.0", - "@types/react-redux": "^7.0.8", + "@types/react-redux": "7.0.8", + "@types/react-table": "6.8.5", "@types/react-test-renderer": "16.8.2", "@types/redux-logger": "3.0.7", + "@types/redux-mock-store": "1.0.1", "@types/reselect": "2.2.0", "@types/slate": "0.44.11", "@types/tinycolor2": "1.4.2", diff --git a/public/app/features/dashboard/components/DashboardSettings/SettingsCtrl.ts b/public/app/features/dashboard/components/DashboardSettings/SettingsCtrl.ts index 2fb9d76daa3..993b398d18b 100644 --- a/public/app/features/dashboard/components/DashboardSettings/SettingsCtrl.ts +++ b/public/app/features/dashboard/components/DashboardSettings/SettingsCtrl.ts @@ -2,8 +2,10 @@ import { coreModule, appEvents, contextSrv } from 'app/core/core'; import { DashboardModel } from '../../state/DashboardModel'; import $ from 'jquery'; import _ from 'lodash'; -import angular from 'angular'; +import angular, { ILocationService } from 'angular'; import config from 'app/core/config'; +import { BackendSrv } from 'app/core/services/backend_srv'; +import { DashboardSrv } from '../../services/DashboardSrv'; export class SettingsCtrl { dashboard: DashboardModel; @@ -19,12 +21,12 @@ export class SettingsCtrl { /** @ngInject */ constructor( - private $scope, - private $route, - private $location, - private $rootScope, - private backendSrv, - private dashboardSrv + private $scope: any, + private $route: any, + private $location: ILocationService, + private $rootScope: any, + private backendSrv: BackendSrv, + private dashboardSrv: DashboardSrv ) { // temp hack for annotations and variables editors // that rely on inherited scope @@ -226,13 +228,13 @@ export class SettingsCtrl { } deleteDashboardConfirmed() { - this.backendSrv.deleteDashboard(this.dashboard.uid).then(() => { + this.backendSrv.deleteDashboard(this.dashboard.uid, false).then(() => { appEvents.emit('alert-success', ['Dashboard Deleted', this.dashboard.title + ' has been deleted']); this.$location.url('/'); }); } - onFolderChange(folder) { + onFolderChange(folder: { id: number; title: string }) { this.dashboard.meta.folderId = folder.id; this.dashboard.meta.folderTitle = folder.title; this.hasUnsavedFolderChange = true; diff --git a/public/app/features/dashboard/components/SaveModals/SaveDashboardAsModalCtrl.test.ts b/public/app/features/dashboard/components/SaveModals/SaveDashboardAsModalCtrl.test.ts index 91b9097b626..c9339a6ecc5 100644 --- a/public/app/features/dashboard/components/SaveModals/SaveDashboardAsModalCtrl.test.ts +++ b/public/app/features/dashboard/components/SaveModals/SaveDashboardAsModalCtrl.test.ts @@ -2,14 +2,14 @@ import { SaveDashboardAsModalCtrl } from './SaveDashboardAsModalCtrl'; import { describe, it, expect } from 'test/lib/common'; describe('saving dashboard as', () => { - function scenario(name, panel, verify) { + function scenario(name: string, panel: any, verify: Function) { describe(name, () => { const json = { title: 'name', panels: [panel], }; - const mockDashboardSrv = { + const mockDashboardSrv: any = { getCurrent: () => { return { id: 5, @@ -34,7 +34,7 @@ describe('saving dashboard as', () => { }); } - scenario('default values', {}, ctx => { + scenario('default values', {}, (ctx: any) => { const clone = ctx.clone; expect(clone.id).toBe(null); expect(clone.title).toBe('name Copy'); @@ -49,19 +49,23 @@ describe('saving dashboard as', () => { thresholds: { value: 3000 }, }; - scenario('should remove alert from graph panel', graphPanel, ctx => { + scenario('should remove alert from graph panel', graphPanel, (ctx: any) => { expect(ctx.panel.alert).toBe(undefined); }); - scenario('should remove threshold from graph panel', graphPanel, ctx => { + scenario('should remove threshold from graph panel', graphPanel, (ctx: any) => { expect(ctx.panel.thresholds).toBe(undefined); }); - scenario('singlestat should keep threshold', { id: 1, type: 'singlestat', thresholds: { value: 3000 } }, ctx => { - expect(ctx.panel.thresholds).not.toBe(undefined); - }); + scenario( + 'singlestat should keep threshold', + { id: 1, type: 'singlestat', thresholds: { value: 3000 } }, + (ctx: any) => { + expect(ctx.panel.thresholds).not.toBe(undefined); + } + ); - scenario('table should keep threshold', { id: 1, type: 'table', thresholds: { value: 3000 } }, ctx => { + scenario('table should keep threshold', { id: 1, type: 'table', thresholds: { value: 3000 } }, (ctx: any) => { expect(ctx.panel.thresholds).not.toBe(undefined); }); }); diff --git a/public/app/features/dashboard/components/SaveModals/SaveDashboardAsModalCtrl.ts b/public/app/features/dashboard/components/SaveModals/SaveDashboardAsModalCtrl.ts index 748acb94831..2241287ad6f 100644 --- a/public/app/features/dashboard/components/SaveModals/SaveDashboardAsModalCtrl.ts +++ b/public/app/features/dashboard/components/SaveModals/SaveDashboardAsModalCtrl.ts @@ -1,4 +1,6 @@ import coreModule from 'app/core/core_module'; +import { DashboardSrv } from '../../services/DashboardSrv'; +import { PanelModel } from '../../state/PanelModel'; const template = `