From 32069ea229915e95f4b995ec8f1f3d4951caba5d Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 21 Oct 2021 09:29:14 +0100 Subject: [PATCH] Dahboard: Only show "Another session is editing this dashboard" once per edit session (#40485) (#40487) (cherry picked from commit 0c5491d6fde3b36e599cfdd4b4a164a80dd1a095) Co-authored-by: An --- public/app/features/live/dashboard/dashboardWatcher.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/app/features/live/dashboard/dashboardWatcher.ts b/public/app/features/live/dashboard/dashboardWatcher.ts index a49de120d17..847cc6f80e1 100644 --- a/public/app/features/live/dashboard/dashboardWatcher.ts +++ b/public/app/features/live/dashboard/dashboardWatcher.ts @@ -1,6 +1,6 @@ import { getGrafanaLiveSrv, locationService } from '@grafana/runtime'; import { getDashboardSrv } from '../../dashboard/services/DashboardSrv'; -import { appEvents } from 'app/core/core'; +import { appEvents, contextSrv } from 'app/core/core'; import { AppEvents, isLiveChannelMessageEvent, @@ -24,12 +24,14 @@ class DashboardWatcher { editing = false; lastEditing?: DashboardEvent; subscription?: Unsubscribable; + hasSeenNotice?: boolean; setEditingState(state: boolean) { const changed = (this.editing = state); this.editing = state; + this.hasSeenNotice = false; - if (changed) { + if (changed && contextSrv.isEditor) { this.sendEditingState(); } } @@ -131,10 +133,11 @@ class DashboardWatcher { this.reloadPage(); } } else if (showPopup) { - if (action === DashboardEventAction.EditingStarted) { + if (action === DashboardEventAction.EditingStarted && !this.hasSeenNotice) { const editingEvent = event.message; const recent = this.getRecentEditingEvent(); if (!recent || recent.message !== editingEvent.message) { + this.hasSeenNotice = true; appEvents.emit(AppEvents.alertWarning, [ 'Another session is editing this dashboard', editingEvent.message,