Skip to content

Fix inconsistent user profile layout across tabs #25625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
519293d
Adjusting profile layout for package, project and code page.
puni9869 Jul 2, 2023
aaa5f71
Templates and go file formatting
puni9869 Jul 2, 2023
2fedaf3
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 2, 2023
eae7940
fix merge
wxiaoguang Jul 2, 2023
b0bd1ea
fix merge
wxiaoguang Jul 2, 2023
8eb033e
Fixing page-content style
puni9869 Jul 2, 2023
907a710
Removing page-content to gt-mt-4
puni9869 Jul 2, 2023
cbd0ca8
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 3, 2023
9d6c8cf
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 3, 2023
bef3289
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 3, 2023
c3f23d1
Fix :: Suggestions Removing page-content
puni9869 Jul 3, 2023
110081a
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 3, 2023
110e50b
Adding style in package version list
puni9869 Jul 3, 2023
8b9a080
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 3, 2023
656191a
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 3, 2023
f3ee922
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 4, 2023
617544c
fix style in package/repo
puni9869 Jul 4, 2023
aeb49f9
Adding style in packages in repo package
puni9869 Jul 4, 2023
0e9e8be
Formatting templates
puni9869 Jul 4, 2023
52cfeec
Adding style
puni9869 Jul 4, 2023
5b18ff6
Formatting templates
puni9869 Jul 4, 2023
55121d6
Adding context to the profile version list package page
puni9869 Jul 4, 2023
7ed8299
Fixing linter issues in templates
puni9869 Jul 4, 2023
2cf7ff8
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 4, 2023
1113af0
Resolving conflicts
puni9869 Jul 4, 2023
1165409
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 4, 2023
e0289ad
Fixing kanban board header
puni9869 Jul 5, 2023
6623348
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 5, 2023
44c2edd
Fixing in edit project org projects
puni9869 Jul 5, 2023
ee1413d
Adding org header avatar
puni9869 Jul 5, 2023
eaa7ee8
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 5, 2023
6e3c782
fix merge
wxiaoguang Jul 5, 2023
ab9b005
fix container layout
wxiaoguang Jul 5, 2023
1571c37
Merge branch 'main' into punit/ISSUE-24871-user-profile-orig
wxiaoguang Jul 5, 2023
7ec582b
revert unnecessary new lines
wxiaoguang Jul 5, 2023
3c5652d
rewrite
wxiaoguang Jul 5, 2023
fd85288
rewrite
wxiaoguang Jul 5, 2023
b29bbfa
rewrite
wxiaoguang Jul 5, 2023
6c93f71
rewrite
wxiaoguang Jul 5, 2023
f355415
fix
wxiaoguang Jul 5, 2023
da7bf21
remove unused code
wxiaoguang Jul 5, 2023
9046994
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 5, 2023
deceaf1
Merge branch 'main' into punit/ISSUE-24871-user-profile
puni9869 Jul 6, 2023
ab0ad22
Merge branch 'main' into punit/ISSUE-24871-user-profile
GiteaBot Jul 6, 2023
0162ec5
Merge branch 'main' into punit/ISSUE-24871-user-profile
GiteaBot Jul 6, 2023
36660f6
Merge branch 'main' into punit/ISSUE-24871-user-profile
GiteaBot Jul 6, 2023
8e6f3c2
Merge branch 'main' into punit/ISSUE-24871-user-profile
GiteaBot Jul 6, 2023
b670669
dedent templates/user/overview/header.tmpl
silverwind Jul 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions routers/web/org/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func MustEnableProjects(ctx *context.Context) {

// Projects renders the home page of projects
func Projects(ctx *context.Context) {
shared_user.PrepareContextForProfileBigAvatar(ctx)
if ctx.ContextUser.IsOrganization() {
ctx.Data["pageStyleClasses"] = "container"
}
ctx.Data["Title"] = ctx.Tr("repo.project_board")

sortType := ctx.FormTrim("sort")
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ func Packages(ctx *context.Context) {
pager.AddParam(ctx, "q", "Query")
pager.AddParam(ctx, "type", "PackageType")
ctx.Data["Page"] = pager

ctx.Data["pageStyleClasses"] = "container"
ctx.HTML(http.StatusOK, tplPackagesList)
}
90 changes: 90 additions & 0 deletions routers/web/shared/user/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,102 @@
package user

import (
"fmt"

"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/organization"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
)

// PrepareContextForProfileBigAvatar set the context for big avatar view on repo
func PrepareContextForProfileBigAvatar(ctx *context.Context) {
// check view permissions
if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name))
return
}

