File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import (
2929
3030const (
3131 tplProfileBigAvatar base.TplName = "shared/user/profile_big_avatar"
32+ tplFollowUnfollow base.TplName = "shared/user/follow_unfollow"
3233)
3334
3435// OwnerProfile render profile page for a user or a organization (aka, repo owner)
@@ -318,6 +319,15 @@ func Action(ctx *context.Context) {
318319 return
319320 }
320321
321- shared_user .PrepareContextForProfileBigAvatar (ctx )
322- ctx .HTML (http .StatusOK , tplProfileBigAvatar )
322+ if ctx .ContextUser .IsIndividual () {
323+ shared_user .PrepareContextForProfileBigAvatar (ctx )
324+ ctx .HTML (http .StatusOK , tplProfileBigAvatar )
325+ return
326+ } else if ctx .ContextUser .IsOrganization () {
327+ ctx .Data ["IsFollowing" ] = ctx .Doer != nil && user_model .IsFollowing (ctx , ctx .Doer .ID , ctx .ContextUser .ID )
328+ ctx .HTML (http .StatusOK , tplFollowUnfollow )
329+ return
330+ }
331+ log .Error ("Failed to apply action %q: unsupport context user type: %s" , ctx .FormString ("action" ), ctx .ContextUser .Type )
332+ ctx .Error (http .StatusBadRequest , fmt .Sprintf ("Action %q failed" , ctx .FormString ("action" )))
323333}
Original file line number Diff line number Diff line change 2525 {{svg "octicon-rss" 24}}
2626 </a>
2727 {{end}}
28- <button class="link-action ui basic button gt-mr-0" data-url="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
29- {{if $.IsFollowing}}
30- {{ctx.Locale.Tr "user.unfollow"}}
31- {{else}}
32- {{ctx.Locale.Tr "user.follow"}}
33- {{end}}
34- </button>
28+ {{if .IsSigned}}
29+ <button class="ui basic button gt-mr-0" hx-post="{{.Org.HomeLink}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}">
30+ {{if $.IsFollowing}}
31+ {{ctx.Locale.Tr "user.unfollow"}}
32+ {{else}}
33+ {{ctx.Locale.Tr "user.follow"}}
34+ {{end}}
35+ </button>
36+ {{end}}
3537 </div>
3638 </div>
3739
You can’t perform that action at this time.
0 commit comments