Skip to content

Commit b84f765

Browse files
committed
fix
1 parent 0593b58 commit b84f765

10 files changed

Lines changed: 30 additions & 36 deletions

File tree

routers/web/repo/issue_watch.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package repo
55

66
import (
77
"net/http"
8-
"strconv"
98

109
issues_model "code.gitea.io/gitea/models/issues"
1110
"code.gitea.io/gitea/modules/log"
@@ -46,12 +45,7 @@ func IssueWatch(ctx *context.Context) {
4645
return
4746
}
4847

49-
watch, err := strconv.ParseBool(ctx.Req.PostFormValue("watch"))
50-
if err != nil {
51-
ctx.ServerError("watch is not bool", err)
52-
return
53-
}
54-
48+
watch := ctx.FormBool("watch")
5549
if err := issues_model.CreateOrUpdateIssueWatch(ctx, ctx.Doer.ID, issue.ID, watch); err != nil {
5650
ctx.ServerError("CreateOrUpdateIssueWatch", err)
5751
return

services/gitdiff/gitdiff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func (d *DiffLine) RenderBlobExcerptButtons(fileNameHash string, data *DiffBlobE
228228
link += fmt.Sprintf("&pull_issue_index=%d", data.PullIssueIndex)
229229
}
230230
return htmlutil.HTMLFormat(
231-
`<button class="code-expander-button" hx-target="closest tr" hx-get="%s" data-hidden-comment-ids=",%s,">%s</button>`,
231+
`<button class="code-expander-button" data-fetch-sync="$closest(tr)" data-fetch-url="%s" data-hidden-comment-ids=",%s,">%s</button>`,
232232
link, dataHiddenCommentIDs, svg.RenderHTML(svgName),
233233
)
234234
}

templates/base/head.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{{template "base/head_script" .}}
2424
{{template "custom/header" .}}
2525
</head>
26-
<body hx-swap="outerHTML" hx-push-url="false">
26+
<body>
2727
{{template "custom/body_outer_pre" .}}
2828

2929
<div class="full height">

templates/org/follow_unfollow.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<button class="ui basic button tw-mr-0" hx-post="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
1+
<button class="ui basic button" data-fetch-method="post" data-fetch-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
22
{{if $.IsFollowing}}
33
{{ctx.Locale.Tr "user.unfollow"}}
44
{{else}}

templates/org/header.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
{{if .Org.Visibility.IsLimited}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.limited_shortname"}}</span>{{end}}
88
{{if .Org.Visibility.IsPrivate}}<span class="ui large basic horizontal label">{{ctx.Locale.Tr "org.settings.visibility.private_shortname"}}</span>{{end}}
99
</span>
10-
<span class="flex-text-inline tw-ml-auto tw-text-16 tw-whitespace-nowrap">
10+
<span class="flex-text-block tw-ml-auto tw-text-16 tw-whitespace-nowrap">
1111
{{if .EnableFeed}}
12-
<a class="ui basic label button tw-mr-0" href="{{.Org.HomeLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">
12+
<a class="ui basic label button" href="{{.Org.HomeLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">
1313
{{svg "octicon-rss" 24}}
1414
</a>
1515
{{end}}

templates/repo/editor/edit.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}}</a>
2424
<a class="item{{if not .CodeEditorConfig.Previewable}} tw-hidden{{end}}" data-tab="preview" data-preview-url="{{.Repository.Link}}/markup" data-preview-context-ref="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a>
2525
{{if not .IsNewFile}}
26+
{{/*FIXME: the related logic is totally a mess, need to completely rewrite, that's also the root reason for
27+
why the "migrate to CodeMirror" PR took very long time on the legacy code and introduced "#file-name (filenameInput)" regressions many times*/}}
2628
<a class="item" data-tab="diff" hx-params="context,content" hx-vals='{"context":"{{.BranchLink}}"}' hx-include="#edit_area" hx-swap="innerHTML" hx-target=".tab[data-tab='diff']" hx-indicator=".tab[data-tab='diff']" hx-post="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">{{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}}</a>
2729
{{end}}
2830
</div>
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
<form hx-boost="true" hx-sync="this:replace" hx-target="this" method="post" action="{{.Issue.Link}}/watch">
2-
<input type="hidden" name="watch" value="{{if $.IssueWatch.IsWatching}}0{{else}}1{{end}}">
3-
<button class="fluid ui button">
4-
{{if $.IssueWatch.IsWatching}}
5-
{{svg "octicon-mute" 16}}
6-
{{ctx.Locale.Tr "repo.issues.unsubscribe"}}
7-
{{else}}
8-
{{svg "octicon-unmute" 16}}
9-
{{ctx.Locale.Tr "repo.issues.subscribe"}}
10-
{{end}}
11-
</button>
12-
</form>
1+
<button class="fluid ui button" type="button" data-fetch-method="post" data-fetch-url="{{.Issue.Link}}/watch?watch={{not $.IssueWatch.IsWatching}}">
2+
{{if $.IssueWatch.IsWatching}}
3+
{{svg "octicon-mute" 16}} {{ctx.Locale.Tr "repo.issues.unsubscribe"}}
4+
{{else}}
5+
{{svg "octicon-unmute" 16}} {{ctx.Locale.Tr "repo.issues.subscribe"}}
6+
{{end}}
7+
</button>

