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 = `