From 5e484e83931d9b3169daf8218066a4dff439b2ee Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Mon, 4 Jun 2018 13:52:17 +0200 Subject: [PATCH 1/4] added if to check if new variable has been added --- public/app/features/dashboard/save_modal.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/app/features/dashboard/save_modal.ts b/public/app/features/dashboard/save_modal.ts index 1c364fbc55f..7a753f3653e 100644 --- a/public/app/features/dashboard/save_modal.ts +++ b/public/app/features/dashboard/save_modal.ts @@ -91,6 +91,9 @@ export class SaveDashboardModalCtrl { } compareTemplating() { + if (this.dashboardSrv.dash.originalTemplating.length !== this.dashboardSrv.dash.templating.list.length) { + return (this.variableChange = false); + } if (this.dashboardSrv.dash.templating.list.length > 0) { for (let i = 0; i < this.dashboardSrv.dash.templating.list.length; i++) { if ( From 609b0fa498e72f40a2d4bff5442760806d53130a Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Mon, 4 Jun 2018 14:05:35 +0200 Subject: [PATCH 2/4] added a test --- .../dashboard/specs/save_modal.jest.ts | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/specs/save_modal.jest.ts b/public/app/features/dashboard/specs/save_modal.jest.ts index 05281cc6097..f55cae75f4b 100644 --- a/public/app/features/dashboard/specs/save_modal.jest.ts +++ b/public/app/features/dashboard/specs/save_modal.jest.ts @@ -54,7 +54,6 @@ describe('SaveDashboardModal', () => { { current: { selected: true, - //tags: Array(0), text: 'server_002', value: 'server_002', }, @@ -86,5 +85,44 @@ describe('SaveDashboardModal', () => { expect(modal.timeChange).toBe(false); expect(modal.variableChange).toBe(false); }); + + it('should hide variable checkboxes', () => { + let fakeDashboardSrv = { + dash: { + templating: { + list: [ + { + current: { + selected: true, + text: 'server_002', + value: 'server_002', + }, + name: 'Server', + }, + { + current: { + selected: true, + text: 'web_002', + value: 'web_002', + }, + name: 'Web', + }, + ], + }, + originalTemplating: [ + { + current: { + selected: true, + text: 'server_002', + value: 'server_002', + }, + name: 'Server', + }, + ], + }, + }; + let modal = new SaveDashboardModalCtrl(fakeDashboardSrv); + expect(modal.variableChange).toBe(false); + }); }); }); From b122f53085a44103baba6f19989961f4bcddb046 Mon Sep 17 00:00:00 2001 From: Patrick O'Carroll Date: Mon, 4 Jun 2018 15:35:34 +0200 Subject: [PATCH 3/4] added comment, variableChange -> variableValueChange --- public/app/features/dashboard/save_modal.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/public/app/features/dashboard/save_modal.ts b/public/app/features/dashboard/save_modal.ts index 7a753f3653e..be6738f6d5f 100644 --- a/public/app/features/dashboard/save_modal.ts +++ b/public/app/features/dashboard/save_modal.ts @@ -16,13 +16,13 @@ const template = `