From 91424fff3def09970c71c5725643daa4c5b141de Mon Sep 17 00:00:00 2001 From: Norwin Date: Fri, 19 Feb 2021 23:06:56 +0000 Subject: [PATCH] stopwatch notif: check if timetracking is enabled (#14750) fixes #14435 --- modules/templates/helper.go | 3 +++ templates/base/head.tmpl | 1 + web_src/js/features/stopwatch.js | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 00ccd49cb4..4b9b648b2f 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -174,6 +174,9 @@ func NewFuncMap() []template.FuncMap { "UseServiceWorker": func() bool { return setting.UI.UseServiceWorker }, + "EnableTimetracking": func() bool { + return setting.Service.EnableTimetracking + }, "FilenameIsImage": func(filename string) bool { mimeType := mime.TypeByExtension(filepath.Ext(filename)) return strings.HasPrefix(mimeType, "image/") diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 1dcaea8560..2feaf1dda4 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -42,6 +42,7 @@ MaxTimeout: {{NotificationSettings.MaxTimeout}}, EventSourceUpdateTime: {{NotificationSettings.EventSourceUpdateTime}}, }, + EnableTimetracking: {{if EnableTimetracking}}true{{else}}false{{end}}, PageIsProjects: {{if .PageIsProjects }}true{{else}}false{{end}}, {{if .RequireTribute}} tributeValues: Array.from(new Map([ diff --git a/web_src/js/features/stopwatch.js b/web_src/js/features/stopwatch.js index 433f042a1f..61f19bd795 100644 --- a/web_src/js/features/stopwatch.js +++ b/web_src/js/features/stopwatch.js @@ -1,11 +1,14 @@ import prettyMilliseconds from 'pretty-ms'; -const {AppSubUrl, csrf, NotificationSettings} = window.config; +const {AppSubUrl, csrf, NotificationSettings, EnableTimetracking} = window.config; let updateTimeInterval = null; // holds setInterval id when active export async function initStopwatch() { - const stopwatchEl = $('.active-stopwatch-trigger'); + if (!EnableTimetracking) { + return; + } + const stopwatchEl = $('.active-stopwatch-trigger'); stopwatchEl.removeAttr('href'); // intended for noscript mode only stopwatchEl.popup({ position: 'bottom right', -- 2.39.5