mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Fix repo home UI when there is no repo description (#30552)
Fix #30502 by a new approach. 
This commit is contained in:
		| @@ -1193,7 +1193,6 @@ action.blocked_user = Cannot perform action because you are blocked by the repos | |||||||
| download_archive = Download Repository | download_archive = Download Repository | ||||||
| more_operations = More Operations | more_operations = More Operations | ||||||
|  |  | ||||||
| no_desc = No Description |  | ||||||
| quick_guide = Quick Guide | quick_guide = Quick Guide | ||||||
| clone_this_repo = Clone this repository | clone_this_repo = Clone this repository | ||||||
| cite_this_repo = Cite this repository | cite_this_repo = Cite this repository | ||||||
|   | |||||||
| @@ -5,18 +5,10 @@ | |||||||
| 		{{template "base/alert" .}} | 		{{template "base/alert" .}} | ||||||
| 		{{template "repo/code/recently_pushed_new_branches" .}} | 		{{template "repo/code/recently_pushed_new_branches" .}} | ||||||
| 		{{if and (not .HideRepoInfo) (not .IsBlame)}} | 		{{if and (not .HideRepoInfo) (not .IsBlame)}} | ||||||
| 		<div class="repo-description"> | 		<div class="repo-description gt-word-break"> | ||||||
| 			<div id="repo-desc" class="gt-word-break tw-text-16"> | 			{{- $description := .Repository.DescriptionHTML ctx -}} | ||||||
| 				{{$description := .Repository.DescriptionHTML $.Context}} | 			{{if $description}}{{$description | RenderCodeBlock}}{{end}} | ||||||
| 				{{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}} | 			{{if .Repository.Website}}<a href="{{.Repository.Website}}">{{.Repository.Website}}</a>{{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> | 		</div> | ||||||
| 		<div class="tw-flex tw-items-center tw-flex-wrap tw-gap-2 tw-my-2" id="repo-topics"> | 		<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 */}} | 			{{/* it should match the code in issue-home.js */}} | ||||||
| @@ -54,7 +46,7 @@ | |||||||
| 		{{$l := Eval $n "-" 1}} | 		{{$l := Eval $n "-" 1}} | ||||||
| 		{{$isHomepage := (eq $n 0)}} | 		{{$isHomepage := (eq $n 0)}} | ||||||
| 		<div class="repo-button-row"> | 		<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"}} | 				{{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mr-1"}} | ||||||
| 				{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}} | 				{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}} | ||||||
| 					{{$cmpBranch := ""}} | 					{{$cmpBranch := ""}} | ||||||
| @@ -111,6 +103,13 @@ | |||||||
| 						{{- end -}} | 						{{- end -}} | ||||||
| 					</span> | 					</span> | ||||||
| 				{{end}} | 				{{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> | ||||||
| 			<div class="tw-flex tw-items-center"> | 			<div class="tw-flex tw-items-center"> | ||||||
| 				<!-- Only show clone panel in repository home page --> | 				<!-- Only show clone panel in repository home page --> | ||||||
|   | |||||||
| @@ -28,11 +28,9 @@ func TestViewRepo(t *testing.T) { | |||||||
| 	resp := session.MakeRequest(t, req, http.StatusOK) | 	resp := session.MakeRequest(t, req, http.StatusOK) | ||||||
|  |  | ||||||
| 	htmlDoc := NewHTMLParser(t, resp.Body) | 	htmlDoc := NewHTMLParser(t, resp.Body) | ||||||
| 	noDescription := htmlDoc.doc.Find("#repo-desc").Children() |  | ||||||
| 	repoTopics := htmlDoc.doc.Find("#repo-topics").Children() | 	repoTopics := htmlDoc.doc.Find("#repo-topics").Children() | ||||||
| 	repoSummary := htmlDoc.doc.Find(".repository-summary").Children() | 	repoSummary := htmlDoc.doc.Find(".repository-summary").Children() | ||||||
|  |  | ||||||
| 	assert.True(t, noDescription.HasClass("no-description")) |  | ||||||
| 	assert.True(t, repoTopics.HasClass("repo-topic")) | 	assert.True(t, repoTopics.HasClass("repo-topic")) | ||||||
| 	assert.True(t, repoSummary.HasClass("repository-menu")) | 	assert.True(t, repoSummary.HasClass("repository-menu")) | ||||||
|  |  | ||||||
| @@ -177,30 +175,6 @@ func TestViewRepoWithSymlinks(t *testing.T) { | |||||||
| 	assert.Equal(t, "link_link: svg octicon-file-symlink-file", items[4]) | 	assert.Equal(t, "link_link: svg octicon-file-symlink-file", items[4]) | ||||||
| } | } | ||||||
|  |  | ||||||
| // TestViewAsRepoAdmin tests PR #2167 |  | ||||||
| func TestViewAsRepoAdmin(t *testing.T) { |  | ||||||
| 	for user, expectedNoDescription := range map[string]bool{ |  | ||||||
| 		"user2": true, |  | ||||||
| 		"user4": false, |  | ||||||
| 	} { |  | ||||||
| 		defer tests.PrepareTestEnv(t)() |  | ||||||
|  |  | ||||||
| 		session := loginUser(t, user) |  | ||||||
|  |  | ||||||
| 		req := NewRequest(t, "GET", "/user2/repo1.git") |  | ||||||
| 		resp := session.MakeRequest(t, req, http.StatusOK) |  | ||||||
|  |  | ||||||
| 		htmlDoc := NewHTMLParser(t, resp.Body) |  | ||||||
| 		noDescription := htmlDoc.doc.Find("#repo-desc").Children() |  | ||||||
| 		repoTopics := htmlDoc.doc.Find("#repo-topics").Children() |  | ||||||
| 		repoSummary := htmlDoc.doc.Find(".repository-summary").Children() |  | ||||||
|  |  | ||||||
| 		assert.Equal(t, expectedNoDescription, noDescription.HasClass("no-description")) |  | ||||||
| 		assert.True(t, repoTopics.HasClass("repo-topic")) |  | ||||||
| 		assert.True(t, repoSummary.HasClass("repository-menu")) |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // TestViewFileInRepo repo description, topics and summary should not be displayed when viewing a file | // TestViewFileInRepo repo description, topics and summary should not be displayed when viewing a file | ||||||
| func TestViewFileInRepo(t *testing.T) { | func TestViewFileInRepo(t *testing.T) { | ||||||
| 	defer tests.PrepareTestEnv(t)() | 	defer tests.PrepareTestEnv(t)() | ||||||
| @@ -211,7 +185,7 @@ func TestViewFileInRepo(t *testing.T) { | |||||||
| 	resp := session.MakeRequest(t, req, http.StatusOK) | 	resp := session.MakeRequest(t, req, http.StatusOK) | ||||||
|  |  | ||||||
| 	htmlDoc := NewHTMLParser(t, resp.Body) | 	htmlDoc := NewHTMLParser(t, resp.Body) | ||||||
| 	description := htmlDoc.doc.Find("#repo-desc") | 	description := htmlDoc.doc.Find(".repo-description") | ||||||
| 	repoTopics := htmlDoc.doc.Find("#repo-topics") | 	repoTopics := htmlDoc.doc.Find("#repo-topics") | ||||||
| 	repoSummary := htmlDoc.doc.Find(".repository-summary") | 	repoSummary := htmlDoc.doc.Find(".repository-summary") | ||||||
|  |  | ||||||
| @@ -230,7 +204,7 @@ func TestBlameFileInRepo(t *testing.T) { | |||||||
| 	resp := session.MakeRequest(t, req, http.StatusOK) | 	resp := session.MakeRequest(t, req, http.StatusOK) | ||||||
|  |  | ||||||
| 	htmlDoc := NewHTMLParser(t, resp.Body) | 	htmlDoc := NewHTMLParser(t, resp.Body) | ||||||
| 	description := htmlDoc.doc.Find("#repo-desc") | 	description := htmlDoc.doc.Find(".repo-description") | ||||||
| 	repoTopics := htmlDoc.doc.Find("#repo-topics") | 	repoTopics := htmlDoc.doc.Find("#repo-topics") | ||||||
| 	repoSummary := htmlDoc.doc.Find(".repository-summary") | 	repoSummary := htmlDoc.doc.Find(".repository-summary") | ||||||
|  |  | ||||||
| @@ -249,7 +223,7 @@ func TestViewRepoDirectory(t *testing.T) { | |||||||
| 	resp := session.MakeRequest(t, req, http.StatusOK) | 	resp := session.MakeRequest(t, req, http.StatusOK) | ||||||
|  |  | ||||||
| 	htmlDoc := NewHTMLParser(t, resp.Body) | 	htmlDoc := NewHTMLParser(t, resp.Body) | ||||||
| 	description := htmlDoc.doc.Find("#repo-desc") | 	description := htmlDoc.doc.Find(".repo-description") | ||||||
| 	repoTopics := htmlDoc.doc.Find("#repo-topics") | 	repoTopics := htmlDoc.doc.Find("#repo-topics") | ||||||
| 	repoSummary := htmlDoc.doc.Find(".repository-summary") | 	repoSummary := htmlDoc.doc.Find(".repository-summary") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -157,21 +157,11 @@ | |||||||
|   left: auto !important; |   left: auto !important; | ||||||
| } | } | ||||||
|  |  | ||||||
| .repository.file.list .repo-description { | .repository .repo-description { | ||||||
|   display: flex; |   font-size: 16px; | ||||||
|   justify-content: space-between; |  | ||||||
|   align-items: center; |  | ||||||
|   gap: 5px; |  | ||||||
|   margin-bottom: 5px; |   margin-bottom: 5px; | ||||||
| } | } | ||||||
|  |  | ||||||
| @media (max-width: 767.98px) { |  | ||||||
|   .repository.file.list .repo-description { |  | ||||||
|     flex-direction: column; |  | ||||||
|     align-items: stretch; |  | ||||||
|   } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| .commit-summary { | .commit-summary { | ||||||
|   flex: 1; |   flex: 1; | ||||||
|   overflow-wrap: anywhere; |   overflow-wrap: anywhere; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user