Refactor htmx and fetch-action related code (#37186)
This is the first step (the hardest part): * repo file list last commit message lazy load * admin server status monitor * watch/unwatch (normal page, watchers page) * star/unstar (normal page, watchers page) * project view, delete column * workflow dispatch, switch the branch * commit page: load branches and tags referencing this commit The legacy "data-redirect" attribute is removed, it only makes the page reload (sometimes using an incorrect link). Also did cleanup for some devtest pages.
This commit is contained in:
@@ -26,6 +26,5 @@ func ActionStar(ctx *context.Context) {
|
||||
ctx.ServerError("GetRepositoryByName", err)
|
||||
return
|
||||
}
|
||||
ctx.RespHeader().Add("hx-trigger", "refreshUserCards") // see the `hx-trigger="refreshUserCards ..."` comments in tmpl
|
||||
ctx.HTML(http.StatusOK, tplStarUnstar)
|
||||
}
|
||||
|
||||
@@ -310,13 +310,15 @@ func renderDirectoryFiles(ctx *context.Context, timeout time.Duration) git.Entri
|
||||
return nil
|
||||
}
|
||||
|
||||
{
|
||||
{ // this block is for testing purpose only
|
||||
if timeout != 0 && !setting.IsProd && !setting.IsInTesting {
|
||||
log.Debug("first call to get directory file commit info")
|
||||
clearFilesCommitInfo := func() {
|
||||
log.Warn("clear directory file commit info to force async loading on frontend")
|
||||
for i := range files {
|
||||
files[i].Commit = nil
|
||||
if i%2 == 0 { // for testing purpose, only clear half of the files' commit info
|
||||
files[i].Commit = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = clearFilesCommitInfo
|
||||
|
||||
@@ -26,6 +26,5 @@ func ActionWatch(ctx *context.Context) {
|
||||
ctx.ServerError("GetRepositoryByName", err)
|
||||
return
|
||||
}
|
||||
ctx.RespHeader().Add("hx-trigger", "refreshUserCards") // see the `hx-trigger="refreshUserCards ..."` comments in tmpl
|
||||
ctx.HTML(http.StatusOK, tplWatchUnwatch)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user