Skip to content
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

Fix repo home UI when there is no repo description #30552

Merged
merged 5 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
29 changes: 16 additions & 13 deletions templates/repo/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
{{template "base/alert" .}}
{{template "repo/code/recently_pushed_new_branches" .}}
{{if and (not .HideRepoInfo) (not .IsBlame)}}
<div class="repo-description">
<div id="repo-desc" class="gt-word-break tw-text-16">
{{$description := .Repository.DescriptionHTML $.Context}}
{{if $description}}<span class="description">{{$description | RenderCodeBlock}}</span>{{else if .IsRepositoryAdmin}}<span class="no-description text-italic">{{ctx.Locale.Tr "repo.no_desc"}}</span>{{end}}
<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>
</div>
<form class="ignore-dirty" action="{{.RepoLink}}/search" method="get">
<div class="ui small action input">
<input name="q" value="{{.Keyword}}" placeholder="{{ctx.Locale.Tr "search.code_kind"}}">
{{template "shared/search/button"}}
</div>
</form>
<div class="repo-description gt-word-break">
{{- $description := .Repository.DescriptionHTML ctx -}}
{{- if $description -}}
{{- $description | RenderCodeBlock -}}
{{- else if .IsRepositoryAdmin -}}
<span class="no-description text italic">{{ctx.Locale.Tr "repo.no_desc"}}</span>
silverwind marked this conversation as resolved.
Show resolved Hide resolved
{{- end -}}
{{- if .Repository.Website}}<a href="{{.Repository.Website}}">{{.Repository.Website}}</a>{{end -}}
</div>
<div class="tw-flex tw-items-center tw-flex-wrap tw-gap-2 tw-my-2" id="repo-topics">
{{/* it should match the code in issue-home.js */}}
Expand Down Expand Up @@ -54,7 +50,7 @@
{{$l := Eval $n "-" 1}}
{{$isHomepage := (eq $n 0)}}
<div class="repo-button-row">
<div class="tw-flex tw-items-center tw-gap-y-2">
<div class="tw-flex tw-items-center tw-flex-wrap tw-gap-y-2">
{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mr-1"}}
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
{{$cmpBranch := ""}}
Expand Down Expand Up @@ -111,6 +107,13 @@
{{- end -}}
</span>
{{end}}

<form class="ignore-dirty" action="{{.RepoLink}}/search" method="get">
<div class="ui small action input">
<input name="q" value="{{.Keyword}}" placeholder="{{ctx.Locale.Tr "search.code_kind"}}">
{{template "shared/search/button"}}
</div>
</form>
</div>
<div class="tw-flex tw-items-center">
<!-- Only show clone panel in repository home page -->
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestViewRepo(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK)

htmlDoc := NewHTMLParser(t, resp.Body)
noDescription := htmlDoc.doc.Find("#repo-desc").Children()
noDescription := htmlDoc.doc.Find(".repo-description").Children()
repoTopics := htmlDoc.doc.Find("#repo-topics").Children()
repoSummary := htmlDoc.doc.Find(".repository-summary").Children()

Expand Down Expand Up @@ -191,7 +191,7 @@ func TestViewAsRepoAdmin(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK)

htmlDoc := NewHTMLParser(t, resp.Body)
noDescription := htmlDoc.doc.Find("#repo-desc").Children()
noDescription := htmlDoc.doc.Find(".repo-description").Children()
repoTopics := htmlDoc.doc.Find("#repo-topics").Children()
repoSummary := htmlDoc.doc.Find(".repository-summary").Children()

Expand All @@ -211,7 +211,7 @@ func TestViewFileInRepo(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK)

htmlDoc := NewHTMLParser(t, resp.Body)
description := htmlDoc.doc.Find("#repo-desc")
description := htmlDoc.doc.Find(".repo-description")
repoTopics := htmlDoc.doc.Find("#repo-topics")
repoSummary := htmlDoc.doc.Find(".repository-summary")

Expand All @@ -230,7 +230,7 @@ func TestBlameFileInRepo(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK)

htmlDoc := NewHTMLParser(t, resp.Body)
description := htmlDoc.doc.Find("#repo-desc")
description := htmlDoc.doc.Find(".repo-description")
repoTopics := htmlDoc.doc.Find("#repo-topics")
repoSummary := htmlDoc.doc.Find(".repository-summary")

Expand All @@ -249,7 +249,7 @@ func TestViewRepoDirectory(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK)

htmlDoc := NewHTMLParser(t, resp.Body)
description := htmlDoc.doc.Find("#repo-desc")
description := htmlDoc.doc.Find(".repo-description")
repoTopics := htmlDoc.doc.Find("#repo-topics")
repoSummary := htmlDoc.doc.Find(".repository-summary")

Expand Down
14 changes: 2 additions & 12 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,11 @@
left: auto !important;
}

.repository.file.list .repo-description {
display: flex;
justify-content: space-between;
align-items: center;
gap: 5px;
.repository .repo-description {
font-size: 16px;
margin-bottom: 5px;
}

@media (max-width: 767.98px) {
.repository.file.list .repo-description {
flex-direction: column;
align-items: stretch;
}
}

.commit-summary {
flex: 1;
overflow-wrap: anywhere;
Expand Down