// advertise feed via meta tag
ctx.Data["FeedURL"] = ctx.ContextUser.HomeLink()

// Show OpenID URIs
openIDs, err := user_model.GetUserOpenIDs(ctx.ContextUser.ID)
if err != nil {
ctx.ServerError("GetUserOpenIDs", err)
return
}

var isFollowing bool
if ctx.Doer != nil {
isFollowing = user_model.IsFollowing(ctx.Doer.ID, ctx.ContextUser.ID)
}

ctx.Data["ContextUser"] = ctx.ContextUser
ctx.Data["OpenIDs"] = openIDs
ctx.Data["IsFollowing"] = isFollowing

if len(ctx.ContextUser.Description) != 0 {
content, err := markdown.RenderString(&markup.RenderContext{
URLPrefix: ctx.Repo.RepoLink,
Metas: map[string]string{"mode": "document"},
GitRepo: ctx.Repo.GitRepo,
Ctx: ctx,
}, ctx.ContextUser.Description)
if err != nil {
ctx.ServerError("RenderString", err)
return
}
ctx.Data["RenderedDescription"] = content
}
showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID)
orgs, err := organization.FindOrgs(organization.FindOrgOptions{
UserID: ctx.ContextUser.ID,
IncludePrivate: showPrivate,
})
if err != nil {
ctx.ServerError("FindOrgs", err)
return
}
ctx.Data["Orgs"] = orgs
ctx.Data["HasOrgsVisible"] = organization.HasOrgsVisible(orgs, ctx.Doer)

badges, _, err := user_model.GetUserBadges(ctx, ctx.ContextUser)
if err != nil {
ctx.ServerError("GetUserBadges", err)
return
}
ctx.Data["Badges"] = badges

pagingNum := setting.UI.User.RepoPagingNum
page := ctx.FormInt("page")
_, numFollowers, err := user_model.GetUserFollowers(ctx, ctx.ContextUser, ctx.Doer, db.ListOptions{
PageSize: pagingNum,
Page: page,
})
if err != nil {
ctx.ServerError("GetUserFollowers", err)
return
}
ctx.Data["NumFollowers"] = numFollowers
_, numFollowing, err := user_model.GetUserFollowing(ctx, ctx.ContextUser, ctx.Doer, db.ListOptions{
PageSize: pagingNum,
Page: page,
})
if err != nil {
ctx.ServerError("GetUserFollowing", err)
return
}
ctx.Data["NumFollowing"] = numFollowing
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail && ctx.ContextUser.Email != "" && ctx.IsSigned && !ctx.ContextUser.KeepEmailPrivate
ctx.Data["EnableFeed"] = setting.Other.EnableFeed
}

func RenderUserHeader(ctx *context.Context) {
ctx.Data["IsProjectEnabled"] = true
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
Expand Down
6 changes: 5 additions & 1 deletion routers/web/user/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/modules/context"
code_indexer "code.gitea.io/gitea/modules/indexer/code"
"code.gitea.io/gitea/modules/setting"
shared_user "code.gitea.io/gitea/routers/web/shared/user"
)

