Compare commits

...

7 Commits

Author SHA1 Message Date
Giteabot
22911a1ece
Imrove scroll behavior to hash issuecomment(scroll position, auto expand if file is folded, and on refreshing) (#23513) (#23540)
Backport #23513 by @HesterG

Close #23466
Right now on pull request "files Changed" tab, if a file is viewed, when
the comments' links are visited, the comment will not be shown as the
file is folded after viewed. This PR is to improve the behavior, to make
the comment seen even the related file is folded, like on github.

And right now scroll position will be remembered and hence it won’t
scroll to hashed comment after refreshing, this PR also adjust the
scroll position remembering behavior: When there is hash comment in url,
do not remember the scroll position.

Before:


https://user-images.githubusercontent.com/17645053/225512079-6cf79581-9346-44cf-95d6-06919642e6a8.mov


After:


https://user-images.githubusercontent.com/17645053/225523753-3f6728f2-977b-4ed0-a65c-63dcef2ace80.mov


Update - long comment's behavior after using `scrollTop ` (Comment div
scroll to the position which is 30px below the diff header, or 30px
below top on conversation tab):


https://user-images.githubusercontent.com/17645053/225614460-0602c1a6-229c-41f4-84d2-334e78251486.mov

Co-authored-by: Hester Gong <hestergong@gmail.com>
2023-03-17 22:59:18 -04:00
Giteabot
4b763d8d37
Fix diff detail buttons wrapping, use tippy for review box (#23271) (#23546)
Backport #23271 by @silverwind

Fix visual regression introduced by
https://github.com/go-gitea/gitea/pull/22986.

Before:
<img width="1277" alt="image"
src="https://user-images.githubusercontent.com/115237/222792814-d70c2173-0c7c-4db2-8839-95be63cdc8ee.png">
<img width="649" alt="image"
src="https://user-images.githubusercontent.com/115237/222792989-9b1f5e12-becd-40cc-b02c-e9f59a8e72a4.png">

After: 
<img width="1274" alt="image"
src="https://user-images.githubusercontent.com/115237/222792769-e7a9702f-4b6a-46c4-9385-da103ed4dff0.png">
<img width="565" alt="image"
src="https://user-images.githubusercontent.com/115237/222793084-6de6482b-11dc-4d38-b514-15884d20e140.png">

Co-authored-by: silverwind <me@silverwind.io>
2023-03-17 14:52:04 -04:00
wxiaoguang
1254fc668a
Fix review comment context menu clipped bug (#23523) (#23543)
Backport #23523, Close #23517

There is no "dropdown menu" for image/csv view, so we could only add the
"overflow-x: scroll" to the image/csv view.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-17 14:00:17 -04:00
wxiaoguang
09824025f7
Refactor merge/update git command calls (#23366) (#23544)
Backport #23366

* Remove unnecessary ToTrustedCmdArgs calls
* The `signArg` couldn't be empty, it's either `-S{keyID}` or
`--no-gpg-sign`.
2023-03-17 12:16:22 -04:00
Giteabot
bd1a915bdb
Use octicon-verified for gpg signatures (#23529) (#23536)
Backport #23529 by @silverwind

Before:
<img width="292" alt="Screenshot 2023-03-16 at 23 40 47"
src="https://user-images.githubusercontent.com/115237/225768871-43e11ced-e340-4c88-b756-25f9f7076fd2.png">
<img width="288" alt="Screenshot 2023-03-16 at 23 51 05"
src="https://user-images.githubusercontent.com/115237/225770071-b51f3ed6-ef14-421b-a5bc-6a26e808d404.png">


After:
<img width="291" alt="Screenshot 2023-03-16 at 23 40 37"
src="https://user-images.githubusercontent.com/115237/225768864-ea4956c7-8c57-4148-9d89-c818991a7538.png">
<img width="281" alt="image"
src="https://user-images.githubusercontent.com/115237/225769978-0b9c6c52-9a13-4c23-b13e-8a8a692abf43.png">

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-17 11:39:31 -04:00
Giteabot
cab7044772
Increase horizontal page padding (#23507) (#23537)
Backport #23507 by @silverwind

Add a bit more empty space on left and right side of page content for a
more pleasant viewing experience. Also tweaked the mobile navbar to
match.

Before:
<img width="1276" alt="Screenshot 2023-03-16 at 00 58 23"
src="https://user-images.githubusercontent.com/115237/225473942-f544106f-1b61-456a-99fb-3ba136cabc8d.png">

After:
<img width="1270" alt="Screenshot 2023-03-16 at 00 58 37"
src="https://user-images.githubusercontent.com/115237/225473959-8b555359-a08d-48e1-9476-2710aabb1166.png">

Mobile Navbar:
<img width="673" alt="Screenshot 2023-03-16 at 01 05 12"
src="https://user-images.githubusercontent.com/115237/225473966-adccef2b-4d34-44ed-8c75-d4ca46d96cf3.png">

Co-authored-by: silverwind <me@silverwind.io>
2023-03-17 21:01:47 +08:00
Giteabot
68c9f1abd8
Use <nav> instead of <div> in the global navbar (#23125) (#23533)
Backport #23125 by @delvh

Furthermore improved/deleted some comments in the template.
The appearance did not change.

Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-03-17 01:28:17 -04:00
15 changed files with 99 additions and 77 deletions

View File

@ -179,7 +179,7 @@ func (c *Command) AddDashesAndList(list ...string) *Command {
} }
// ToTrustedCmdArgs converts a list of strings (trusted as argument) to TrustedCmdArgs // ToTrustedCmdArgs converts a list of strings (trusted as argument) to TrustedCmdArgs
// In most cases, it shouldn't be used. Use AddXxx function instead // In most cases, it shouldn't be used. Use NewCommand().AddXxx() function instead
func ToTrustedCmdArgs(args []string) TrustedCmdArgs { func ToTrustedCmdArgs(args []string) TrustedCmdArgs {
ret := make(TrustedCmdArgs, len(args)) ret := make(TrustedCmdArgs, len(args))
for i, arg := range args { for i, arg := range args {

View File

@ -332,8 +332,13 @@ func doMergeAndPush(ctx context.Context, pr *issues_model.PullRequest, doer *use
} }
func commitAndSignNoAuthor(ctx *mergeContext, message string) error { func commitAndSignNoAuthor(ctx *mergeContext, message string) error {
if err := git.NewCommand(ctx, "commit").AddArguments(ctx.signArg...).AddOptionFormat("--message=%s", message). cmdCommit := git.NewCommand(ctx, "commit").AddOptionFormat("--message=%s", message)
Run(ctx.RunOpts()); err != nil { if ctx.signKeyID == "" {
cmdCommit.AddArguments("--no-gpg-sign")
} else {
cmdCommit.AddOptionFormat("-S%s", ctx.signKeyID)
}
if err := cmdCommit.Run(ctx.RunOpts()); err != nil {
log.Error("git commit %-v: %v\n%s\n%s", ctx.pr, err, ctx.outbuf.String(), ctx.errbuf.String()) log.Error("git commit %-v: %v\n%s\n%s", ctx.pr, err, ctx.outbuf.String(), ctx.errbuf.String())
return fmt.Errorf("git commit %v: %w\n%s\n%s", ctx.pr, err, ctx.outbuf.String(), ctx.errbuf.String()) return fmt.Errorf("git commit %v: %w\n%s\n%s", ctx.pr, err, ctx.outbuf.String(), ctx.errbuf.String())
} }

View File

@ -28,7 +28,7 @@ type mergeContext struct {
doer *user_model.User doer *user_model.User
sig *git.Signature sig *git.Signature
committer *git.Signature committer *git.Signature
signArg git.TrustedCmdArgs signKeyID string // empty for no-sign, non-empty to sign
env []string env []string
} }
@ -85,12 +85,10 @@ func createTemporaryRepoForMerge(ctx context.Context, pr *issues_model.PullReque
// Determine if we should sign // Determine if we should sign
sign, keyID, signer, _ := asymkey_service.SignMerge(ctx, mergeCtx.pr, mergeCtx.doer, mergeCtx.tmpBasePath, "HEAD", trackingBranch) sign, keyID, signer, _ := asymkey_service.SignMerge(ctx, mergeCtx.pr, mergeCtx.doer, mergeCtx.tmpBasePath, "HEAD", trackingBranch)
if sign { if sign {
mergeCtx.signArg = git.ToTrustedCmdArgs([]string{"-S" + keyID}) mergeCtx.signKeyID = keyID
if pr.BaseRepo.GetTrustModel() == repo_model.CommitterTrustModel || pr.BaseRepo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel { if pr.BaseRepo.GetTrustModel() == repo_model.CommitterTrustModel || pr.BaseRepo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel {
mergeCtx.committer = signer mergeCtx.committer = signer
} }
} else {
mergeCtx.signArg = git.ToTrustedCmdArgs([]string{"--no-gpg-sign"})
} }
commitTimeStr := time.Now().Format(time.RFC3339) commitTimeStr := time.Now().Format(time.RFC3339)
@ -136,18 +134,11 @@ func prepareTemporaryRepoForMerge(ctx *mergeContext) error {
return fmt.Errorf("Unable to close .git/info/sparse-checkout file in tmpBasePath: %w", err) return fmt.Errorf("Unable to close .git/info/sparse-checkout file in tmpBasePath: %w", err)
} }
gitConfigCommand := func() *git.Command {
return git.NewCommand(ctx, "config", "--local")
}
setConfig := func(key, value string) error { setConfig := func(key, value string) error {
if err := gitConfigCommand().AddArguments(git.ToTrustedCmdArgs([]string{key, value})...). if err := git.NewCommand(ctx, "config", "--local").AddDynamicArguments(key, value).
Run(ctx.RunOpts()); err != nil { Run(ctx.RunOpts()); err != nil {
if value == "" { log.Error("git config [%s -> %q]: %v\n%s\n%s", key, value, err, ctx.outbuf.String(), ctx.errbuf.String())
value = "<>" return fmt.Errorf("git config [%s -> %q]: %w\n%s\n%s", key, value, err, ctx.outbuf.String(), ctx.errbuf.String())
}
log.Error("git config [%s -> %s ]: %v\n%s\n%s", key, value, err, ctx.outbuf.String(), ctx.errbuf.String())
return fmt.Errorf("git config [%s -> %s ]: %w\n%s\n%s", key, value, err, ctx.outbuf.String(), ctx.errbuf.String())
} }
ctx.outbuf.Reset() ctx.outbuf.Reset()
ctx.errbuf.Reset() ctx.errbuf.Reset()

View File

@ -14,8 +14,8 @@ import (
// doMergeStyleSquash squashes the tracking branch on the current HEAD (=base) // doMergeStyleSquash squashes the tracking branch on the current HEAD (=base)
func doMergeStyleSquash(ctx *mergeContext, message string) error { func doMergeStyleSquash(ctx *mergeContext, message string) error {
cmd := git.NewCommand(ctx, "merge", "--squash").AddDynamicArguments(trackingBranch) cmdMerge := git.NewCommand(ctx, "merge", "--squash").AddDynamicArguments(trackingBranch)
if err := runMergeCommand(ctx, repo_model.MergeStyleSquash, cmd); err != nil { if err := runMergeCommand(ctx, repo_model.MergeStyleSquash, cmdMerge); err != nil {
log.Error("%-v Unable to merge --squash tracking into base: %v", ctx.pr, err) log.Error("%-v Unable to merge --squash tracking into base: %v", ctx.pr, err)
return err return err
} }
@ -25,28 +25,22 @@ func doMergeStyleSquash(ctx *mergeContext, message string) error {
return fmt.Errorf("LoadPoster: %w", err) return fmt.Errorf("LoadPoster: %w", err)
} }
sig := ctx.pr.Issue.Poster.NewGitSig() sig := ctx.pr.Issue.Poster.NewGitSig()
if len(ctx.signArg) == 0 {
if err := git.NewCommand(ctx, "commit").
AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email).
AddOptionFormat("--message=%s", message).
Run(ctx.RunOpts()); err != nil {
log.Error("git commit %-v: %v\n%s\n%s", ctx.pr, err, ctx.outbuf.String(), ctx.errbuf.String())
return fmt.Errorf("git commit [%s:%s -> %s:%s]: %w\n%s\n%s", ctx.pr.HeadRepo.FullName(), ctx.pr.HeadBranch, ctx.pr.BaseRepo.FullName(), ctx.pr.BaseBranch, err, ctx.outbuf.String(), ctx.errbuf.String())
}
} else {
if setting.Repository.PullRequest.AddCoCommitterTrailers && ctx.committer.String() != sig.String() { if setting.Repository.PullRequest.AddCoCommitterTrailers && ctx.committer.String() != sig.String() {
// add trailer // add trailer
message += fmt.Sprintf("\nCo-authored-by: %s\nCo-committed-by: %s\n", sig.String(), sig.String()) message += fmt.Sprintf("\nCo-authored-by: %s\nCo-committed-by: %s\n", sig.String(), sig.String())
} }
if err := git.NewCommand(ctx, "commit"). cmdCommit := git.NewCommand(ctx, "commit").
AddArguments(ctx.signArg...).
AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email). AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email).
AddOptionFormat("--message=%s", message). AddOptionFormat("--message=%s", message)
Run(ctx.RunOpts()); err != nil { if ctx.signKeyID == "" {
cmdCommit.AddArguments("--no-gpg-sign")
} else {
cmdCommit.AddOptionFormat("-S%s", ctx.signKeyID)
}
if err := cmdCommit.Run(ctx.RunOpts()); err != nil {
log.Error("git commit %-v: %v\n%s\n%s", ctx.pr, err, ctx.outbuf.String(), ctx.errbuf.String()) log.Error("git commit %-v: %v\n%s\n%s", ctx.pr, err, ctx.outbuf.String(), ctx.errbuf.String())
return fmt.Errorf("git commit [%s:%s -> %s:%s]: %w\n%s\n%s", ctx.pr.HeadRepo.FullName(), ctx.pr.HeadBranch, ctx.pr.BaseRepo.FullName(), ctx.pr.BaseBranch, err, ctx.outbuf.String(), ctx.errbuf.String()) return fmt.Errorf("git commit [%s:%s -> %s:%s]: %w\n%s\n%s", ctx.pr.HeadRepo.FullName(), ctx.pr.HeadBranch, ctx.pr.BaseRepo.FullName(), ctx.pr.BaseBranch, err, ctx.outbuf.String(), ctx.errbuf.String())
} }
}
ctx.outbuf.Reset() ctx.outbuf.Reset()
ctx.errbuf.Reset() ctx.errbuf.Reset()
return nil return nil

View File

@ -1,4 +1,4 @@
<div class="ui container" id="navbar" role="navigation" aria-label="{{.locale.Tr "aria.navbar"}}"> <nav class="ui container" id="navbar" aria-label="{{.locale.Tr "aria.navbar"}}">
{{$notificationUnreadCount := 0}} {{$notificationUnreadCount := 0}}
{{if .IsSigned}} {{if .IsSigned}}
{{if .NotificationUnreadCount}}{{$notificationUnreadCount = call .NotificationUnreadCount}}{{end}} {{if .NotificationUnreadCount}}{{$notificationUnreadCount = call .NotificationUnreadCount}}{{end}}
@ -150,7 +150,7 @@
</div><!-- end content create new menu --> </div><!-- end content create new menu -->
</div><!-- end dropdown menu create new --> </div><!-- end dropdown menu create new -->
<div class="ui dropdown jump item tooltip gt-mx-0" tabindex="-1" data-content="{{.locale.Tr "user_profile_and_more"}}"> <div class="ui dropdown jump item tooltip gt-mx-0" data-content="{{.locale.Tr "user_profile_and_more"}}">
<span class="text"> <span class="text">
{{avatar $.Context .SignedUser 24 "tiny"}} {{avatar $.Context .SignedUser 24 "tiny"}}
<span class="sr-only">{{.locale.Tr "user_profile_and_more"}}</span> <span class="sr-only">{{.locale.Tr "user_profile_and_more"}}</span>
@ -190,14 +190,14 @@
<a class="{{if .PageIsAdmin}}active {{end}}item" href="{{AppSubUrl}}/admin"> <a class="{{if .PageIsAdmin}}active {{end}}item" href="{{AppSubUrl}}/admin">
{{svg "octicon-server"}} {{svg "octicon-server"}}
{{.locale.Tr "admin_panel"}}<!-- Admin Panel --> {{.locale.Tr "admin_panel"}}
</a> </a>
{{end}} {{end}}
<div class="divider"></div> <div class="divider"></div>
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/"> <a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/">
{{svg "octicon-sign-out"}} {{svg "octicon-sign-out"}}
{{.locale.Tr "sign_out"}}<!-- Sign Out --> {{.locale.Tr "sign_out"}}
</a> </a>
</div><!-- end content avatar menu --> </div><!-- end content avatar menu -->
</div><!-- end dropdown avatar menu --> </div><!-- end dropdown avatar menu -->
@ -213,6 +213,6 @@
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login{{if not .PageIsSignIn}}?redirect_to={{.CurrentURL}}{{end}}"> <a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login{{if not .PageIsSignIn}}?redirect_to={{.CurrentURL}}{{end}}">
{{svg "octicon-sign-in"}} {{.locale.Tr "sign_in"}} {{svg "octicon-sign-in"}} {{.locale.Tr "sign_in"}}
</a> </a>
</div><!-- end anonymous right menu --> </div><!-- end anonymous user right menu -->
{{end}} {{end}}
</div> </nav>

View File

@ -216,7 +216,7 @@
<div class="gt-df gt-ac"> <div class="gt-df gt-ac">
{{if .Verification.Verified}} {{if .Verification.Verified}}
{{if ne .Verification.SigningUser.ID 0}} {{if ne .Verification.SigningUser.ID 0}}
{{svg "octicon-shield-check" 16 "gt-mr-3"}} {{svg "octicon-verified" 16 "gt-mr-3"}}
{{if .Verification.SigningSSHKey}} {{if .Verification.SigningSSHKey}}
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> <span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
{{.Verification.SigningSSHKey.Fingerprint}} {{.Verification.SigningSSHKey.Fingerprint}}
@ -225,7 +225,7 @@
{{.Verification.SigningKey.PaddedKeyID}} {{.Verification.SigningKey.PaddedKeyID}}
{{end}} {{end}}
{{else}} {{else}}
{{svg "octicon-shield-lock" 16 "gt-mr-3"}} {{svg "octicon-unverified" 16 "gt-mr-3"}}
{{if .Verification.SigningSSHKey}} {{if .Verification.SigningSSHKey}}
<span class="ui text gt-mr-3 tooltip" data-content="{{.locale.Tr "gpg.default_key"}}">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> <span class="ui text gt-mr-3 tooltip" data-content="{{.locale.Tr "gpg.default_key"}}">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
{{.Verification.SigningSSHKey.Fingerprint}} {{.Verification.SigningSSHKey.Fingerprint}}
@ -235,7 +235,7 @@
{{end}} {{end}}
{{end}} {{end}}
{{else if .Verification.Warning}} {{else if .Verification.Warning}}
{{svg "octicon-shield" 16 "gt-mr-3"}} {{svg "octicon-unverified" 16 "gt-mr-3"}}
{{if .Verification.SigningSSHKey}} {{if .Verification.SigningSSHKey}}
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> <span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
{{.Verification.SigningSSHKey.Fingerprint}} {{.Verification.SigningSSHKey.Fingerprint}}
@ -246,14 +246,14 @@
{{else}} {{else}}
{{if .Verification.SigningKey}} {{if .Verification.SigningKey}}
{{if ne .Verification.SigningKey.KeyID ""}} {{if ne .Verification.SigningKey.KeyID ""}}
{{svg "octicon-shield" 16 "gt-mr-3"}} {{svg "octicon-verified" 16 "gt-mr-3"}}
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.gpg_key_id"}}:</span> <span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.gpg_key_id"}}:</span>
{{.Verification.SigningKey.PaddedKeyID}} {{.Verification.SigningKey.PaddedKeyID}}
{{end}} {{end}}
{{end}} {{end}}
{{if .Verification.SigningSSHKey}} {{if .Verification.SigningSSHKey}}
{{if ne .Verification.SigningSSHKey.Fingerprint ""}} {{if ne .Verification.SigningSSHKey.Fingerprint ""}}
{{svg "octicon-shield" 16 "gt-mr-3"}} {{svg "octicon-verified" 16 "gt-mr-3"}}
<span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> <span class="ui text gt-mr-3">{{.locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span>
{{.Verification.SigningSSHKey.Fingerprint}} {{.Verification.SigningSSHKey.Fingerprint}}
{{end}} {{end}}

View File

@ -24,7 +24,7 @@
{{svg "octicon-diff" 16 "gt-mr-2"}}{{.locale.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}} {{svg "octicon-diff" 16 "gt-mr-2"}}{{.locale.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
</div> </div>
</div> </div>
<div class="diff-detail-actions gt-df gt-ac gt-w-100"> <div class="diff-detail-actions gt-df gt-ac">
{{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}} {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
<progress id="viewed-files-summary" class="gt-mr-2" value="{{.Diff.NumViewedFiles}}" max="{{.Diff.NumFiles}}"></progress> <progress id="viewed-files-summary" class="gt-mr-2" value="{{.Diff.NumViewedFiles}}" max="{{.Diff.NumFiles}}"></progress>
<label for="viewed-files-summary" id="viewed-files-summary-label" class="gt-mr-3 gt-f1" data-text-changed-template="{{.locale.Tr "repo.pulls.viewed_files_label"}}"> <label for="viewed-files-summary" id="viewed-files-summary-label" class="gt-mr-3 gt-f1" data-text-changed-template="{{.locale.Tr "repo.pulls.viewed_files_label"}}">
@ -161,7 +161,8 @@
{{end}} {{end}}
</div> </div>
{{if $showFileViewToggle}} {{if $showFileViewToggle}}
<div id="diff-rendered-{{$file.NameHash}}" class="file-body file-code {{if $.IsSplitStyle}} code-diff-split{{else}} code-diff-unified{{end}}"> {{/* for image or CSV, it can have a horizontal scroll bar, there won't be review comment context menu (position absolute) which would be clipped by "overflow" */}}
<div id="diff-rendered-{{$file.NameHash}}" class="file-body file-code {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}} gt-overflow-x-scroll">
<table class="chroma gt-w-100"> <table class="chroma gt-w-100">
{{if $isImage}} {{if $isImage}}
{{template "repo/diff/image_diff" dict "file" . "root" $ "blobBase" $blobBase "blobHead" $blobHead}} {{template "repo/diff/image_diff" dict "file" . "root" $ "blobBase" $blobBase "blobHead" $blobHead}}

View File

@ -4,7 +4,7 @@
<span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span> <span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}} {{svg "octicon-triangle-down" 14 "dropdown icon"}}
</button> </button>
<div class="review-box-panel gt-hidden"> <div class="review-box-panel tippy-target">
<div class="ui segment"> <div class="ui segment">
<form class="ui form" action="{{.Link}}/reviews/submit" method="post"> <form class="ui form" action="{{.Link}}/reviews/submit" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}

View File

@ -58,7 +58,7 @@
</div> </div>
<div class="content"> <div class="content">
{{if .Verified}} {{if .Verified}}
<span class="tooltip" data-content="{{$.locale.Tr "settings.gpg_key_verified_long"}}">{{svg "octicon-shield-check"}} <strong>{{$.locale.Tr "settings.gpg_key_verified"}}</strong></span> <span class="tooltip" data-content="{{$.locale.Tr "settings.gpg_key_verified_long"}}">{{svg "octicon-verified"}} <strong>{{$.locale.Tr "settings.gpg_key_verified"}}</strong></span>
{{end}} {{end}}
{{if gt (len .Emails) 0}} {{if gt (len .Emails) 0}}
<span class="tooltip" data-content="{{$.locale.Tr "settings.gpg_key_matched_identities_long"}}">{{svg "octicon-mail"}} {{$.locale.Tr "settings.gpg_key_matched_identities"}} {{range .Emails}}<strong>{{.Email}} </strong>{{end}}</span> <span class="tooltip" data-content="{{$.locale.Tr "settings.gpg_key_matched_identities_long"}}">{{svg "octicon-mail"}} {{$.locale.Tr "settings.gpg_key_matched_identities"}} {{range .Emails}}<strong>{{.Email}} </strong>{{end}}</span>

View File

@ -51,7 +51,7 @@
</div> </div>
<div class="content"> <div class="content">
{{if .Verified}} {{if .Verified}}
<span class="tooltip" data-content="{{$.locale.Tr "settings.ssh_key_verified_long"}}">{{svg "octicon-shield-check"}} <strong>{{$.locale.Tr "settings.ssh_key_verified"}}</strong></span> <span class="tooltip" data-content="{{$.locale.Tr "settings.ssh_key_verified_long"}}">{{svg "octicon-verified"}} <strong>{{$.locale.Tr "settings.ssh_key_verified"}}</strong></span>
{{end}} {{end}}
<strong>{{.Name}}</strong> <strong>{{.Name}}</strong>
<div class="print meta"> <div class="print meta">

View File

@ -1231,7 +1231,7 @@ a.ui.card:hover,
/* enable fluid page widths for medium size viewports */ /* enable fluid page widths for medium size viewports */
@media (min-width: 768px) and (max-width: 1200px) { @media (min-width: 768px) and (max-width: 1200px) {
.ui.ui.ui.container:not(.fluid) { .ui.ui.ui.container:not(.fluid) {
width: calc(100vw - 3em); width: calc(100vw - 64px);
} }
} }
@ -1285,7 +1285,14 @@ a.ui.card:hover,
.following.bar #navbar { .following.bar #navbar {
width: 100vw; width: 100vw;
min-height: 52px; min-height: 52px;
padding: 0 0.5rem; padding: 0 16px;
}
@media (max-width: 767px) {
.following.bar #navbar {
padding-left: 4px;
padding-right: 0;
}
} }
.following.bar #navbar .brand { .following.bar #navbar .brand {
@ -1491,7 +1498,7 @@ a.ui.card:hover,
} }
.ui.container.fluid.padded { .ui.container.fluid.padded {
padding: 0 10px; padding: 0 32px;
} }
.ui.form .ui.button { .ui.form .ui.button {

View File

@ -22,6 +22,7 @@
/* below class names match Tailwind CSS */ /* below class names match Tailwind CSS */
.gt-pointer-events-none { pointer-events: none !important; } .gt-pointer-events-none { pointer-events: none !important; }
.gt-relative { position: relative !important; } .gt-relative { position: relative !important; }
.gt-overflow-x-scroll { overflow-x: scroll !important; }
.gt-mono { .gt-mono {
font-family: var(--fonts-monospace) !important; font-family: var(--fonts-monospace) !important;

View File

@ -3337,10 +3337,6 @@ td.blob-excerpt {
min-width: 100px; min-width: 100px;
} }
.diff-file-body {
overflow-x: scroll;
}
.diff-stats-bar { .diff-stats-bar {
display: inline-block; display: inline-block;
background-color: var(--color-red); background-color: var(--color-red);

View File

@ -214,6 +214,10 @@ a.blob-excerpt:hover {
color: var(--color-primary-contrast); color: var(--color-primary-contrast);
} }
.review-box-panel .ui.segment {
border: none;
}
/* See the comment of createCommentEasyMDE() for the review editor */ /* See the comment of createCommentEasyMDE() for the review editor */
/* EasyMDE's options can not handle minHeight & maxHeight together correctly, we have to set minHeight in JS code */ /* EasyMDE's options can not handle minHeight & maxHeight together correctly, we have to set minHeight in JS code */
.review-box-panel .CodeMirror-scroll { .review-box-panel .CodeMirror-scroll {
@ -249,14 +253,6 @@ a.blob-excerpt:hover {
position: relative; position: relative;
} }
.review-box-panel {
position: absolute;
min-width: max-content;
top: 45px;
right: -5px;
z-index: 2;
}
#review-box .review-comments-counter { #review-box .review-comments-counter {
background-color: var(--color-primary-light-4); background-color: var(--color-primary-light-4);
color: var(--color-primary-contrast); color: var(--color-primary-contrast);

View File

@ -4,8 +4,9 @@ import {attachTribute} from './tribute.js';
import {createCommentEasyMDE, getAttachedEasyMDE} from './comp/EasyMDE.js'; import {createCommentEasyMDE, getAttachedEasyMDE} from './comp/EasyMDE.js';
import {initEasyMDEImagePaste} from './comp/ImagePaste.js'; import {initEasyMDEImagePaste} from './comp/ImagePaste.js';
import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js'; import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
import {initTooltip, showTemporaryTooltip} from '../modules/tippy.js'; import {initTooltip, showTemporaryTooltip, createTippy} from '../modules/tippy.js';
import {hideElem, showElem, toggleElem} from '../utils/dom.js'; import {hideElem, showElem, toggleElem} from '../utils/dom.js';
import {setFileFolding} from './file-fold.js';
const {appSubUrl, csrfToken} = window.config; const {appSubUrl, csrfToken} = window.config;
@ -436,17 +437,36 @@ export async function handleReply($el) {
export function initRepoPullRequestReview() { export function initRepoPullRequestReview() {
if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) { if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) {
// set scrollRestoration to 'manual' when there is a hash in url, so that the scroll position will not be remembered after refreshing
if (window.history.scrollRestoration !== 'manual') {
window.history.scrollRestoration = 'manual';
}
const commentDiv = $(window.location.hash); const commentDiv = $(window.location.hash);
if (commentDiv) { if (commentDiv) {
// get the name of the parent id // get the name of the parent id
const groupID = commentDiv.closest('div[id^="code-comments-"]').attr('id'); const groupID = commentDiv.closest('div[id^="code-comments-"]').attr('id');
if (groupID && groupID.startsWith('code-comments-')) { if (groupID && groupID.startsWith('code-comments-')) {
const id = groupID.slice(14); const id = groupID.slice(14);
const ancestorDiffBox = commentDiv.closest('.diff-file-box');
// on pages like conversation, there is no diff header
const diffHeader = ancestorDiffBox.find('.diff-file-header');
// offset is for scrolling
let offset = 30;
if (diffHeader[0]) {
offset += $('.diff-detail-box').outerHeight() + diffHeader.outerHeight();
}
$(`#show-outdated-${id}`).addClass('gt-hidden'); $(`#show-outdated-${id}`).addClass('gt-hidden');
$(`#code-comments-${id}`).removeClass('gt-hidden'); $(`#code-comments-${id}`).removeClass('gt-hidden');
$(`#code-preview-${id}`).removeClass('gt-hidden'); $(`#code-preview-${id}`).removeClass('gt-hidden');
$(`#hide-outdated-${id}`).removeClass('gt-hidden'); $(`#hide-outdated-${id}`).removeClass('gt-hidden');
commentDiv[0].scrollIntoView(); // if the comment box is folded, expand it
if (ancestorDiffBox.attr('data-folded') && ancestorDiffBox.attr('data-folded') === 'true') {
setFileFolding(ancestorDiffBox[0], ancestorDiffBox.find('.fold-file')[0], false);
}
window.scrollTo({
top: commentDiv.offset().top - offset,
behavior: 'instant'
});
} }
} }
} }
@ -491,12 +511,23 @@ export function initRepoPullRequestReview() {
return; return;
} }
$('.js-btn-review').on('click', function (e) { const $reviewBtn = $('.js-btn-review');
const $panel = $reviewBtn.parent().find('.review-box-panel');
const $closeBtn = $panel.find('.close');
const tippy = createTippy($reviewBtn[0], {
content: $panel[0],
placement: 'bottom',
trigger: 'click',
role: 'menu',
maxWidth: 'none',
interactive: true,
hideOnClick: true,
});
$closeBtn.on('click', (e) => {
e.preventDefault(); e.preventDefault();
toggleElem($(this).parent().find('.review-box-panel')); tippy.hide();
}).parent().find('.review-box-panel .close').on('click', function (e) {
e.preventDefault();
hideElem($(this).closest('.review-box-panel'));
}); });
$(document).on('click', 'a.add-code-comment', async function (e) { $(document).on('click', 'a.add-code-comment', async function (e) {