Skip to content

Commit 91424ff

Browse files
authored
stopwatch notif: check if timetracking is enabled (#14750)
fixes #14435
1 parent aa4f918 commit 91424ff

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

modules/templates/helper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ func NewFuncMap() []template.FuncMap {
174174
"UseServiceWorker": func() bool {
175175
return setting.UI.UseServiceWorker
176176
},
177+
"EnableTimetracking": func() bool {
178+
return setting.Service.EnableTimetracking
179+
},
177180
"FilenameIsImage": func(filename string) bool {
178181
mimeType := mime.TypeByExtension(filepath.Ext(filename))
179182
return strings.HasPrefix(mimeType, "image/")

templates/base/head.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
MaxTimeout: {{NotificationSettings.MaxTimeout}},
4343
EventSourceUpdateTime: {{NotificationSettings.EventSourceUpdateTime}},
4444
},
45+
EnableTimetracking: {{if EnableTimetracking}}true{{else}}false{{end}},
4546
PageIsProjects: {{if .PageIsProjects }}true{{else}}false{{end}},
4647
{{if .RequireTribute}}
4748
tributeValues: Array.from(new Map([

web_src/js/features/stopwatch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import prettyMilliseconds from 'pretty-ms';
2-
const {AppSubUrl, csrf, NotificationSettings} = window.config;
2+
const {AppSubUrl, csrf, NotificationSettings, EnableTimetracking} = window.config;
33

44
let updateTimeInterval = null; // holds setInterval id when active
55

66
export async function initStopwatch() {
7-
const stopwatchEl = $('.active-stopwatch-trigger');
7+
if (!EnableTimetracking) {
8+
return;
9+
}
810

11+
const stopwatchEl = $('.active-stopwatch-trigger');
912
stopwatchEl.removeAttr('href'); // intended for noscript mode only
1013
stopwatchEl.popup({
1114
position: 'bottom right',

0 commit comments

Comments
 (0)