templates/shared/user/profile_big_avatar.tmpl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,19 @@
115115
{{end}}
116116
{{if and .IsSigned (ne .SignedUserID .ContextUser.ID)}}
117117
{{if not .UserBlocking}}
118-
<li class="follow" hx-target="#profile-avatar-card" hx-indicator="#profile-avatar-card">
119-
{{if $.IsFollowing}}
120-
<button hx-post="{{.ContextUser.HomeLink}}?action=unfollow" class="ui basic red button">
118+
<li class="follow">
119+
{{$buttonExtraClass := Iif $.IsFollowing "" "primary"}}
120+
{{$followAction := Iif $.IsFollowing "unfollow" "follow"}}
121+
<button class="ui basic {{$buttonExtraClass}} button"
122+
data-fetch-method="post" data-fetch-url="{{.ContextUser.HomeLink}}?action={{$followAction}}"
123+
data-fetch-sync="$body #profile-avatar-card"
124+
>
125+
{{if $.IsFollowing}}
121126
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.unfollow"}}
122-
</button>
123-
{{else}}
124-
<button hx-post="{{.ContextUser.HomeLink}}?action=follow" class="ui basic primary button">
127+
{{else}}
125128
{{svg "octicon-person"}} {{ctx.Locale.Tr "user.follow"}}
126-
</button>
127-
{{end}}
129+
{{end}}
130+
</button>
128131
</li>
129132
{{end}}
130133
<li>

templates/user/notification/notification_div.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
{{DateUtils.TimeSince $one.UpdatedUnix}}
5454
{{end}}
5555
</div>
56-
<form class="notifications-buttons" action="{{AppSubUrl}}/notifications/status?type={{$.PageType}}&page={{$.Page.Paginater.Current}}&perPage={{$.Page.Paginater.PagingNum}}" method="post"
57-
hx-boost="true" hx-target="#notification_div" hx-swap="outerHTML"
56+
<form class="notifications-buttons form-fetch-action" action="{{AppSubUrl}}/notifications/status?type={{$.PageType}}&page={{$.Page.Paginater.Current}}&perPage={{$.Page.Paginater.PagingNum}}" method="post"
57+
data-fetch-sync="$body #notification_div"
5858
>
5959
<input type="hidden" name="notification_id" value="{{$one.ID}}">
6060
{{if ne $one.Status $statusPinned}}

tests/integration/compare_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ func TestCompareCodeExpand(t *testing.T) {
147147
req := NewRequest(t, "GET", "/user1/test_blob_excerpt/compare/main...user2/test_blob_excerpt-fork:forked-branch")
148148
resp := session.MakeRequest(t, req, http.StatusOK)
149149
htmlDoc := NewHTMLParser(t, resp.Body)
150-
els := htmlDoc.Find(`button.code-expander-button[hx-get]`)
150+
els := htmlDoc.Find(`button.code-expander-button[data-fetch-url]`)
151151

152152
// all the links in the comparison should be to the forked repo&branch
153153
assert.NotZero(t, els.Length())
154154
for i := 0; i < els.Length(); i++ {
155-
link := els.Eq(i).AttrOr("hx-get", "")
155+
link := els.Eq(i).AttrOr("data-fetch-url", "")
156156
assert.True(t, strings.HasPrefix(link, "/user2/test_blob_excerpt-fork/blob_excerpt/"))
157157
}
158158
})

0 commit comments

Comments
 (0)