Skip to content

Commit

Permalink
add rollback to get private profile when view as is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
changchaishi committed Dec 23, 2024
1 parent c93b960 commit 55af509
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
30 changes: 19 additions & 11 deletions routers/web/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,30 @@ func home(ctx *context.Context, viewRepositories bool) {
queryParams.Set("view_as", "public")
ctx.Data["QueryForPublic"] = html_template.URL(queryParams.Encode())

isViewerMember := ctx.FormString("view_as") == "member"
ctx.Data["IsViewerMember"] = isViewerMember
err = shared_user.RenderOrgHeader(ctx)
if err != nil {
ctx.ServerError("RenderOrgHeader", err)
return
}

isViewerMember := ctx.FormString("view_as")
ctx.Data["IsViewerMember"] = isViewerMember == "member"

profileType := "Public"
if isViewerMember {
if isViewerMember == "member" {
profileType = "Private"
}

if !prepareOrgProfileReadme(ctx, viewRepositories, profileType) {
ctx.Data["PageIsViewRepositories"] = true
}

err = shared_user.RenderOrgHeader(ctx)
if err != nil {
ctx.ServerError("RenderOrgHeader", err)
return
if isViewerMember == "" {
if !prepareOrgProfileReadme(ctx, viewRepositories, "Public") {
if !prepareOrgProfileReadme(ctx, viewRepositories, "Private") {
ctx.Data["PageIsViewRepositories"] = true
}
}
} else {
if !prepareOrgProfileReadme(ctx, viewRepositories, profileType) {
ctx.Data["PageIsViewRepositories"] = true
}
}

var (
Expand Down
13 changes: 5 additions & 8 deletions templates/org/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
</div>
{{end}}
{{end}}
{{if .IsViewerMember}}
{{if and .ShowMemberAndTeamTab .PrivateProfileReadme}}
<div id="readme_profile" class="markup">{{.PrivateProfileReadme}}</div>
{{end}}
{{else}}
{{if .PublicProfileReadme}}
<div id="readme_profile" class="markup">{{.PublicProfileReadme}}</div>
{{end}}
{{if .PrivateProfileReadme}}
<div id="readme_profile" class="markup">{{.PrivateProfileReadme}}</div>
{{end}}
{{if .PublicProfileReadme}}
<div id="readme_profile" class="markup">{{.PublicProfileReadme}}</div>
{{end}}
{{template "shared/repo_search" .}}
{{template "explore/repo_list" .}}
Expand Down

0 comments on commit 55af509

Please sign in to comment.