Add pull request manually merge instruction (#13840)

* add pull request command line instructions

* Add pull request manually merge instuction

* Fix styles

* Fix lint

* Move inline style to class file

* add space between merge button and hint text

* Add sentence end charcter

* Change the language file

* adjust secondary bg

* further adjustment

Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
Lunny Xiao 2020-12-10 10:59:05 +08:00 committed by GitHub
parent c85bb62635
commit 2d71cdb668
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 78 additions and 42 deletions

View file

@ -86,6 +86,9 @@ write = Write
preview = Preview preview = Preview
loading = Loading… loading = Loading…
step1 = Step 1:
step2 = Step 2:
error404 = The page you are trying to reach either <strong>does not exist</strong> or <strong>you are not authorized</strong> to view it. error404 = The page you are trying to reach either <strong>does not exist</strong> or <strong>you are not authorized</strong> to view it.
[error] [error]
@ -1296,6 +1299,10 @@ pulls.update_not_allowed = You are not allowed to update branch
pulls.outdated_with_base_branch = This branch is out-of-date with the base branch pulls.outdated_with_base_branch = This branch is out-of-date with the base branch
pulls.closed_at = `closed this pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>` pulls.closed_at = `closed this pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
pulls.reopened_at = `reopened this pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>` pulls.reopened_at = `reopened this pull request <a id="%[1]s" href="#%[1]s">%[2]s</a>`
pulls.merge_instruction_hint = `You can also view <a class="show-instruction">command line instructions</a>.`
pulls.merge_instruction_step1_desc = From your project repository, check out a new branch and test the changes.
pulls.merge_instruction_step2_desc = Merge the changes and update on Gitea.
milestones.new = New Milestone milestones.new = New Milestone
milestones.open_tab = %d Open milestones.open_tab = %d Open

View file

@ -323,6 +323,7 @@
</form> </form>
</div> </div>
{{end}} {{end}}
<div class="dib">
<div class="ui {{if $notAllOverridableChecksOk}}red{{else}}green{{end}} buttons merge-button"> <div class="ui {{if $notAllOverridableChecksOk}}red{{else}}green{{end}} buttons merge-button">
<button class="ui button" data-do="{{.MergeStyle}}"> <button class="ui button" data-do="{{.MergeStyle}}">
{{svg "octicon-git-merge"}} {{svg "octicon-git-merge"}}
@ -361,6 +362,22 @@
</div> </div>
{{end}} {{end}}
</div> </div>
</div>
<div class="dib ml-3">{{$.i18n.Tr "repo.pulls.merge_instruction_hint" | Safe}}</div>
<div class="instruct" style="display:none">
<div class="ui divider"></div>
<div><h3 class="di">{{$.i18n.Tr "step1"}} </h3>{{$.i18n.Tr "repo.pulls.merge_instruction_step1_desc"}}</div>
<div class="ui secondary segment">
<div>git checkout -b {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.OwnerName}}-{{end}}{{.Issue.PullRequest.HeadBranch}} {{.Issue.PullRequest.BaseBranch}}</div>
<div>git pull {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.HTMLURL}}{{else}}origin{{end}} {{.Issue.PullRequest.HeadBranch}}</div>
</div>
<div><h3 class="di">{{$.i18n.Tr "step2"}} </h3>{{$.i18n.Tr "repo.pulls.merge_instruction_step2_desc"}}</div>
<div class="ui secondary segment">
<div>git checkout {{.Issue.PullRequest.BaseBranch}}</div>
<div>git merge --no-ff {{if ne .Issue.PullRequest.HeadRepo.ID .Issue.PullRequest.BaseRepo.ID}}{{.Issue.PullRequest.HeadRepo.OwnerName}}-{{end}}{{.Issue.PullRequest.HeadBranch}}</div>
<div>git push origin {{.Issue.PullRequest.BaseBranch}}</div>
</div>
</div>
{{else}} {{else}}
<div class="ui divider"></div> <div class="ui divider"></div>
<div class="item text red"> <div class="item text red">

View file

@ -33,7 +33,7 @@
<span class="sr-only">{{.i18n.Tr "new_repo"}}</span> <span class="sr-only">{{.i18n.Tr "new_repo"}}</span>
</a> </a>
</h4> </h4>
<div class="ui attached secondary segment repos-search"> <div class="ui attached segment repos-search">
<div class="ui fluid right action left icon input" :class="{loading: isLoading}"> <div class="ui fluid right action left icon input" :class="{loading: isLoading}">
<input @input="searchRepos(reposFilter)" v-model="searchQuery" ref="search" placeholder="{{.i18n.Tr "home.search_repos"}}"> <input @input="searchRepos(reposFilter)" v-model="searchQuery" ref="search" placeholder="{{.i18n.Tr "home.search_repos"}}">
<i class="icon df ac jc">{{svg "octicon-search" 16}}</i> <i class="icon df ac jc">{{svg "octicon-search" 16}}</i>

View file

@ -1201,6 +1201,12 @@ async function initRepository() {
} }
} }
function initPullRequestMergeInstruction() {
$('.show-instruction').on('click', () => {
$('.instruct').toggle();
});
}
function initPullRequestReview() { function initPullRequestReview() {
if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) { if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) {
const commentDiv = $(window.location.hash); const commentDiv = $(window.location.hash);
@ -2526,6 +2532,7 @@ $(document).ready(async () => {
initContextPopups(); initContextPopups();
initTableSort(); initTableSort();
initNotificationsTable(); initNotificationsTable();
initPullRequestMergeInstruction();
const routes = { const routes = {
'div.user.settings': initUserSettings, 'div.user.settings': initUserSettings,

View file

@ -99,7 +99,8 @@
--color-markdown-code-block: #00000008; --color-markdown-code-block: #00000008;
--color-button: #ffffff; --color-button: #ffffff;
--color-code-bg: #ffffff; --color-code-bg: #ffffff;
--color-shadow: #00000024; --color-markdown-code-block: #00000010;
--color-secondary-bg: #f4f4f4;
} }
:root:lang(ja) { :root:lang(ja) {
@ -1691,6 +1692,11 @@ a.ui.basic.label:hover {
border-color: var(--color-secondary); border-color: var(--color-secondary);
} }
.ui.secondary.segment {
background: var(--color-secondary-bg);
color: var(--color-text-light);
}
.ui.attached.header { .ui.attached.header {
position: relative; position: relative;
background: var(--color-box-header); background: var(--color-box-header);

View file

@ -1,5 +1,7 @@
.df { display: flex !important; } .df { display: flex !important; }
.di { display: inline !important; }
.dif { display: inline-flex !important; } .dif { display: inline-flex !important; }
.dib { display: inline-block !important; }
.ac { align-items: center !important; } .ac { align-items: center !important; }
.tc { text-align: center !important; } .tc { text-align: center !important; }
.jc { justify-content: center !important; } .jc { justify-content: center !important; }

View file

@ -95,6 +95,7 @@
--color-button: #353846; --color-button: #353846;
--color-code-bg: #2a2e3a; --color-code-bg: #2a2e3a;
--color-shadow: #00000060; --color-shadow: #00000060;
--color-secondary-bg: #2a2e3a;
} }
/* LineTableTD */ /* LineTableTD */
@ -827,10 +828,6 @@ td.blob-hunk {
color: #dbdbdb; color: #dbdbdb;
} }
.ui.secondary.segment {
background: #353945;
}
.ui.attached.info.message, .ui.attached.info.message,
.ui.info.message { .ui.info.message {
box-shadow: 0 0 0 1px #4b5e71 inset, 0 0 0 0 transparent; box-shadow: 0 0 0 1px #4b5e71 inset, 0 0 0 0 transparent;