From 217647f33170d469ed392e3284cc1149047c1b74 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 5 Jul 2020 20:38:03 +0100 Subject: [PATCH] Multiple small admin dashboard fixes (#12153) * Remove spurious spacing between Maintenance Operations and its table on dashboard * Prevent (EXTRA string) comments in Task headers * Redirect tasks started from monitor page back to monitor * Fix #12107 - redirects from process cancel should use AppSubUrl * When wrapping queues set the name correctly Signed-off-by: Andrew Thornton --- modules/auth/admin.go | 3 ++- modules/queue/setting.go | 1 + options/locale/locale_en-US.ini | 12 ++++++------ routers/admin/admin.go | 9 ++++++--- templates/admin/dashboard.tmpl | 10 +++++----- templates/admin/monitor.tmpl | 1 + 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/modules/auth/admin.go b/modules/auth/admin.go index af7197d2ae..9caf81e07f 100644 --- a/modules/auth/admin.go +++ b/modules/auth/admin.go @@ -51,7 +51,8 @@ func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) // AdminDashboardForm form for admin dashboard operations type AdminDashboardForm struct { - Op string `binding:"required"` + Op string `binding:"required"` + From string } // Validate validates form fields diff --git a/modules/queue/setting.go b/modules/queue/setting.go index c47e85f756..786a08a3b0 100644 --- a/modules/queue/setting.go +++ b/modules/queue/setting.go @@ -75,6 +75,7 @@ func CreateQueue(name string, handle HandlerFunc, exemplar interface{}) Queue { MaxAttempts: q.MaxAttempts, Config: cfg, QueueLength: q.Length, + Name: name, }, exemplar) } if err != nil { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 036665256d..7968d00b58 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1867,12 +1867,12 @@ dashboard.operation_switch = Switch dashboard.operation_run = Run dashboard.clean_unbind_oauth = Clean unbound OAuth connections dashboard.clean_unbind_oauth_success = All unbound OAuth connections have been deleted. -dashboard.task.started=Started Task: %s -dashboard.task.process=Task: %s -dashboard.task.cancelled=Task: %s cancelled: %[3]s -dashboard.task.error=Error in Task: %s: %[3]s -dashboard.task.finished=Task: %s started by %s has finished -dashboard.task.unknown=Unknown task: %s +dashboard.task.started=Started Task: %[1]s +dashboard.task.process=Task: %[1]s +dashboard.task.cancelled=Task: %[1]s cancelled: %[3]s +dashboard.task.error=Error in Task: %[1]s: %[3]s +dashboard.task.finished=Task: %[1]s started by %[2]s has finished +dashboard.task.unknown=Unknown task: %[1]s dashboard.cron.started=Started Cron: %[1]s dashboard.cron.process=Cron: %[1]s dashboard.cron.cancelled=Cron: %s cancelled: %[3]s diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 7595f4929d..e48e416258 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -153,8 +153,11 @@ func DashboardPost(ctx *context.Context, form auth.AdminDashboardForm) { ctx.Flash.Error(ctx.Tr("admin.dashboard.task.unknown", form.Op)) } } - - ctx.Redirect(setting.AppSubURL + "/admin") + if form.From == "monitor" { + ctx.Redirect(setting.AppSubURL + "/admin/monitor") + } else { + ctx.Redirect(setting.AppSubURL + "/admin") + } } // SendTestMail send test mail to confirm mail service is OK @@ -331,7 +334,7 @@ func MonitorCancel(ctx *context.Context) { pid := ctx.ParamsInt64("pid") process.GetManager().Cancel(pid) ctx.JSON(200, map[string]interface{}{ - "redirect": ctx.Repo.RepoLink + "/admin/monitor", + "redirect": setting.AppSubURL + "/admin/monitor", }) } diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index c1ac8fb489..f6acc9457f 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -14,9 +14,9 @@

{{.i18n.Tr "admin.dashboard.operations"}}

-
-
- {{.CsrfTokenHtml}} + + {{.CsrfTokenHtml}} +
@@ -62,8 +62,8 @@
- -
+
+

{{.i18n.Tr "admin.dashboard.system_status"}} diff --git a/templates/admin/monitor.tmpl b/templates/admin/monitor.tmpl index 2980a2e9d8..8dd0d939d7 100644 --- a/templates/admin/monitor.tmpl +++ b/templates/admin/monitor.tmpl @@ -8,6 +8,7 @@

+ {{.CsrfTokenHtml}}