File tree 2 files changed +21
-9
lines changed
2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import (
31
31
32
32
const (
33
33
tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
34
+ tplFollowUnfollow base.TplName = "shared/user/follow_unfollow"
34
35
)
35
36
36
37
// OwnerProfile render profile page for a user or a organization (aka, repo owner)
@@ -349,6 +350,15 @@ func Action(ctx *context.Context) {
349
350
return
350
351
}
351
352
352
- shared_user .PrepareContextForProfileBigAvatar (ctx )
353
- ctx .HTML (http .StatusOK , tplProfileBigAvatar )
353
+ if ctx .ContextUser .IsIndividual () {
354
+ shared_user .PrepareContextForProfileBigAvatar (ctx )
355
+ ctx .HTML (http .StatusOK , tplProfileBigAvatar )
356
+ return
357
+ } else if ctx .ContextUser .IsOrganization () {
358
+ ctx .Data ["IsFollowing" ] = ctx .Doer != nil && user_model .IsFollowing (ctx , ctx .Doer .ID , ctx .ContextUser .ID )
359
+ ctx .HTML (http .StatusOK , tplFollowUnfollow )
360
+ return
361
+ }
362
+ log .Error ("Failed to apply action %q: unsupport context user type: %s" , ctx .FormString ("action" ), ctx .ContextUser .Type )
363
+ ctx .Error (http .StatusBadRequest , fmt .Sprintf ("Action %q failed" , ctx .FormString ("action" )))
354
364
}
Original file line number Diff line number Diff line change 30
30
{{svg "octicon-rss" 24}}
31
31
</a>
32
32
{{end}}
33
- <button class="link-action ui basic button gt-mr-0" data-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
34
- {{if $.IsFollowing}}
35
- {{ctx.Locale.Tr "user.unfollow"}}
36
- {{else}}
37
- {{ctx.Locale.Tr "user.follow"}}
38
- {{end}}
39
- </button>
33
+ {{if .IsSigned}}
34
+ <button class="ui basic button gt-mr-0" hx-post="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
35
+ {{if $.IsFollowing}}
36
+ {{ctx.Locale.Tr "user.unfollow"}}
37
+ {{else}}
38
+ {{ctx.Locale.Tr "user.follow"}}
39
+ {{end}}
40
+ </button>
41
+ {{end}}
40
42
</div>
41
43
</div>
42
44
You can’t perform that action at this time.
0 commit comments