feat(ui): Automatically refresh workflows in the "Actions" list (#7361)
- Make the "Actions" list (for example, https://codeberg.org/forgejo/forgejo/actions) dynamically refresh using htmx and partial page reloading. This addresses a pet peeve of mine, I find it common to end up on this page and have workflows in-progress, but not be able to monitor the workflows to success or failure from the page as it currently doesn't do any data refreshing. - There are a few major risks involves with this change. - Increased server-side load & network utilization. In order to mitigate this risk, I have configured the refresh to occur every 30 seconds **only** when the Page Visibility API indicates that the web page is currently visible to the end-user. It is still reasonable to assume this change will increase server-side load though. - UI interactions on the page, such as the "Actor" and "Status" dropdown and the workflow dispatch form, would be replaced from the server with non-expanded UI during the refresh. This problem is prevented by stopping the refresh while these UIs are in their expanded states. - E2E tests added. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7361 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net> Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
This commit is contained in:
parent
c977585e4c
commit
6ad706aa88
4 changed files with 271 additions and 99 deletions
|
@ -31,8 +31,9 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
tplListActions base.TplName = "repo/actions/list"
|
||||
tplViewActions base.TplName = "repo/actions/view"
|
||||
tplListActions base.TplName = "repo/actions/list"
|
||||
tplListActionsInner base.TplName = "repo/actions/list_inner"
|
||||
tplViewActions base.TplName = "repo/actions/view"
|
||||
)
|
||||
|
||||
type Workflow struct {
|
||||
|
@ -67,6 +68,8 @@ func List(ctx *context.Context) {
|
|||
curWorkflow := ctx.FormString("workflow")
|
||||
ctx.Data["CurWorkflow"] = curWorkflow
|
||||
|
||||
listInner := ctx.FormBool("list_inner")
|
||||
|
||||
var workflows []Workflow
|
||||
if empty, err := ctx.Repo.GitRepo.IsEmpty(); err != nil {
|
||||
ctx.ServerError("IsEmpty", err)
|
||||
|
@ -250,7 +253,11 @@ func List(ctx *context.Context) {
|
|||
ctx.Data["Page"] = pager
|
||||
ctx.Data["HasWorkflowsOrRuns"] = len(workflows) > 0 || len(runs) > 0
|
||||
|
||||
ctx.HTML(http.StatusOK, tplListActions)
|
||||
if listInner {
|
||||
ctx.HTML(http.StatusOK, tplListActionsInner)
|
||||
} else {
|
||||
ctx.HTML(http.StatusOK, tplListActions)
|
||||
}
|
||||
}
|
||||
|
||||
// loadIsRefDeleted loads the IsRefDeleted field for each run in the list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue