Skip to content

Commit c517e52

Browse files
authored
Merge branch 'release/v1.22' into backport-32244-v1.22
2 parents bcd4bdf + c1023b9 commit c517e52

File tree

5 files changed

+55
-35
lines changed

5 files changed

+55
-35
lines changed

routers/web/web.go

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,35 @@ func registerRoutes(m *web.Route) {
14541454
)
14551455
// end "/{username}/{reponame}/activity"
14561456

1457+
m.Group("/{username}/{reponame}", func() {
1458+
m.Group("/pulls/{index}", func() {
1459+
m.Get("", repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewIssue)
1460+
m.Get(".diff", repo.DownloadPullDiff)
1461+
m.Get(".patch", repo.DownloadPullPatch)
1462+
m.Group("/commits", func() {
1463+
m.Get("", context.RepoRef(), repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewPullCommits)
1464+
m.Get("/list", context.RepoRef(), repo.GetPullCommits)
1465+
m.Get("/{sha:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForSingleCommit)
1466+
})
1467+
m.Post("/merge", context.RepoMustNotBeArchived(), web.Bind(forms.MergePullRequestForm{}), repo.MergePullRequest)
1468+
m.Post("/cancel_auto_merge", context.RepoMustNotBeArchived(), repo.CancelAutoMergePullRequest)
1469+
m.Post("/update", repo.UpdatePullRequest)
1470+
m.Post("/set_allow_maintainer_edit", web.Bind(forms.UpdateAllowEditsForm{}), repo.SetAllowEdits)
1471+
m.Post("/cleanup", context.RepoMustNotBeArchived(), context.RepoRef(), repo.CleanUpPullRequest)
1472+
m.Group("/files", func() {
1473+
m.Get("", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForAllCommitsOfPr)
1474+
m.Get("/{sha:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesStartingFromCommit)
1475+
m.Get("/{shaFrom:[a-f0-9]{7,40}}..{shaTo:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForRange)
1476+
m.Group("/reviews", func() {
1477+
m.Get("/new_comment", repo.RenderNewCodeCommentForm)
1478+
m.Post("/comments", web.Bind(forms.CodeCommentForm{}), repo.SetShowOutdatedComments, repo.CreateCodeComment)
1479+
m.Post("/submit", web.Bind(forms.SubmitReviewForm{}), repo.SubmitReview)
1480+
}, context.RepoMustNotBeArchived())
1481+
})
1482+
})
1483+
}, ignSignIn, context.RepoAssignment, repo.MustAllowPulls, reqRepoPullsReader)
1484+
// end "/{username}/{reponame}/pulls/{index}": repo pull request
1485+
14571486
m.Group("/{username}/{reponame}", func() {
14581487
m.Group("/activity_author_data", func() {
14591488
m.Get("", repo.ActivityAuthors)
@@ -1492,32 +1521,6 @@ func registerRoutes(m *web.Route) {
14921521
return cancel
14931522
})
14941523

1495-
m.Group("/pulls/{index}", func() {
1496-
m.Get("", repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewIssue)
1497-
m.Get(".diff", repo.DownloadPullDiff)
1498-
m.Get(".patch", repo.DownloadPullPatch)
1499-
m.Group("/commits", func() {
1500-
m.Get("", context.RepoRef(), repo.SetWhitespaceBehavior, repo.GetPullDiffStats, repo.ViewPullCommits)
1501-
m.Get("/list", context.RepoRef(), repo.GetPullCommits)
1502-
m.Get("/{sha:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForSingleCommit)
1503-
})
1504-
m.Post("/merge", context.RepoMustNotBeArchived(), web.Bind(forms.MergePullRequestForm{}), repo.MergePullRequest)
1505-
m.Post("/cancel_auto_merge", context.RepoMustNotBeArchived(), repo.CancelAutoMergePullRequest)
1506-
m.Post("/update", repo.UpdatePullRequest)
1507-
m.Post("/set_allow_maintainer_edit", web.Bind(forms.UpdateAllowEditsForm{}), repo.SetAllowEdits)
1508-
m.Post("/cleanup", context.RepoMustNotBeArchived(), context.RepoRef(), repo.CleanUpPullRequest)
1509-
m.Group("/files", func() {
1510-
m.Get("", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForAllCommitsOfPr)
1511-
m.Get("/{sha:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesStartingFromCommit)
1512-
m.Get("/{shaFrom:[a-f0-9]{7,40}}..{shaTo:[a-f0-9]{7,40}}", context.RepoRef(), repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.SetShowOutdatedComments, repo.ViewPullFilesForRange)
1513-
m.Group("/reviews", func() {
1514-
m.Get("/new_comment", repo.RenderNewCodeCommentForm)
1515-
m.Post("/comments", web.Bind(forms.CodeCommentForm{}), repo.SetShowOutdatedComments, repo.CreateCodeComment)
1516-
m.Post("/submit", web.Bind(forms.SubmitReviewForm{}), repo.SubmitReview)
1517-
}, context.RepoMustNotBeArchived())
1518-
})
1519-
}, repo.MustAllowPulls)
1520-
15211524
m.Group("/media", func() {
15221525
m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.SingleDownloadOrLFS)
15231526
m.Get("/tag/*", context.RepoRefByType(context.RepoRefTag), repo.SingleDownloadOrLFS)

web_src/js/features/common-global.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,11 @@ export function checkAppUrl() {
453453
showGlobalErrorMessage(`Your ROOT_URL in app.ini is "${appUrl}", it's unlikely matching the site you are visiting.
454454
Mismatched ROOT_URL config causes wrong URL links for web UI/mail content/webhook notification/OAuth2 sign-in.`, 'warning');
455455
}
456+
457+
export function checkAppUrlScheme() {
458+
const curUrl = window.location.href;
459+
// some users visit "http://domain" while appUrl is "https://domain", COOKIE_SECURE makes it impossible to sign in
460+
if (curUrl.startsWith('http:') && appUrl.startsWith('https:')) {
461+
showGlobalErrorMessage(`This instance is configured to run under HTTPS (by ROOT_URL config), you are accessing by HTTP. Mismatched scheme might cause problems for sign-in/sign-up.`, 'warning');
462+
}
463+
}

web_src/js/features/repo-issue.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,17 @@ export function initRepoIssueCommentDelete() {
188188
const path = conversationHolder.getAttribute('data-path');
189189
const side = conversationHolder.getAttribute('data-side');
190190
const idx = conversationHolder.getAttribute('data-idx');
191-
const lineType = conversationHolder.closest('tr').getAttribute('data-line-type');
192-
193-
if (lineType === 'same') {
194-
document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).classList.remove('tw-invisible');
195-
} else {
196-
document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).classList.remove('tw-invisible');
191+
const lineType = conversationHolder.closest('tr')?.getAttribute('data-line-type');
192+
193+
// the conversation holder could appear either on the "Conversation" page, or the "Files Changed" page
194+
// on the Conversation page, there is no parent "tr", so no need to do anything for "add-code-comment"
195+
if (lineType) {
196+
if (lineType === 'same') {
197+
document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).classList.remove('tw-invisible');
198+
} else {
199+
document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).classList.remove('tw-invisible');
200+
}
197201
}
198-
199202
conversationHolder.remove();
200203
}
201204

web_src/js/features/user-auth.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import {checkAppUrl} from './common-global.js';
1+
import {checkAppUrl, checkAppUrlScheme} from './common-global.js';
2+
3+
export function initUserCheckAppUrl() {
4+
if (!document.querySelector('.page-content.user.signin, .page-content.user.signup, .page-content.user.link-account')) return;
5+
checkAppUrlScheme();
6+
}
27

38
export function initUserAuthOauth2() {
49
const outer = document.getElementById('oauth2-login-navigator');

web_src/js/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {initFindFileInRepo} from './features/repo-findfile.js';
2323
import {initCommentContent, initMarkupContent} from './markup/content.js';
2424
import {initPdfViewer} from './render/pdf.js';
2525

26-
import {initUserAuthOauth2} from './features/user-auth.js';
26+
import {initUserAuthOauth2, initUserCheckAppUrl} from './features/user-auth.js';
2727
import {
2828
initRepoIssueDue,
2929
initRepoIssueReferenceRepositorySearch,
@@ -184,6 +184,7 @@ onDomReady(() => {
184184
initCommitStatuses();
185185
initCaptcha();
186186

187+
initUserCheckAppUrl();
187188
initUserAuthOauth2();
188189
initUserAuthWebAuthn();
189190
initUserAuthWebAuthnRegister();

0 commit comments

Comments
 (0)