const (
Expand All @@ -19,11 +20,14 @@ const (

// CodeSearch render user/organization code search page
func CodeSearch(ctx *context.Context) {
shared_user.PrepareContextForProfileBigAvatar(ctx)
if ctx.ContextUser.IsOrganization() {
ctx.Data["pageStyleClasses"] = "container"
}
if !setting.Indexer.RepoIndexerEnabled {
ctx.Redirect(ctx.ContextUser.HomeLink())
return
}

ctx.Data["IsProjectEnabled"] = true
ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
Expand Down
13 changes: 7 additions & 6 deletions routers/web/user/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (

// ListPackages displays a list of all packages of the context user
func ListPackages(ctx *context.Context) {
shared_user.PrepareContextForProfileBigAvatar(ctx)
page := ctx.FormInt("page")
if page <= 1 {
page = 1
Expand Down Expand Up @@ -102,10 +103,10 @@ func ListPackages(ctx *context.Context) {

// TODO: context/org -> HandleOrgAssignment() can not be used
if ctx.ContextUser.IsOrganization() {
ctx.Data["pageStyleClasses"] = "container"
org := org_model.OrgFromUser(ctx.ContextUser)
ctx.Data["Org"] = org
ctx.Data["OrgLink"] = ctx.ContextUser.OrganisationLink()

if ctx.Doer != nil {
ctx.Data["IsOrganizationMember"], _ = org_model.IsOrganizationMember(ctx, org.ID, ctx.Doer.ID)
ctx.Data["IsOrganizationOwner"], _ = org_model.IsOrganizationOwner(ctx, org.ID, ctx.Doer.ID)
Expand Down Expand Up @@ -160,9 +161,8 @@ func RedirectToLastVersion(ctx *context.Context) {
// ViewPackageVersion displays a single package version
func ViewPackageVersion(ctx *context.Context) {
pd := ctx.Package.Descriptor

shared_user.RenderUserHeader(ctx)

ctx.Data["pageStyleClasses"] = "container"
ctx.Data["Title"] = pd.Package.Name
ctx.Data["IsPackagesPage"] = true
ctx.Data["PackageDescriptor"] = pd
Expand Down Expand Up @@ -259,6 +259,7 @@ func ViewPackageVersion(ctx *context.Context) {

// ListPackageVersions lists all versions of a package
func ListPackageVersions(ctx *context.Context) {
shared_user.PrepareContextForProfileBigAvatar(ctx)
p, err := packages_model.GetPackageByName(ctx, ctx.Package.Owner.ID, packages_model.Type(ctx.Params("type")), ctx.Params("name"))
if err != nil {
if err == packages_model.ErrPackageNotExist {
Expand All @@ -268,7 +269,7 @@ func ListPackageVersions(ctx *context.Context) {
}
return
}

ctx.Data["pageStyleClasses"] = "container"
page := ctx.FormInt("page")
if page <= 1 {
page = 1
Expand Down Expand Up @@ -356,7 +357,6 @@ func ListPackageVersions(ctx *context.Context) {
// PackageSettings displays the package settings page
func PackageSettings(ctx *context.Context) {
pd := ctx.Package.Descriptor

shared_user.RenderUserHeader(ctx)

ctx.Data["Title"] = pd.Package.Name
Expand All @@ -369,14 +369,15 @@ func PackageSettings(ctx *context.Context) {
})
ctx.Data["Repos"] = repos
ctx.Data["CanWritePackages"] = ctx.Package.AccessMode >= perm.AccessModeWrite || ctx.IsUserSiteAdmin()
ctx.Data["pageStyleClasses"] = "container"

ctx.HTML(http.StatusOK, tplPackagesSettings)
}

// PackageSettingsPost updates the package settings
func PackageSettingsPost(ctx *context.Context) {
pd := ctx.Package.Descriptor

ctx.Data["pageStyleClasses"] = "container"
form := web.GetForm(ctx).(*forms.PackageSettingForm)
switch form.Action {
case "link":
Expand Down
27 changes: 23 additions & 4 deletions templates/org/projects/list.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content repository packages">
{{template "user/overview/header" .}}
{{template "projects/list" .}}
</div>
{{if .ContextUser.IsOrganization}}
<div role="main" aria-label="{{.Title}}" class="page-content repository packages">
{{template "shared/user/org_profile_avatar" .}}
{{template "user/overview/header" .}}
{{template "projects/list" .}}
</div>
{{else}}
<div role="main" aria-label="{{.Title}}" class="page-content user profile">
<div class="ui container">
<div class="ui stackable grid">
<div class="ui four wide column">
{{template "shared/user/profile_big_avatar" .}}
</div>
<div class="ui twelve wide column">
<div class="gt-mb-4">
{{template "user/overview/header" .}}
</div>
{{template "projects/list" .}}
</div>
</div>
</div>
</div>
{{end}}
{{template "base/footer" .}}
104 changes: 56 additions & 48 deletions templates/package/shared/list.tmpl
Original file line number Diff line number Diff line change
@@ -1,55 +1,63 @@
<div class="ui container">
{{template "base/alert" .}}
<form class="ui form ignore-dirty">
<div class="ui fluid action input">
{{template "shared/searchinput" dict "locale" .locale "Value" .Query "AutoFocus" true}}
<select class="ui dropdown" name="type">
<option value="">{{.locale.Tr "packages.filter.type"}}</option>
<option value="all">{{.locale.Tr "packages.filter.type.all"}}</option>
{{range $type := .AvailableTypes}}
<option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
{{end}}
</select>
<button class="ui primary button">{{.locale.Tr "explore.search"}}</button>
</div>
</form>
<div class="ui {{if .PackageDescriptors}}issue list{{end}}">
{{range .PackageDescriptors}}
<li class="item gt-df gt-py-3">
<div class="issue-item-main">
<div class="issue-item-top-row">
<a class="title" href="{{.FullWebLink}}">{{.Package.Name}}</a>
<span class="ui label">{{svg .Package.Type.SVGName 16}} {{.Package.Type.Name}}</span>
</div>
<div class="desc issue-item-bottom-row">
{{$timeStr := TimeSinceUnix .Version.CreatedUnix $.locale}}
{{$hasRepositoryAccess := false}}
{{if .Repository}}
{{$hasRepositoryAccess = index $.RepositoryAccessMap .Repository.ID}}
{{end}}
{{if $hasRepositoryAccess}}
{{$.locale.Tr "packages.published_by_in" $timeStr .Creator.HomeLink (.Creator.GetDisplayName | Escape) .Repository.Link (.Repository.FullName | Escape) | Safe}}
{{else}}
{{$.locale.Tr "packages.published_by" $timeStr .Creator.HomeLink (.Creator.GetDisplayName | Escape) | Safe}}
<div class="gt-mt-4">
<div class="ui {{.pageStyleClasses}}">
{{template "base/alert" .}}
<form class="ui form ignore-dirty search-input">
<div class="ui fluid action input">
{{template "shared/searchinput" dict "locale" .locale "Value" .Query "AutoFocus" true}}
<div class="ui clearable dropdown selection">
<input name="type" type="hidden" value="{{$.PackageType}}">
{{svg "octicon-x" 14 "remove icon"}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="default text">{{.locale.Tr "packages.filter.type"}}</div>
<div class="menu">
{{range $type := .AvailableTypes}}
<div class="item" data-value="{{$type.Name}}">
{{$type.Name}}
</div>
{{end}}
</div>
</div>
</li>
{{else}}
{{if not .HasPackages}}
<div class="empty center">
{{svg "octicon-package" 48}}
<h2>{{.locale.Tr "packages.empty"}}</h2>
{{if and .Repository .CanWritePackages}}
{{$packagesUrl := URLJoin .Owner.HomeLink "-" "packages"}}
<p>{{.locale.Tr "packages.empty.repo" $packagesUrl | Safe}}</p>
{{end}}
<p>{{.locale.Tr "packages.empty.documentation" "https://docs.gitea.io/en-us/usage/packages/overview/" | Safe}}</p>
</div>
<button class="ui primary button">{{.locale.Tr "explore.search"}}</button>
</div>
</form>
<div class="ui {{if .PackageDescriptors}}issue list{{end}}">
{{range .PackageDescriptors}}
<li class="item gt-df gt-py-3">
<div class="issue-item-main gt-f1 gt-fc gt-df">
<div class="issue-item-top-row">
<a class="title" href="{{.FullWebLink}}">{{.Package.Name}}</a>
<span class="ui label">{{svg .Package.Type.SVGName 16}} {{.Package.Type.Name}}</span>
</div>
<div class="desc issue-item-bottom-row gt-df gt-ac gt-fw gt-my-1">
{{$timeStr := TimeSinceUnix .Version.CreatedUnix $.locale}}
{{$hasRepositoryAccess := false}}
{{if .Repository}}
{{$hasRepositoryAccess = index $.RepositoryAccessMap .Repository.ID}}
{{end}}
{{if $hasRepositoryAccess}}
{{$.locale.Tr "packages.published_by_in" $timeStr .Creator.HomeLink (.Creator.GetDisplayName | Escape) .Repository.Link (.Repository.FullName | Escape) | Safe}}
{{else}}
{{$.locale.Tr "packages.published_by" $timeStr .Creator.HomeLink (.Creator.GetDisplayName | Escape) | Safe}}
{{end}}
</div>
</div>
</li>
{{else}}
<p>{{.locale.Tr "packages.filter.no_result"}}</p>
{{if not .HasPackages}}
<div class="gt-pt-5 empty center">
{{svg "octicon-package" 48}}
<h2>{{.locale.Tr "packages.empty"}}</h2>
{{if and .Repository .CanWritePackages}}
{{$packagesUrl := URLJoin .Owner.HomeLink "-" "packages"}}
<p>{{.locale.Tr "packages.empty.repo" $packagesUrl | Safe}}</p>
{{end}}
<p>{{.locale.Tr "packages.empty.documentation" "https://docs.gitea.io/en-us/usage/packages/overview/" | Safe}}</p>
</div>
{{else}}
<p>{{.locale.Tr "packages.filter.no_result"}}</p>
{{end}}
{{end}}
{{end}}
{{template "base/paginate" .}}
{{template "base/paginate" .}}
</div>
</div>
</div>
Loading