Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Use Vue to refactor pull merge UI (go-gitea#19650)
  [skip ci] Updated translations via Crowdin
  • Loading branch information
zjjhot committed May 12, 2022
2 parents 7ac964a + 368baf9 commit 067b922
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 232 deletions.
6 changes: 2 additions & 4 deletions integrations/pull_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum strin
req := NewRequest(t, "GET", path.Join(user, repo, "pulls", pullnum))
resp := session.MakeRequest(t, req, http.StatusOK)

// Click the little green button to create a pull
htmlDoc := NewHTMLParser(t, resp.Body)
link, exists := htmlDoc.doc.Find(".ui.form." + string(mergeStyle) + "-fields > form").Attr("action")
assert.True(t, exists, "The template has changed")
link := path.Join(user, repo, "pulls", pullnum, "merge")
req = NewRequestWithValues(t, "POST", link, map[string]string{
"_csrf": htmlDoc.GetCSRF(),
"do": string(mergeStyle),
Expand All @@ -57,7 +55,7 @@ func testPullCleanUp(t *testing.T, session *TestSession, user, repo, pullnum str
// Click the little green button to create a pull
htmlDoc := NewHTMLParser(t, resp.Body)
link, exists := htmlDoc.doc.Find(".timeline-item .delete-button").Attr("data-url")
assert.True(t, exists, "The template has changed")
assert.True(t, exists, "The template has changed, can not find delete button url")
req = NewRequestWithValues(t, "POST", link, map[string]string{
"_csrf": htmlDoc.GetCSRF(),
})
Expand Down
18 changes: 0 additions & 18 deletions models/repo/repo_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,6 @@ func (cfg *PullRequestsConfig) GetDefaultMergeStyle() MergeStyle {
return MergeStyleMerge
}

// AllowedMergeStyleCount returns the total count of allowed merge styles for the PullRequestsConfig
func (cfg *PullRequestsConfig) AllowedMergeStyleCount() int {
count := 0
if cfg.AllowMerge {
count++
}
if cfg.AllowRebase {
count++
}
if cfg.AllowRebaseMerge {
count++
}
if cfg.AllowSquash {
count++
}
return count
}

// BeforeSet is invoked from XORM before setting the value of a field of this object.
func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) {
switch colName {
Expand Down
28 changes: 14 additions & 14 deletions options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ hidden_comment_types=Tipos de comentários ocultos
comment_type_group_reference=Referência
comment_type_group_label=Rótulo
comment_type_group_milestone=Etapa
comment_type_group_assignee=Responsável
comment_type_group_assignee=Encarregado
comment_type_group_title=Título
comment_type_group_branch=Ramo
comment_type_group_time_tracking=Contagem de tempo
Expand Down Expand Up @@ -1188,7 +1188,7 @@ projects.close=Fechar
projects.board.assigned_to=Atribuído a

issues.desc=Organize relatórios de erros, tarefas e etapas.
issues.filter_assignees=Filtrar responsável
issues.filter_assignees=Filtrar encarregado
issues.filter_milestones=Filtrar etapa
issues.filter_projects=Filtrar planeamento
issues.filter_labels=Filtrar rótulo
Expand All @@ -1212,10 +1212,10 @@ issues.new.no_milestone=Sem etapa
issues.new.clear_milestone=Limpar etapa
issues.new.open_milestone=Etapas abertas
issues.new.closed_milestone=Etapas fechadas
issues.new.assignees=Responsáveis
issues.new.add_assignees_title=Definir responsáveis
issues.new.clear_assignees=Limpar responsáveis
issues.new.no_assignees=Sem responsáveis
issues.new.assignees=Encarregados
issues.new.add_assignees_title=Definir encarregados
issues.new.clear_assignees=Retirar todos os encarregados
issues.new.no_assignees=Sem encarregados
issues.new.no_reviewers=Sem revisores
issues.new.add_reviewer_title=Solicitar revisão
issues.choose.get_started=Começar
Expand Down Expand Up @@ -1261,8 +1261,7 @@ issues.filter_label_exclude=`Use <code>alt</code> + <code>clique/enter</code> pa
issues.filter_label_no_select=Todos os rótulos
issues.filter_milestone=Etapa
issues.filter_milestone_no_select=Todas as etapas
issues.filter_assignee=Responsável
issues.filter_assginee_no_select=Todos os responsáveis
issues.filter_assignee=Encarregado
issues.filter_type=Tipo
issues.filter_type.all_issues=Todas as questões
issues.filter_type.assigned_to_you=Atribuídas a si
Expand All @@ -1288,8 +1287,8 @@ issues.action_close=Fechar
issues.action_label=Rótulo
issues.action_milestone=Etapa
issues.action_milestone_no_select=Sem etapa
issues.action_assignee=Responsável
issues.action_assignee_no_select=Sem responsável
issues.action_assignee=Encarregado
issues.action_assignee_no_select=Sem encarregado
issues.opened_by=aberta %[1]s por <a href="%[2]s">%[3]s</a>
pulls.merged_by=por <a href="%[2]s">%[3]s</a> foi executado %[1]s
pulls.merged_by_fake=por %[2]s foi executado %[1]s
Expand Down Expand Up @@ -1461,6 +1460,7 @@ issues.review.add_review_request=solicitou revisão de %s %s
issues.review.remove_review_request=removeu a solicitação de revisão para %s %s
issues.review.remove_review_request_self=recusou-se a rever %s
issues.review.pending=Pendente
issues.review.pending.tooltip=Este comentário não está visível para os outros utilizadores, neste momento. Para submeter os seus comentários pendentes, escolha '%s' -> '%s/%s/%s' no topo da página.
issues.review.review=Revisão
issues.review.reviewers=Revisores
issues.review.outdated=Obsoleta
Expand All @@ -1471,7 +1471,7 @@ issues.review.hide_resolved=Ocultar os concluídos
issues.review.resolve_conversation=Passar diálogo ao estado de resolvido
issues.review.un_resolve_conversation=Passar diálogo ao estado de não resolvido
issues.review.resolved_by=marcou este diálogo como estando concluído
issues.assignee.error=Nem todos os responsáveis foram adicionados devido a um erro inesperado.
issues.assignee.error=Nem todos os encarregados foram adicionados devido a um erro inesperado.
issues.reference_issue.body=Conteúdo
issues.content_history.deleted=eliminado
issues.content_history.edited=editado
Expand Down Expand Up @@ -1954,7 +1954,7 @@ settings.event_header_issue=Eventos da questão
settings.event_issues=Questões
settings.event_issues_desc=Questão aberta, fechada, reaberta ou editada.
settings.event_issue_assign=Questão atribuída
settings.event_issue_assign_desc=Responsável atribuído ou retirado à questão.
settings.event_issue_assign_desc=Encarregado atribuído ou retirado à questão.
settings.event_issue_label=Questão com rótulo
settings.event_issue_label_desc=Rótulos modificados ou retirados às questões.
settings.event_issue_milestone=Questão com etapa atribuída
Expand All @@ -1964,8 +1964,8 @@ settings.event_issue_comment_desc=Comentário da questão criado, editado ou eli
settings.event_header_pull_request=Eventos de pedidos de integração
settings.event_pull_request=Pedido de integração
settings.event_pull_request_desc=Pedido de integração aberto, fechado, reaberto ou editado.
settings.event_pull_request_assign=Responsável atribuído ao pedido de integração
settings.event_pull_request_assign_desc=Responsável atribuído ou retirado ao pedido de integração.
settings.event_pull_request_assign=Encarregado atribuído ao pedido de integração
settings.event_pull_request_assign_desc=Encarregado atribuído ou retirado ao pedido de integração.
settings.event_pull_request_label=Rótulo atribuído ao pedido de integração
settings.event_pull_request_label_desc=Rótulos modificados ou retirados aos pedidos de integração.
settings.event_pull_request_milestone=Etapa atribuída ao pedido de integração
Expand Down
229 changes: 61 additions & 168 deletions templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -322,176 +322,69 @@
{{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
{{$approvers := .Issue.PullRequest.GetApprovers}}
{{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash}}

<div class="ui divider"></div>
{{if $prUnit.PullRequestsConfig.AllowMerge}}
<div class="ui form merge-fields" style="display: none">
<form action="{{.Link}}/merge" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="head_commit_id" value="{{.PullHeadCommitID}}">
<div class="field">
<input type="text" name="merge_title_field" value="{{.DefaultMergeMessage}}">
</div>
<div class="field">
<textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
</div>
<button class="ui green button" type="submit" name="do" value="merge">
{{$.i18n.Tr "repo.pulls.merge_pull_request"}}
</button>
<button class="ui button merge-cancel">
{{$.i18n.Tr "cancel"}}
</button>
{{if .IsPullBranchDeletable}}
<div class="ui checkbox ml-2">
<input name="delete_branch_after_merge" type="checkbox" {{if $prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}}checked{{end}}>
<label>{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</label>
</div>
{{end}}
</form>
</div>
{{end}}
{{if $prUnit.PullRequestsConfig.AllowRebase}}
<div class="ui form rebase-fields" style="display: none">
<form action="{{.Link}}/merge" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="head_commit_id" value="{{.PullHeadCommitID}}">
<button class="ui green button" type="submit" name="do" value="rebase">
{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
</button>
<button class="ui button merge-cancel">
{{$.i18n.Tr "cancel"}}
</button>
{{if .IsPullBranchDeletable}}
<div class="ui checkbox ml-2">
<input name="delete_branch_after_merge" type="checkbox" {{if $prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}}checked{{end}}>
<label>{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</label>
</div>
{{end}}
</form>
</div>
{{end}}
{{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
<div class="ui form rebase-merge-fields" style="display: none">
<form action="{{.Link}}/merge" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="head_commit_id" value="{{.PullHeadCommitID}}">
<div class="field">
<input type="text" name="merge_title_field" value="{{.DefaultMergeMessage}}">
</div>
<div class="field">
<textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
</div>
<button class="ui green button" type="submit" name="do" value="rebase-merge">
{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
</button>
<button class="ui button merge-cancel">
{{$.i18n.Tr "cancel"}}
</button>
{{if .IsPullBranchDeletable}}
<div class="ui checkbox ml-2">
<input name="delete_branch_after_merge" type="checkbox" {{if $prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}}checked{{end}}>
<label>{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</label>
</div>
{{end}}
</form>
</div>
{{end}}
{{if $prUnit.PullRequestsConfig.AllowSquash}}
<div class="ui form squash-fields" style="display: none">
<form action="{{.Link}}/merge" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="head_commit_id" value="{{.PullHeadCommitID}}">
<div class="field">
<input type="text" name="merge_title_field" value="{{.DefaultSquashMergeMessage}}">
</div>
<div class="field">
<textarea name="merge_message_field" rows="5" placeholder="{{$.i18n.Tr "repo.editor.commit_message_desc"}}">{{.GetCommitMessages}}Reviewed-on: {{$.Issue.HTMLURL}}&#13;&#10;{{$approvers}}</textarea>
</div>
<button class="ui green button" type="submit" name="do" value="squash">
{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
</button>
<button class="ui button merge-cancel">
{{$.i18n.Tr "cancel"}}
</button>
{{if .IsPullBranchDeletable}}
<div class="ui checkbox ml-2">
<input name="delete_branch_after_merge" type="checkbox" {{if $prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}}checked{{end}}>
<label>{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</label>
</div>
{{end}}
</form>
</div>
{{end}}
{{if and $prUnit.PullRequestsConfig.AllowManualMerge $.IsRepoAdmin}}
<div class="ui form manually-merged-fields" style="display: none">
<form action="{{.Link}}/merge" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="head_commit_id" value="{{.PullHeadCommitID}}">
<div class="field">
<input type="text" name="merge_commit_id" placeholder="{{$.i18n.Tr "repo.pulls.merge_commit_id"}}">
</div>
<button class="ui red button" type="submit" name="do" value="manually-merged">
{{$.i18n.Tr "repo.pulls.merge_manually"}}
</button>
<button class="ui button merge-cancel">
{{$.i18n.Tr "cancel"}}
</button>
{{if .IsPullBranchDeletable}}
<div class="ui checkbox ml-2">
<input name="delete_branch_after_merge" type="checkbox" {{if $prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}}checked{{end}}>
<label>{{$.i18n.Tr "repo.branch.delete" .HeadTarget}}</label>
</div>
{{end}}
</form>
</div>
{{end}}
<div class="dib">
<div class="ui {{if $notAllOverridableChecksOk}}red{{else}}green{{end}} buttons merge-button">
<button class="ui button" data-do="{{.MergeStyle}}">
{{svg "octicon-git-merge"}}
<span class="button-text">
{{if eq .MergeStyle "merge"}}
{{$.i18n.Tr "repo.pulls.merge_pull_request"}}
{{end}}
{{if eq .MergeStyle "rebase"}}
{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}
{{end}}
{{if eq .MergeStyle "rebase-merge"}}
{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}
{{end}}
{{if eq .MergeStyle "squash"}}
{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}
{{end}}
{{if eq .MergeStyle "manually-merged"}}
{{$.i18n.Tr "repo.pulls.merge_manually"}}
{{end}}
</span>
</button>
{{if gt $prUnit.PullRequestsConfig.AllowedMergeStyleCount 1}}
<div class="ui dropdown icon button no-text">
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
{{if $prUnit.PullRequestsConfig.AllowMerge}}
<div class="item{{if eq .MergeStyle "merge"}} active selected{{end}}" data-do="merge">{{$.i18n.Tr "repo.pulls.merge_pull_request"}}</div>
{{end}}
{{if $prUnit.PullRequestsConfig.AllowRebase}}
<div class="item{{if eq .MergeStyle "rebase"}} active selected{{end}}" data-do="rebase">{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}</div>
{{end}}
{{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
<div class="item{{if eq .MergeStyle "rebase-merge"}} active selected{{end}}" data-do="rebase-merge">{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</div>
{{end}}
{{if $prUnit.PullRequestsConfig.AllowSquash}}
<div class="item{{if eq .MergeStyle "squash"}} active selected{{end}}" data-do="squash">{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}</div>
{{end}}
{{if and $prUnit.PullRequestsConfig.AllowManualMerge $.IsRepoAdmin}}
<div class="item{{if eq .MergeStyle "manually-merged"}} active selected{{end}}" data-do="manually-merged">{{$.i18n.Tr "repo.pulls.merge_manually"}}</div>
{{end}}
</div>
</div>
{{end}}
</div>
</div>

<script>
<!-- /* eslint-disable */ -->
(() => {
const defaultMergeTitle = {{.DefaultMergeMessage}};
const defaultSquashMergeTitle = {{.DefaultSquashMergeMessage}};
const defaultMergeMessage = 'Reviewed-on: ' + {{$.Issue.HTMLURL}} + '\n' + {{$approvers}};
const mergeForm = {
'baseLink': {{.Link}},
'textCancel': {{$.i18n.Tr "cancel"}},
'textDeleteBranch': {{$.i18n.Tr "repo.branch.delete" .HeadTarget}},
'allOverridableChecksOk': {{not $notAllOverridableChecksOk}},
'pullHeadCommitID': {{.PullHeadCommitID}},
'isPullBranchDeletable': {{.IsPullBranchDeletable}},
'defaultDeleteBranchAfterMerge': {{$prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}},
'mergeMessageFieldPlaceHolder': {{$.i18n.Tr "repo.editor.commit_message_desc"}},
};
mergeForm['mergeStyles'] = [
{
'name': 'merge',
'allowed': {{$prUnit.PullRequestsConfig.AllowMerge}},
'textDoMerge': {{$.i18n.Tr "repo.pulls.merge_pull_request"}},
'mergeTitleFieldText': defaultMergeTitle,
'mergeMessageFieldText': defaultMergeMessage,
},
{
'name': 'rebase',
'allowed': {{$prUnit.PullRequestsConfig.AllowRebase}},
'textDoMerge': {{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}},
'hideMergeMessageTexts': true,
},
{
'name': 'rebase-merge',
'allowed': {{$prUnit.PullRequestsConfig.AllowRebaseMerge}},
'textDoMerge': {{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}},
'mergeTitleFieldText': defaultMergeTitle,
'mergeMessageFieldText': defaultMergeMessage,
},
{
'name': 'squash',
'allowed': {{$prUnit.PullRequestsConfig.AllowSquash}},
'textDoMerge': {{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}},
'mergeTitleFieldText': defaultSquashMergeTitle,
'mergeMessageFieldText': defaultMergeMessage,
},
{
'name': 'manually-merged',
'allowed': {{and $prUnit.PullRequestsConfig.AllowManualMerge $.IsRepoAdmin}},
'textDoMerge': {{$.i18n.Tr "repo.pulls.merge_manually"}},
'hideMergeMessageTexts': true,
}
];
window.config.pageData.pullRequestMergeForm = mergeForm;
})();
</script>

<div id="pull-request-merge-form"></div>

{{if .ShowMergeInstructions}}
<div class="instruct-toggle ml-3"> {{$.i18n.Tr "repo.pulls.merge_instruction_hint" | Safe}} </div>
<div class="instruct-toggle mt-3"> {{$.i18n.Tr "repo.pulls.merge_instruction_hint" | Safe}} </div>
<div class="instruct-content" 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>
Expand Down
Loading

0 comments on commit 067b922

Please sign in to comment.