[Notice] Announcing the End of Demo Server [Read me]

Refactored pullRequest form
@3ad394e37252e74b51e0f4aed6ba15154a0539b1
--- app/assets/stylesheets/less/_common.less
+++ app/assets/stylesheets/less/_common.less
... | ... | @@ -233,3 +233,8 @@ |
233 | 233 |
-o-box-shadow: 0 1px 1px rgba(0,0,0,0.2), inset 0 1px 1px rgba(0,0,0,0.1); |
234 | 234 |
box-shadow: 0 1px 1px rgba(0,0,0,0.2), inset 0 1px 1px rgba(0,0,0,0.1); |
235 | 235 |
} |
236 |
+ |
|
237 |
+.vmiddle-inline { |
|
238 |
+ display:inline-block !important; |
|
239 |
+ vertical-align: middle !important; |
|
240 |
+} |
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
... | ... | @@ -4770,38 +4770,23 @@ |
4770 | 4770 |
|
4771 | 4771 |
// -- pull request |
4772 | 4772 |
.pull-request-wrap { |
4773 |
+ position:relative; |
|
4774 |
+ display: block; |
|
4773 | 4775 |
margin-bottom:20px; |
4774 |
- display: table; |
|
4776 |
+ min-height:55px; |
|
4775 | 4777 |
|
4776 |
- .request-box { |
|
4777 |
- border: 1px solid lightgray; |
|
4778 |
- border-radius: 3px !important; |
|
4779 |
- display:inline-block; width:350px; |
|
4780 |
- .repo { color:@secondary; font-size:14px; } |
|
4781 |
- .dropdown-toggle { width:350px; } |
|
4782 |
- .dropdown-menu { width:350px; } |
|
4783 |
- padding: 5px; |
|
4784 |
- } |
|
4785 |
- |
|
4786 |
- label { |
|
4778 |
+ .field-title { |
|
4779 |
+ display:block; |
|
4787 | 4780 |
font-weight: bold; |
4788 |
- cursor: default; |
|
4789 |
- } |
|
4790 |
- |
|
4791 |
- .request-from { |
|
4792 |
- .request-box; |
|
4793 |
- } |
|
4794 |
- |
|
4795 |
- .request-to { |
|
4796 |
- .request-box; |
|
4797 | 4781 |
} |
4798 | 4782 |
|
4799 | 4783 |
.arrow { |
4800 |
- display:table-cell; vertical-align:middle; |
|
4801 |
- width:50px; |
|
4784 |
+ position:absolute; |
|
4785 |
+ left:50%; top:20px; |
|
4786 |
+ margin-left:-16px; |
|
4802 | 4787 |
text-align:center; |
4803 |
- font-size: xx-large; |
|
4804 |
- color: lightgray; |
|
4788 |
+ color: @yobi-gray; |
|
4789 |
+ font-size: 32px; |
|
4805 | 4790 |
} |
4806 | 4791 |
} |
4807 | 4792 |
|
--- app/controllers/PullRequestApp.java
+++ app/controllers/PullRequestApp.java
... | ... | @@ -176,12 +176,6 @@ |
176 | 176 |
, StringUtils.defaultIfBlank(request().getQueryString("fromBranch"), fromBranches.get(0).getName()) |
177 | 177 |
, StringUtils.defaultIfBlank(request().getQueryString("toBranch"), project.defaultBranch())); |
178 | 178 |
|
179 |
- if (HttpUtil.isRequestedWithXHR(request())) { |
|
180 |
- response().setHeader("Cache-Control", "no-cache, no-store"); |
|
181 |
- PullRequestMergeResult mergeResult = pullRequest.getPullRequestMergeResult(); |
|
182 |
- return ok(partial_diff.render(new Form<>(PullRequest.class).fill(pullRequest), project, pullRequest, mergeResult)); |
|
183 |
- } |
|
184 |
- |
|
185 | 179 |
return ok(create.render("title.newPullRequest", new Form<>(PullRequest.class).fill(pullRequest), project, projects, fromProject, toProject, fromBranches, toBranches, pullRequest)); |
186 | 180 |
} |
187 | 181 |
|
... | ... | @@ -199,6 +193,32 @@ |
199 | 193 |
return selectedProject; |
200 | 194 |
} |
201 | 195 |
|
196 |
+ @With(AnonymousCheckAction.class) |
|
197 |
+ @IsCreatable(ResourceType.FORK) |
|
198 |
+ public static Result mergeResult(String userName, String projectName) throws IOException, GitAPIException { |
|
199 |
+ final Project project = Project.findByOwnerAndProjectName(userName, projectName); |
|
200 |
+ |
|
201 |
+ ValidationResult validation = validateBeforePullRequest(project); |
|
202 |
+ if(validation.hasError()) { |
|
203 |
+ return validation.getResult(); |
|
204 |
+ } |
|
205 |
+ |
|
206 |
+ final Project fromProject = getSelectedProject(project, request().getQueryString("fromProjectId"), false); |
|
207 |
+ final Project toProject = getSelectedProject(project, request().getQueryString("toProjectId"), true); |
|
208 |
+ |
|
209 |
+ final List<GitBranch> fromBranches = new GitRepository(fromProject).getAllBranches(); |
|
210 |
+ final List<GitBranch> toBranches = new GitRepository(toProject).getAllBranches(); |
|
211 |
+ |
|
212 |
+ final PullRequest pullRequest = PullRequest.createNewPullRequest(fromProject, toProject |
|
213 |
+ , StringUtils.defaultIfBlank(request().getQueryString("fromBranch"), fromBranches.get(0).getName()) |
|
214 |
+ , StringUtils.defaultIfBlank(request().getQueryString("toBranch"), toBranches.get(0).getName())); |
|
215 |
+ |
|
216 |
+ PullRequestMergeResult mergeResult = pullRequest.getPullRequestMergeResult(); |
|
217 |
+ |
|
218 |
+ response().setHeader("Cache-Control", "no-cache, no-store"); |
|
219 |
+ return ok(partial_merge_result.render(project, pullRequest, mergeResult)); |
|
220 |
+ } |
|
221 |
+ |
|
202 | 222 |
@Transactional |
203 | 223 |
@With(AnonymousCheckAction.class) |
204 | 224 |
@IsCreatable(ResourceType.FORK) |
--- app/views/git/create.scala.html
+++ app/views/git/create.scala.html
... | ... | @@ -18,7 +18,10 @@ |
18 | 18 |
* See the License for the specific language governing permissions and |
19 | 19 |
* limitations under the License. |
20 | 20 |
**@ |
21 |
-@(title:String, form: Form[PullRequest], project: Project, projects: List[Project] , fromProject:Project, toProject:Project, fromBranches: List[playRepository.GitBranch], toBranches: List[playRepository.GitBranch], pullRequest:models.PullRequest) |
|
21 |
+@(title:String, form:Form[PullRequest], project:Project, projects:List[Project], |
|
22 |
+ fromProject:Project, toProject:Project, |
|
23 |
+ fromBranches:List[playRepository.GitBranch], toBranches:List[playRepository.GitBranch], |
|
24 |
+ pullRequest:models.PullRequest) |
|
22 | 25 |
|
23 | 26 |
@import scala.collection.Map |
24 | 27 |
@import utils.TemplateHelper._ |
... | ... | @@ -31,121 +34,104 @@ |
31 | 34 |
<div class="project-page-wrap"> |
32 | 35 |
<div class="content-wrap frm-wrap"> |
33 | 36 |
@helper.form(action=routes.PullRequestApp.newPullRequest(project.owner, project.name), 'enctype -> "multipart/form-data", 'class->"nm"){ |
34 |
- <div class="row-fluid"> |
|
35 |
- <div class="span10"> |
|
36 |
- <div class="pull-request-wrap"> |
|
37 |
- <div class="option request-from"> |
|
38 |
- <div class="option-label"> |
|
39 |
- <label>@Messages("pullRequest.from")</label> |
|
40 |
- <div class="btn-group branches" data-name="fromProjectId"> |
|
41 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
42 |
- <span class="d-label">@Messages("pullRequest.select.branch")</span> |
|
43 |
- <span class="d-caret"><span class="caret"></span></span> |
|
44 |
- </button> |
|
45 |
- <ul class="dropdown-menu"> |
|
46 |
- @for(repo <- projects) { |
|
47 |
- @if(ProjectUser.isMember(UserApp.currentUser().id, repo.id)) { |
|
48 |
- <li data-value="@repo.id" @if(repo.id == fromProject.id) {data-selected="true"}> |
|
49 |
- <a href="#"><span class="label">repo</span>@repo.owner/@repo.name</a> |
|
50 |
- </li> |
|
51 |
- } |
|
52 |
- } |
|
53 |
- </ul> |
|
54 |
- </div> |
|
55 |
- </div> |
|
56 |
- <div class="option-desc mt5"> |
|
57 |
- <div class="btn-group branches" data-name="fromBranch"> |
|
58 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
59 |
- <span class="d-label">@Messages("pullRequest.select.branch")</span> |
|
60 |
- <span class="d-caret"><span class="caret"></span></span> |
|
61 |
- </button> |
|
62 |
- <ul class="dropdown-menu"> |
|
63 |
- @for(branch <- fromBranches) { |
|
64 |
- @common.branchItem("pullRequest", null, branch.getName, null, |
|
65 |
- utils.TemplateHelper.equals(pullRequest.fromBranch, branch.getName)) |
|
66 |
- } |
|
67 |
- </ul> |
|
68 |
- </div> |
|
69 |
- </div> |
|
70 |
- </div> |
|
71 |
- |
|
72 |
- <div class="arrow"> |
|
73 |
- <i class="yobicon-right-2"></i> |
|
74 |
- </div> |
|
75 |
- |
|
76 |
- <div class="option request-to"> |
|
77 |
- <div class="option-label"> |
|
78 |
- <label>@Messages("pullRequest.to")</label> |
|
79 |
- <div class="btn-group branches" data-name="toProjectId"> |
|
80 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
81 |
- <span class="d-label">@Messages("pullRequest.select.branch")</span> |
|
82 |
- <span class="d-caret"><span class="caret"></span></span> |
|
83 |
- </button> |
|
84 |
- <ul class="dropdown-menu"> |
|
85 |
- @for(repo <- projects) { |
|
86 |
- <li data-value="@repo.id" @if(repo.id == toProject.id) {data-selected="true"}> |
|
87 |
- <a href="#"><span class="label">repo</span>@repo.owner/@repo.name</a> |
|
88 |
- </li> |
|
89 |
- } |
|
90 |
- </ul> |
|
91 |
- </div> |
|
92 |
- </div> |
|
93 |
- <div class="option-desc mt5"> |
|
94 |
- <div class="btn-group branches" data-name="toBranch"> |
|
95 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
96 |
- <span class="d-label">@Messages("pullRequest.select.branch")</span> |
|
97 |
- <span class="d-caret"><span class="caret"></span></span> |
|
98 |
- </button> |
|
99 |
- <ul class="dropdown-menu"> |
|
100 |
- @for(branch <- toBranches) { |
|
101 |
- @common.branchItem("pullRequest", null, branch.getName, null, |
|
102 |
- utils.TemplateHelper.equals(pullRequest.toBranch, branch.getName)) |
|
103 |
- } |
|
104 |
- </ul> |
|
105 |
- </div> |
|
106 |
- </div> |
|
107 |
- </div> |
|
108 |
- </div> |
|
37 |
+ <div class="pull-request-wrap"> |
|
38 |
+ <!-- from --> |
|
39 |
+ <div class="pull-left"> |
|
40 |
+ <label for="fromProjectId" class="field-title">@Messages("pullRequest.from")</label> |
|
41 |
+ <select id="fromProjectId" name="fromProjectId" data-toggle="select2" class="mr5"> |
|
42 |
+ <option></option> |
|
43 |
+ @for(repo <- projects if ProjectUser.isMember(UserApp.currentUser().id, repo.id)) { |
|
44 |
+ <option value="@repo.id" @if(repo.id == fromProject.id){ selected }> |
|
45 |
+ @repo.owner / @repo.name |
|
46 |
+ </option> |
|
47 |
+ } |
|
48 |
+ </select> |
|
49 |
+ <select id="fromBranch" name="fromBranch" data-toggle="select2" data-format="branch" |
|
50 |
+ data-dropdown-css-class="branches" data-placeholder="@Messages("pullRequest.select.branch")"> |
|
51 |
+ <option></option> |
|
52 |
+ @for(branch <- fromBranches) { |
|
53 |
+ <option value="@branch.getName" @if(branch.getName == pullRequest.fromBranch){ selected }>@branch.getName</option> |
|
54 |
+ } |
|
55 |
+ </select> |
|
109 | 56 |
</div> |
110 |
- <div class="span2"> |
|
111 |
- <table class="request-summary"> |
|
112 |
- <tr> |
|
113 |
- <th>@Messages("pullRequest.is.safe.title")</th> |
|
114 |
- <td id="ableToMerge"> |
|
115 |
- @Messages("pullRequest.is.checking") |
|
116 |
- </td> |
|
117 |
- </tr> |
|
118 |
- <tr> |
|
119 |
- <th>@Messages("pullRequest.commmit.count")</th> |
|
120 |
- <td id="commitCount"> |
|
121 |
- @Messages("pullRequest.is.checking") |
|
122 |
- </td> |
|
123 |
- </tr> |
|
124 |
- </table> |
|
57 |
+ <!-- // --> |
|
58 |
+ |
|
59 |
+ <div class="arrow"> |
|
60 |
+ <i class="yobicon-right-2"></i> |
|
61 |
+ </div> |
|
62 |
+ |
|
63 |
+ <!-- to --> |
|
64 |
+ <div class="pull-right"> |
|
65 |
+ <label for="toProjectId" class="field-title">@Messages("pullRequest.to")</label> |
|
66 |
+ <select id="toProjectId" name="toProjectId" data-toggle="select2" class="mr5"> |
|
67 |
+ <option></option> |
|
68 |
+ @for(repo <- projects){ |
|
69 |
+ <option value="@repo.id" @if(repo.id == toProject.id){ selected }> |
|
70 |
+ @repo.owner / @repo.name |
|
71 |
+ </option> |
|
72 |
+ } |
|
73 |
+ </select> |
|
74 |
+ <select id="toBranch" name="toBranch" data-toggle="select2" data-format="branch" |
|
75 |
+ data-dropdown-css-class="branches" data-placeholder="@Messages("pullRequest.select.branch")"> |
|
76 |
+ <option></option> |
|
77 |
+ @for(branch <- toBranches) { |
|
78 |
+ <option value="@branch.getName" @if(branch.getName == pullRequest.toBranch){ selected }>@branch.getName</option> |
|
79 |
+ } |
|
80 |
+ </select> |
|
81 |
+ </div> |
|
82 |
+ <!-- // --> |
|
83 |
+ </div> |
|
84 |
+ |
|
85 |
+ <div id="status" class="alert mt20 mb20"> |
|
86 |
+ @Messages("pullRequest.is.merging") |
|
87 |
+ </div> |
|
88 |
+ |
|
89 |
+ <div> |
|
90 |
+ <input type="text" id="title" name="title" maxlength="255" class="text" placeholder="@Messages("title")"> |
|
91 |
+ <div style="position: relative;"> |
|
92 |
+ @common.editor("body", pullRequest.body, "", "content-body") |
|
93 |
+ </div> |
|
94 |
+ @common.fileUploader(ResourceType.PULL_REQUEST, null) |
|
95 |
+ @common.markdown(project) |
|
96 |
+ |
|
97 |
+ <div class="actions"> |
|
98 |
+ <button type="submit" class="ybtn ybtn-success">@Messages("pullRequest.send")</button> |
|
99 |
+ <a href="javascript:history.back();" class="ybtn">@Messages("button.cancel")</a> |
|
125 | 100 |
</div> |
126 | 101 |
</div> |
127 | 102 |
|
128 |
- <div id="frmWrap"> |
|
129 |
- @* this area will be replaced with asynchronously by yobi.git.Write.js after load this page. *@ |
|
130 |
- <input type="hidden" id="title"> |
|
131 |
- <textarea id="body" style="display: none;" data-editor-mode="content-body">@pullRequest.body</textarea> |
|
132 |
- <div id="spin" style="position: absolute; top:50%; left:50%"></div> |
|
103 |
+ <ul class="nav nav-tabs mt20"> |
|
104 |
+ <li class="active"> |
|
105 |
+ <a href="#__commits" data-toggle="tab"> |
|
106 |
+ <span class="vmiddle-inline">@Messages("pullRequest.menu.commit")</span> |
|
107 |
+ <span id="numOfCommits" class="num-badge vmiddle-inline"></span> |
|
108 |
+ </a> |
|
109 |
+ </li> |
|
110 |
+ </ul> |
|
111 |
+ |
|
112 |
+ <div class="tab-content"> |
|
113 |
+ <div id="__commits" class="code-browse-wrap tab-pane active"> |
|
114 |
+ @** this area will be replaced with asynchronously by yobi.git.Write.js after load this page. **@ |
|
115 |
+ </div> |
|
133 | 116 |
</div> |
134 | 117 |
} |
135 | 118 |
</div> |
136 | 119 |
</div> |
137 | 120 |
</div> |
121 |
+ |
|
122 |
+@common.select2() |
|
123 |
+ |
|
138 | 124 |
<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("javascripts/lib/atjs/jquery.atwho.css")"> |
139 | 125 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/atjs/jquery.caret.min.js")"></script> |
140 | 126 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/atjs/jquery.atwho.js")"></script> |
141 | 127 |
<script type="text/javascript"> |
142 |
-$(document).ready(function() { |
|
128 |
+$(function(){ |
|
143 | 129 |
$yobi.loadModule("git.Write", { |
144 |
- "sFormURL" : "@routes.PullRequestApp.newPullRequestForm(project.owner, project.name)", |
|
145 |
- "welFromProject": $("div[data-name='fromProjectId']"), |
|
146 |
- "welToProject" : $("div[data-name='toProjectId']"), |
|
147 |
- "welFromBranch" : $("div[data-name='fromBranch']"), |
|
148 |
- "welToBranch" : $("div[data-name='toBranch']") |
|
130 |
+ "mergeResultURL": "@routes.PullRequestApp.mergeResult(project.owner, project.name)", |
|
131 |
+ "fromProject" : $("#fromProjectId"), |
|
132 |
+ "toProject" : $("#toProjectId"), |
|
133 |
+ "fromBranch" : $("#fromBranch"), |
|
134 |
+ "toBranch" : $("#toBranch") |
|
149 | 135 |
}); |
150 | 136 |
|
151 | 137 |
// yobi.Mention |
--- app/views/git/edit.scala.html
+++ app/views/git/edit.scala.html
... | ... | @@ -18,112 +18,127 @@ |
18 | 18 |
* See the License for the specific language governing permissions and |
19 | 19 |
* limitations under the License. |
20 | 20 |
**@ |
21 |
-@(title:String, form: Form[PullRequest], project: Project, fromBranches: List[playRepository.GitBranch], toBranches: List[playRepository.GitBranch], pull: PullRequest) |
|
21 |
+@(title:String, form:Form[PullRequest], project:Project, |
|
22 |
+ fromBranches: List[playRepository.GitBranch], toBranches:List[playRepository.GitBranch], |
|
23 |
+ pullRequest:models.PullRequest) |
|
22 | 24 |
|
23 | 25 |
@import scala.collection.Map |
24 | 26 |
@import utils.TemplateHelper._ |
25 | 27 |
@import utils.TemplateHelper.Branches._ |
26 | 28 |
@implicitField = @{ helper.FieldConstructor(simpleForm) } |
27 | 29 |
|
28 |
-@projectLayout(title, pull.toProject, utils.MenuType.PULL_REQUEST) { |
|
29 |
-@projectMenu(pull.toProject, utils.MenuType.PULL_REQUEST, "main-menu-only") |
|
30 |
+@projectLayout(title, pullRequest.toProject, utils.MenuType.PULL_REQUEST) { |
|
31 |
+@projectMenu(pullRequest.toProject, utils.MenuType.PULL_REQUEST, "main-menu-only") |
|
30 | 32 |
<div class="page-wrap-outer"> |
31 | 33 |
<div class="project-page-wrap"> |
32 | 34 |
<div class="content-wrap frm-wrap"> |
33 |
- @helper.form(action=routes.PullRequestApp.editPullRequest(pull.toProject.owner, pull.toProject.name, pull.number), 'enctype -> "multipart/form-data", 'class->"nm"){ |
|
35 |
+ @helper.form(action=routes.PullRequestApp.editPullRequest(pullRequest.toProject.owner, pullRequest.toProject.name, pullRequest.number), 'enctype -> "multipart/form-data", 'class->"nm"){ |
|
34 | 36 |
<div class="pull-request-wrap"> |
35 |
- <div class="option request-from"> |
|
36 |
- <div class="option-label">@Messages("pullRequest.from"): |
|
37 |
- <div class="btn-group branches" data-name="fromProjectId"> |
|
38 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
39 |
- <span class="d-label">@Messages("pullRequest.select.branch")</span> |
|
40 |
- <span class="d-caret"><span class="caret"></span></span> |
|
41 |
- </button> |
|
42 |
- <ul class="dropdown-menu"> |
|
43 |
- <li data-value="@pull.fromProject.id" data-selected="true"> |
|
44 |
- <a href="#"><span class="label">repo</span>@pull.fromProject.owner/@pull.fromProject.name</a> |
|
45 |
- </li> |
|
46 |
- </ul> |
|
47 |
- </div> |
|
48 |
- </div> |
|
49 |
- <div class="option-desc mt5"> |
|
50 |
- <div class="btn-group branches" data-name="fromBranch"> |
|
51 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
52 |
- <span class="d-label">@Messages("pullRequest.select.branch")</span> |
|
53 |
- <span class="d-caret"><span class="caret"></span></span> |
|
54 |
- </button> |
|
55 |
- <ul class="dropdown-menu"> |
|
56 |
- @defining(form("fromBranch").value()) { fromBranch => |
|
57 |
- @common.branchItem("pullRequest", null, fromBranch, null, true) |
|
58 |
- } |
|
59 |
- </ul> |
|
60 |
- </div> |
|
61 |
- </div> |
|
37 |
+ <!-- from --> |
|
38 |
+ <div class="pull-left"> |
|
39 |
+ <label for="fromProjectId" class="field-title">@Messages("pullRequest.from")</label> |
|
40 |
+ <select id="fromProjectId" name="fromProjectId" data-toggle="select2" class="mr5" disabled> |
|
41 |
+ <option value="@pullRequest.fromProject.id" selected> |
|
42 |
+ @pullRequest.fromProject.owner / @pullRequest.fromProject.name |
|
43 |
+ </option> |
|
44 |
+ </select> |
|
45 |
+ <select id="fromBranch" name="fromBranch" data-toggle="select2" data-format="branch" disabled |
|
46 |
+ data-dropdown-css-class="branches" data-placeholder="@Messages("pullRequest.select.branch")"> |
|
47 |
+ <option></option> |
|
48 |
+ @for(branch <- fromBranches) { |
|
49 |
+ <option value="@branch.getName" @if(branch.getName == pullRequest.fromBranch){ selected }>@branch.getName</option> |
|
50 |
+ } |
|
51 |
+ </select> |
|
52 |
+ |
|
53 |
+ <input type="hidden" name="fromProjectId" value="@pullRequest.fromProject.id"> |
|
54 |
+ <input type="hidden" name="fromBranch" value="@pullRequest.fromBranch"> |
|
62 | 55 |
</div> |
56 |
+ <!-- // --> |
|
63 | 57 |
|
64 | 58 |
<div class="arrow"> |
65 | 59 |
<i class="yobicon-right-2"></i> |
66 | 60 |
</div> |
67 | 61 |
|
68 |
- <div class="option request-to"> |
|
69 |
- <div class="option-label">@Messages("pullRequest.to"): |
|
70 |
- <div class="btn-group branches" data-name="toProjectId"> |
|
71 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
72 |
- <span class="d-label">@Messages("pullRequest.select.branch")</span> |
|
73 |
- <span class="d-caret"><span class="caret"></span></span> |
|
74 |
- </button> |
|
75 |
- <ul class="dropdown-menu"> |
|
76 |
- <li data-value="@pull.toProject.id" data-selected="true"> |
|
77 |
- <a href="#"><span class="label">repo</span>@pull.toProject.owner/@pull.toProject.name</a> |
|
78 |
- </li> |
|
79 |
- </ul> |
|
80 |
- </div> |
|
81 |
- </div> |
|
82 |
- <div class="option-desc mt5"> |
|
83 |
- <div class="btn-group branches" data-name="toBranch"> |
|
84 |
- <button class="btn dropdown-toggle auto" data-toggle="dropdown"> |
|
85 |
- <span class="d-label">@Messages("pullRequest.select.branch")</span> |
|
86 |
- <span class="d-caret"><span class="caret"></span></span> |
|
87 |
- </button> |
|
88 |
- <ul class="dropdown-menu"> |
|
89 |
- @defining(form("toBranch").value()) { toBranch => |
|
90 |
- @common.branchItem("pullRequest", null, toBranch, null, true) |
|
91 |
- } |
|
92 |
- </ul> |
|
93 |
- </div> |
|
94 |
- </div> |
|
62 |
+ <!-- to --> |
|
63 |
+ <div class="pull-right"> |
|
64 |
+ <label for="toProjectId" class="field-title">@Messages("pullRequest.to")</label> |
|
65 |
+ <select id="toProjectId" name="toProjectId" data-toggle="select2" class="mr5" disabled> |
|
66 |
+ <option value="@pullRequest.toProject.id" selected> |
|
67 |
+ @pullRequest.toProject.owner / @pullRequest.toProject.name |
|
68 |
+ </option> |
|
69 |
+ </select> |
|
70 |
+ <select id="toBranch" name="toBranch" data-toggle="select2" data-format="branch" disabled |
|
71 |
+ data-dropdown-css-class="branches" data-placeholder="@Messages("pullRequest.select.branch")"> |
|
72 |
+ <option></option> |
|
73 |
+ @for(branch <- toBranches) { |
|
74 |
+ <option value="@branch.getName" @if(branch.getName == pullRequest.toBranch){ selected }>@branch.getName</option> |
|
75 |
+ } |
|
76 |
+ </select> |
|
77 |
+ |
|
78 |
+ <input type="hidden" name="toProjectId" value="@pullRequest.toProject.id"> |
|
79 |
+ <input type="hidden" name="toBranch" value="@pullRequest.toBranch"> |
|
80 |
+ </div> |
|
81 |
+ <!-- // --> |
|
82 |
+ </div> |
|
83 |
+ |
|
84 |
+ <div id="status" class="alert mt20 mb20"> |
|
85 |
+ @Messages("pullRequest.is.merging") |
|
86 |
+ </div> |
|
87 |
+ |
|
88 |
+ <div> |
|
89 |
+ <input type="text" id="title" name="title" maxlength="255" class="text" |
|
90 |
+ value="@pullRequest.title" placeholder="@Messages("title")" data-is-user-has-typed="true"> |
|
91 |
+ <div style="position: relative;"> |
|
92 |
+ @common.editor("body", pullRequest.body, "data-is-user-has-typed=true", "content-body") |
|
93 |
+ </div> |
|
94 |
+ @common.fileUploader(ResourceType.PULL_REQUEST, pullRequest.id) |
|
95 |
+ @common.markdown(project) |
|
96 |
+ |
|
97 |
+ <div class="actions"> |
|
98 |
+ <button type="submit" class="ybtn ybtn-success">@Messages("button.save")</button> |
|
99 |
+ <a href="javascript:history.back();" class="ybtn">@Messages("button.cancel")</a> |
|
95 | 100 |
</div> |
96 | 101 |
</div> |
97 | 102 |
|
98 |
- <input type="text" name="title" id="title" placeholder="" maxlength="maxlength" tabindex="1" class="text" value="@pull.title"> |
|
99 |
- <div style="position: relative;"> |
|
100 |
- @common.editor("body", pull.body, "tabindex=2", "content-body") |
|
101 |
- </div> |
|
103 |
+ <ul class="nav nav-tabs mt20"> |
|
104 |
+ <li class="active"> |
|
105 |
+ <a href="#__commits" data-toggle="tab"> |
|
106 |
+ <span class="vmiddle-inline">@Messages("pullRequest.menu.commit")</span> |
|
107 |
+ <span id="numOfCommits" class="num-badge vmiddle-inline"></span> |
|
108 |
+ </a> |
|
109 |
+ </li> |
|
110 |
+ </ul> |
|
102 | 111 |
|
103 |
- @common.fileUploader(ResourceType.PULL_REQUEST, pull.id) |
|
104 |
- |
|
105 |
- <div class="actions"> |
|
106 |
- <button type="submit" class="ybtn ybtn-info">@Messages("button.save")</button> |
|
107 |
- <a href="javascript:history.back();" class="ybtn">@Messages("button.cancel")</a> |
|
112 |
+ <div class="tab-content"> |
|
113 |
+ <div id="__commits" class="code-browse-wrap tab-pane active"> |
|
114 |
+ @** this area will be replaced with asynchronously by yobi.git.Write.js after load this page. **@ |
|
115 |
+ </div> |
|
108 | 116 |
</div> |
109 | 117 |
} |
110 | 118 |
</div> |
111 | 119 |
</div> |
112 | 120 |
</div> |
113 |
-@common.markdown(project) |
|
121 |
+ |
|
122 |
+@common.select2() |
|
114 | 123 |
|
115 | 124 |
<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("javascripts/lib/atjs/jquery.atwho.css")"> |
116 | 125 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/atjs/jquery.caret.min.js")"></script> |
117 | 126 |
<script type="text/javascript" src="@routes.Assets.at("javascripts/lib/atjs/jquery.atwho.js")"></script> |
118 | 127 |
<script type="text/javascript"> |
119 |
- $(document).ready(function(){ |
|
120 |
- $yobi.loadModule("git.Write"); |
|
128 |
+$(function(){ |
|
129 |
+ $yobi.loadModule("git.Write", { |
|
130 |
+ "sMergeResultURL": "@routes.PullRequestApp.mergeResult(project.owner, project.name)", |
|
131 |
+ "welFromProject" : $("#fromProjectId"), |
|
132 |
+ "welToProject" : $("#toProjectId"), |
|
133 |
+ "welFromBranch" : $("#fromBranch"), |
|
134 |
+ "welToBranch" : $("#toBranch") |
|
135 |
+ }); |
|
121 | 136 |
|
122 |
- // yobi.Mention |
|
123 |
- yobi.Mention({ |
|
124 |
- "target": "textarea[id^=editor-]", |
|
125 |
- "url" : "@routes.ProjectApp.mentionList(project.owner, project.name)" |
|
126 |
- }); |
|
127 |
- }); |
|
137 |
+ // yobi.Mention |
|
138 |
+ yobi.Mention({ |
|
139 |
+ "target": "textarea[id^=editor-]", |
|
140 |
+ "url" : "@routes.ProjectApp.mentionList(project.owner, project.name)" |
|
141 |
+ }); |
|
142 |
+}); |
|
128 | 143 |
</script> |
129 | 144 |
} |
--- app/views/git/partial_diff.scala.html
... | ... | @@ -1,138 +0,0 @@ |
1 | -@** | |
2 | -* Yobi, Project Hosting SW | |
3 | -* | |
4 | -* Copyright 2013 NAVER Corp. | |
5 | -* http://yobi.io | |
6 | -* | |
7 | -* @Author Wansoon Park | |
8 | -* | |
9 | -* Licensed under the Apache License, Version 2.0 (the "License"); | |
10 | -* you may not use this file except in compliance with the License. | |
11 | -* You may obtain a copy of the License at | |
12 | -* | |
13 | -* http://www.apache.org/licenses/LICENSE-2.0 | |
14 | -* | |
15 | -* Unless required by applicable law or agreed to in writing, software | |
16 | -* distributed under the License is distributed on an "AS IS" BASIS, | |
17 | -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
18 | -* See the License for the specific language governing permissions and | |
19 | -* limitations under the License. | |
20 | -**@ | |
21 | -@(form: Form[PullRequest], project: Project, pullRequest:models.PullRequest, result:models.PullRequestMergeResult) | |
22 | - | |
23 | -@import utils.JodaDateUtil | |
24 | -@import utils.TemplateHelper._ | |
25 | -@import utils.AccessControl._ | |
26 | -@import models.enumeration | |
27 | -@import playRepository.GitCommit | |
28 | -@import scala.collection.Map | |
29 | - | |
30 | -@implicitField = @{ helper.FieldConstructor(simpleForm) } | |
31 | - | |
32 | -@getCodeURL(project: Project) = @{ | |
33 | - if(session == null){ | |
34 | - CodeApp.getURL(project.owner, project.name) | |
35 | - } else { | |
36 | - defining(ProjectUser.roleOf(session.get("loginId"), project)) { role => | |
37 | - if(role == "manager" || role == "member"){ | |
38 | - CodeApp.getURL(project.owner, project.name).replace("://", "://" + session.get("loginId") + "@") | |
39 | - } else { | |
40 | - CodeApp.getURL(project.owner, project.name) | |
41 | - } | |
42 | - } | |
43 | - } | |
44 | -} | |
45 | - | |
46 | -<input type="text" name="title" id="title" placeholder="@Messages("title")" maxlength="255" tabindex="1" class="text" value="@pullRequest.title"> | |
47 | -<div style="position: relative;"> | |
48 | - @common.editor("body", pullRequest.body, "tabindex=2", "content-body") | |
49 | -</div> | |
50 | -@common.fileUploader(ResourceType.PULL_REQUEST, null) | |
51 | -@common.markdown(project) | |
52 | - | |
53 | -<div class="actions"> | |
54 | - <button type="submit" class="ybtn ybtn-success">@Messages("button.save")</button> | |
55 | - <a href="javascript:history.back();" class="ybtn">@Messages("button.cancel")</a> | |
56 | -</div> | |
57 | - | |
58 | -<div id="spin" style="position: absolute; top:50%; left:50%"></div> | |
59 | - | |
60 | -<div id="diff"> | |
61 | -@if(result != null) { | |
62 | - @if(result.getGitCommits().isEmpty) { | |
63 | - <h4>@Messages("pullRequest.diff.noChanges")</h4> | |
64 | - } else { | |
65 | - <div style="margin-top:20px;"> | |
66 | - @if(result.getGitConflicts == null){ | |
67 | - <div class="alert alert-success"> | |
68 | - <h5>@Messages("pullRequest.is.safe")</h5> | |
69 | - </div> | |
70 | - } else { | |
71 | - <div class="alert alert-error"> | |
72 | - <h5>@Messages("pullRequest.is.not.safe")</h5> | |
73 | - </div> | |
74 | - } | |
75 | - </div> | |
76 | - | |
77 | - <ul class="nav nav-tabs nm"> | |
78 | - <li class="active"><a href="#__commits" data-toggle="tab">@Messages("pullRequest.menu.commit")</a></li> | |
79 | - </ul> | |
80 | - <div class="tab-content"> | |
81 | - <div id="__commits" class="code-browse-wrap tab-pane active"> | |
82 | - <div id="history" class="commit-wrap mt20"> | |
83 | - <table class="code-table commits"> | |
84 | - <thead class="thead"> | |
85 | - <tr> | |
86 | - <td class="commit-id"><strong>@{"@"}</strong></td> | |
87 | - <td class="messages"><strong>@Messages("code.commitMsg")</strong></td> | |
88 | - <td class="date"><strong>@Messages("code.commitDate")</strong></td> | |
89 | - <td class="author"><strong>@Messages("code.author")</strong></td> | |
90 | - </tr> | |
91 | - </thead> | |
92 | - <tbody class="tbody"> | |
93 | - @for(commit <- result.getGitCommits) { | |
94 | - <tr> | |
95 | - <td class="commit-id"> | |
96 | - <a href="@routes.CodeHistoryApp.show(pullRequest.fromProject.owner, pullRequest.fromProject.name, commit.getId)"> | |
97 | - @commit.getShortId | |
98 | - </a> | |
99 | - </td> | |
100 | - <td class="messages"> | |
101 | - @defining(CommitComment.count(pullRequest.fromProject, commit.getId, null)){ numOfComment => | |
102 | - @if(numOfComment > 0) { | |
103 | - <span class="number-of-comments"><i class="yobicon-comments"></i> @numOfComment</span> | |
104 | - } | |
105 | - } | |
106 | - @defining(commit.getMessage){ commitMsg => | |
107 | - @common.commitMsg(commitMsg.split("\n")(0), | |
108 | - commitMsg, | |
109 | - routes.CodeHistoryApp.show(pullRequest.fromProject.owner, pullRequest.fromProject.name, commit.getId).toString()) | |
110 | - } | |
111 | - </td> | |
112 | - <td class="date" title="@JodaDateUtil.getDateString(commit.getAuthorDate)"> | |
113 | - @agoOrDateString(commit.getAuthorDate) | |
114 | - </td> | |
115 | - <td class="author @commit.getAuthorEmail"> | |
116 | - @defining(User.find.where.eq("email", commit.getAuthorEmail).findUnique) { user => | |
117 | - @if(user != null) { | |
118 | - <a href="@routes.UserApp.userInfo(user.loginId)" class="avatar-wrap"> | |
119 | - <img src="@user.avatarUrl" alt="@user.name" width="32" height="32"/> | |
120 | - </a> | |
121 | - } else { | |
122 | - <div class="avatar-wrap"> | |
123 | - <img src="@urlToPicture(commit.getAuthorEmail, 32)" width="32" height="32"/> | |
124 | - </div> | |
125 | - } | |
126 | - } | |
127 | - </td> | |
128 | - </tr> | |
129 | - } | |
130 | - </tbody> | |
131 | - </table> | |
132 | - </div> | |
133 | - </div> | |
134 | - </div> | |
135 | - } | |
136 | -} | |
137 | -</div> | |
138 | -<input type="hidden" id="commitChanged" value="@if(result != null){ @result.hasDiffCommits } else {false}" /> |
+++ app/views/git/partial_merge_result.scala.html
... | ... | @@ -0,0 +1,99 @@ |
1 | +@** | |
2 | +* Yobi, Project Hosting SW | |
3 | +* | |
4 | +* Copyright 2014 NAVER Corp. | |
5 | +* http://yobi.io | |
6 | +* | |
7 | +* @Author Jihan Kim | |
8 | +* | |
9 | +* Licensed under the Apache License, Version 2.0 (the "License"); | |
10 | +* you may not use this file except in compliance with the License. | |
11 | +* You may obtain a copy of the License at | |
12 | +* | |
13 | +* http://www.apache.org/licenses/LICENSE-2.0 | |
14 | +* | |
15 | +* Unless required by applicable law or agreed to in writing, software | |
16 | +* distributed under the License is distributed on an "AS IS" BASIS, | |
17 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
18 | +* See the License for the specific language governing permissions and | |
19 | +* limitations under the License. | |
20 | +**@ | |
21 | +@(project: Project, pullRequest:models.PullRequest, result:models.PullRequestMergeResult) | |
22 | + | |
23 | +@import utils.JodaDateUtil | |
24 | +@import utils.TemplateHelper._ | |
25 | +@import utils.AccessControl._ | |
26 | +@import models.enumeration | |
27 | +@import playRepository.GitCommit | |
28 | +@import scala.collection.Map | |
29 | + | |
30 | +@if(result != null) { | |
31 | + @defining(result.getGitCommits){ commits => | |
32 | + <div id="mergeResult" class="code-browser-wrap" | |
33 | + data-commits="@commits.size" | |
34 | + data-pullrequest-title="@pullRequest.title" | |
35 | + data-pullrequest-body="@pullRequest.body" | |
36 | + @if(!commits.isEmpty){ | |
37 | + data-conflict="@result.conflicts" | |
38 | + } | |
39 | + > | |
40 | + @if(commits.isEmpty) { | |
41 | + <div> | |
42 | + <h5>@Messages("pullRequest.diff.noChanges")</h5> | |
43 | + </div> | |
44 | + } else { | |
45 | + <div class="commit-wrap"> | |
46 | + <table class="code-table commits"> | |
47 | + <thead class="thead"> | |
48 | + <tr> | |
49 | + <td class="commit-id"><strong>@{"@"}</strong></td> | |
50 | + <td class="messages"><strong>@Messages("code.commitMsg")</strong></td> | |
51 | + <td class="date"><strong>@Messages("code.commitDate")</strong></td> | |
52 | + <td class="author"><strong>@Messages("code.author")</strong></td> | |
53 | + </tr> | |
54 | + </thead> | |
55 | + <tbody class="tbody"> | |
56 | + @for(commit <- commits){ | |
57 | + <tr> | |
58 | + <td class="commit-id"> | |
59 | + <a href="@routes.CodeHistoryApp.show(pullRequest.fromProject.owner, pullRequest.fromProject.name, commit.getId)"> | |
60 | + @commit.getShortId | |
61 | + </a> | |
62 | + </td> | |
63 | + <td class="messages"> | |
64 | + @defining(CommitComment.count(pullRequest.fromProject, commit.getId, null)){ numOfComment => | |
65 | + @if(numOfComment > 0) { | |
66 | + <span class="number-of-comments"><i class="yobicon-comments"></i> @numOfComment</span> | |
67 | + } | |
68 | + } | |
69 | + @defining(commit.getMessage){ commitMsg => | |
70 | + @common.commitMsg(commitMsg.split("\n")(0), | |
71 | + commitMsg, | |
72 | + routes.CodeHistoryApp.show(pullRequest.fromProject.owner, pullRequest.fromProject.name, commit.getId).toString()) | |
73 | + } | |
74 | + </td> | |
75 | + <td class="date" title="@JodaDateUtil.getDateString(commit.getAuthorDate)"> | |
76 | + @agoOrDateString(commit.getAuthorDate) | |
77 | + </td> | |
78 | + <td class="author @commit.getAuthorEmail"> | |
79 | + @defining(User.find.where.eq("email", commit.getAuthorEmail).findUnique) { user => | |
80 | + @if(user != null) { | |
81 | + <a href="@routes.UserApp.userInfo(user.loginId)" class="avatar-wrap"> | |
82 | + <img src="@user.avatarUrl" alt="@user.name" width="32" height="32"/> | |
83 | + </a> | |
84 | + } else { | |
85 | + <div class="avatar-wrap"> | |
86 | + <img src="@urlToPicture(commit.getAuthorEmail, 32)" width="32" height="32"/> | |
87 | + </div> | |
88 | + } | |
89 | + } | |
90 | + </td> | |
91 | + </tr> | |
92 | + } | |
93 | + </tbody> | |
94 | + </table> | |
95 | + </div> | |
96 | + } | |
97 | + </div> | |
98 | + } | |
99 | +} |
--- conf/messages
+++ conf/messages
... | ... | @@ -580,6 +580,7 @@ |
580 | 580 |
pullRequest.help.message.1 = This is a simple way to contribute your code to original project. |
581 | 581 |
pullRequest.help.message.2 = Please select your branch containing your code to be sent and that of original project to receive your code, and describe your code briefly. |
582 | 582 |
pullRequest.help.message.3 = Member of the original project can accept or postpone your code. |
583 |
+pullRequest.ignore.conflict = This code seems to have conflicts when merging. Do you really want to continue? |
|
583 | 584 |
pullRequest.is.checking = Checking |
584 | 585 |
pullRequest.is.empty = No pull requests have been received |
585 | 586 |
pullRequest.is.merging = We are checking if the code is safe. Please wait for a while to complete this process. |
... | ... | @@ -626,6 +627,7 @@ |
626 | 627 |
pullRequest.review.participants = <strong>{0}</strong> participants |
627 | 628 |
pullRequest.review.total = Total review |
628 | 629 |
pullRequest.select.branch = Select branch |
630 |
+pullRequest.send = Send pull request |
|
629 | 631 |
pullRequest.sender = Sender |
630 | 632 |
pullRequest.sent = Sent code |
631 | 633 |
pullRequest.sentByMe = Sent by me |
--- conf/messages.ja
+++ conf/messages.ja
... | ... | @@ -437,6 +437,7 @@ |
437 | 437 |
pullRequest.help.message.1 = 原本プロジェクトにコードを寄与する方法です |
438 | 438 |
pullRequest.help.message.2 = 送ろうとするコードが入っているブランチとそれを受けてくれる原本プロジェクトのブランチを指定しどんなコードか説明してください |
439 | 439 |
pullRequest.help.message.3 = 原本プロジェクトのメンバーがプルリクエストを確認し、受諾するか保留するかを決めます |
440 |
+pullRequest.ignore.conflict = このコードはコンフリクトが発生するように見えます。それでもコードを送りますか? |
|
440 | 441 |
pullRequest.is.empty = プルリクエストがありません |
441 | 442 |
pullRequest.is.merging = Checking whether code is safety. Please wait for a while to complete. |
442 | 443 |
pullRequest.is.not.safe = コードは自動的にマージすると衝突が発生します。自動でマージできません。 |
... | ... | @@ -469,6 +470,7 @@ |
469 | 470 |
pullRequest.resolver.step9 = rebaseが終わったらoriginにコードを強制的にpushします |
470 | 471 |
pullRequest.restore.branch = ブランチ復旧 |
471 | 472 |
pullRequest.restore.frombranch.message = ブランチを復旧できます |
473 |
+pullRequest.send = プルリクエストを送る |
|
472 | 474 |
pullRequest.sender = 送り主 |
473 | 475 |
pullRequest.sent = 送ったリクエスト |
474 | 476 |
pullRequest.sentByMe = 私が送ったリクエスト |
--- conf/messages.ko
+++ conf/messages.ko
... | ... | @@ -580,6 +580,7 @@ |
580 | 580 |
pullRequest.help.message.1 = 원본 프로젝트에 코드를 기여하는 방법입니다. |
581 | 581 |
pullRequest.help.message.2 = 본인이 보낼 코드가 들어있는 브랜치와 보낸 코드를 받아줄 원본 프로젝트의 브랜치를 지정하고 어떤 코드인지 설명해 주세요. |
582 | 582 |
pullRequest.help.message.3 = 원본 프로젝트의 멤버가 해당 코드를 확인하고 코드를 받거나 보류할 수 있습니다. |
583 |
+pullRequest.ignore.conflict = 충돌이 발생하여 코드를 자동으로 병합할 수 없습니다. 그래도 코드를 보내시겠습니까? |
|
583 | 584 |
pullRequest.is.checking = 확인중 |
584 | 585 |
pullRequest.is.empty = 등록된 코드 주고 받기가 없습니다. |
585 | 586 |
pullRequest.is.merging = 코드가 안전한지 확인하고 있습니다. 완료될때까지 잠시만 기다려주십시오. |
... | ... | @@ -626,6 +627,7 @@ |
626 | 627 |
pullRequest.review.participants = 참여자 <strong>{0}</strong>명 |
627 | 628 |
pullRequest.review.total = 전체 리뷰 |
628 | 629 |
pullRequest.select.branch = 브랜치를 선택하세요. |
630 |
+pullRequest.send = 코드 보내기 |
|
629 | 631 |
pullRequest.sender = 보낸 사람 |
630 | 632 |
pullRequest.sent = 보낸 코드 |
631 | 633 |
pullRequest.sentByMe = 내가 보낸 코드 |
--- conf/routes
+++ conf/routes
... | ... | @@ -187,6 +187,7 @@ |
187 | 187 |
GET /:ownerName/:project/pullRequest/:id/changes/:commitId controllers.PullRequestApp.specificChange(ownerName, project, id: Long, commitId: String) |
188 | 188 |
GET /:ownerName/:project/pullRequest/:id/state controllers.PullRequestApp.pullRequestState(ownerName, project, id: Long) |
189 | 189 |
GET /:ownerName/:project/newPullRequestForm controllers.PullRequestApp.newPullRequestForm(ownerName:String, project:String) |
190 |
+GET /:ownerName/:project/newPullRequest/mergeResult controllers.PullRequestApp.mergeResult(ownerName, project) |
|
190 | 191 |
POST /:ownerName/:project/pullRequests controllers.PullRequestApp.newPullRequest(ownerName, project) |
191 | 192 |
POST /:ownerName/:project/pullRequest/:id/accept controllers.PullRequestApp.accept(ownerName, project, id: Long) |
192 | 193 |
POST /:ownerName/:project/pullRequest/:id/close controllers.PullRequestApp.close(ownerName, project, id: Long) |
--- public/javascripts/service/yobi.git.Write.js
+++ public/javascripts/service/yobi.git.Write.js
... | ... | @@ -20,243 +20,252 @@ |
20 | 20 |
*/ |
21 | 21 |
(function(ns){ |
22 | 22 |
var oNS = $yobi.createNamespace(ns); |
23 |
- oNS.container[oNS.name] = function(htOptions){ |
|
23 |
+ oNS.container[oNS.name] = function(options){ |
|
24 | 24 |
|
25 |
- var htVar = {}; |
|
26 |
- var htElement = {}; |
|
25 |
+ var vars = {}; |
|
26 |
+ var elements = {}; |
|
27 | 27 |
|
28 | 28 |
/** |
29 | 29 |
* initialize |
30 | 30 |
*/ |
31 |
- function _init(htOptions){ |
|
32 |
- _initVar(htOptions || {}); |
|
33 |
- _initElement(htOptions || {}); |
|
31 |
+ function _init(options){ |
|
32 |
+ _initVar(options); |
|
33 |
+ _initElement(options); |
|
34 | 34 |
_attachEvent(); |
35 | 35 |
|
36 | 36 |
_initFileUploader(); |
37 |
+ _onChangeBranch(); |
|
37 | 38 |
} |
38 | 39 |
|
39 | 40 |
/** |
40 | 41 |
* initialize variables |
41 | 42 |
*/ |
42 |
- function _initVar() { |
|
43 |
- htVar.sFormURL = htOptions.sFormURL; |
|
44 |
- htVar.oFromProject = new yobi.ui.Dropdown({"elContainer": htOptions.welFromProject}); |
|
45 |
- htVar.oToProject = new yobi.ui.Dropdown({"elContainer": htOptions.welToProject}); |
|
46 |
- htVar.oFromBranch = new yobi.ui.Dropdown({"elContainer": htOptions.welFromBranch}); |
|
47 |
- htVar.oToBranch = new yobi.ui.Dropdown({"elContainer": htOptions.welToBranch}); |
|
48 |
- htVar.sUploaderId = null; |
|
49 |
- htVar.oSpinner = null; |
|
50 |
- |
|
51 |
- htVar.htUserInput = {}; |
|
52 |
- htVar.sTplFileItem = $('#tplAttachedFile').text(); |
|
43 |
+ function _initVar(options) { |
|
44 |
+ vars.mergeResult = {}; |
|
45 |
+ vars.mergeResultURL = options.mergeResultURL; |
|
46 |
+ vars.tplFileItem = $('#tplAttachedFile').text(); |
|
47 |
+ vars.uploaderId = null; |
|
53 | 48 |
} |
54 | 49 |
|
55 | 50 |
/** |
56 | 51 |
* initialize element variables |
57 | 52 |
*/ |
58 |
- function _initElement(htOptions){ |
|
59 |
- htElement.welForm = $("form.nm"); |
|
60 |
- htElement.welInputTitle = $('#title'); |
|
61 |
- htElement.welInputBody = $('textarea[data-editor-mode="content-body"]'); |
|
53 |
+ function _initElement(options){ |
|
54 |
+ elements.form = $("form.nm"); |
|
55 |
+ elements.title = $('#title'); |
|
56 |
+ elements.body = $('textarea[data-editor-mode="content-body"]'); |
|
62 | 57 |
|
63 |
- htElement.welInputFromProject = $('input[name="fromProjectId"]'); |
|
64 |
- htElement.welInputToProject = $('input[name="toProjectId"]'); |
|
65 |
- htElement.welInputFromBranch = $('input[name="fromBranch"]'); |
|
66 |
- htElement.welInputToBranch = $('input[name="toBranch"]'); |
|
58 |
+ elements.fromProject = options.fromProject; |
|
59 |
+ elements.fromBranch = options.fromBranch; |
|
60 |
+ elements.toProject = options.toProject; |
|
61 |
+ elements.toBranch = options.toBranch; |
|
67 | 62 |
|
68 |
- htElement.welUploader = $("#upload"); |
|
69 |
- htElement.welContainer = $("#frmWrap"); |
|
70 |
- |
|
71 |
- htElement.welAbleToMerge = $("#ableToMerge"); |
|
72 |
- htElement.welCommitCount = $("#commitCount"); |
|
63 |
+ elements.uploader = $("#upload"); |
|
64 |
+ elements.numOfCommits = $("#numOfCommits"); |
|
65 |
+ elements.commits = $("#__commits"); |
|
66 |
+ elements.status = $("#status"); |
|
73 | 67 |
} |
74 | 68 |
|
75 | 69 |
/** |
76 | 70 |
* attach event handlers |
77 | 71 |
*/ |
78 | 72 |
function _attachEvent(){ |
79 |
- htElement.welForm.submit(_onSubmitForm); |
|
80 |
- htElement.welInputTitle.on("keyup", _onKeyupInput); |
|
81 |
- htElement.welInputBody.on("keyup", _onKeyupInput); |
|
73 |
+ elements.form.on("submit", _onSubmitForm); |
|
74 |
+ elements.title.on("keyup", _onKeyUpInput); |
|
75 |
+ elements.body.on("keyup", _onKeyUpInput); |
|
82 | 76 |
|
83 |
- htVar.oFromProject.onChange(_refreshNewPullRequestForm); |
|
84 |
- htVar.oToProject.onChange(_refreshNewPullRequestForm); |
|
85 |
- htVar.oFromBranch.onChange(_reloadNewPullRequestForm); |
|
86 |
- htVar.oToBranch.onChange(_reloadNewPullRequestForm); |
|
77 |
+ // onChangeProject |
|
78 |
+ elements.fromProject.on("change", _onChangeProject); |
|
79 |
+ elements.toProject.on("change", _onChangeProject); |
|
80 |
+ |
|
81 |
+ // onChangeBranch |
|
82 |
+ elements.fromBranch.on("change", _onChangeBranch); |
|
83 |
+ elements.toBranch.on("change", _onChangeBranch); |
|
87 | 84 |
|
88 | 85 |
$(document.body).on("click", "button.moreBtn", function(){ |
89 | 86 |
$(this).next("pre.commitMsg.desc").toggleClass("hidden"); |
90 | 87 |
}); |
91 |
- |
|
92 |
- $('body').on('click','button.more',function(){ |
|
93 |
- $(this).next('pre').toggleClass("hidden"); |
|
94 |
- }); |
|
95 |
- |
|
96 |
- _reloadNewPullRequestForm(); |
|
97 | 88 |
} |
98 | 89 |
|
99 | 90 |
/** |
100 |
- * @param {Wrapped Event} weEvt |
|
91 |
+ * "keyup" event handler of inputTitle, inputBody. |
|
92 |
+ * Mark as user has typed on this input, and detach this event handler. |
|
93 |
+ * Ignore if the pressed key is ENTER. |
|
94 |
+ * |
|
95 |
+ * @param {Wrapped Event} evt |
|
101 | 96 |
*/ |
102 |
- function _onKeyupInput(weEvt){ |
|
103 |
- var welTarget = $(weEvt.target); |
|
104 |
- var sInputId = welTarget.attr("id"); |
|
105 |
- htVar.htUserInput = htVar.htUserInput || {}; |
|
106 |
- htVar.htUserInput[sInputId] = true; |
|
97 |
+ function _onKeyUpInput(evt){ |
|
98 |
+ var keyCode = (evt.keyCode || evt.which); |
|
99 |
+ |
|
100 |
+ if(keyCode !== 13){ |
|
101 |
+ $(evt.target).data("isUserHasTyped", true) |
|
102 |
+ .off("keyup", _onKeyUpInput); |
|
103 |
+ } |
|
107 | 104 |
} |
108 | 105 |
|
109 | 106 |
/** |
107 |
+ * Reload page with changed fromProjectId, toProjectId query string. |
|
108 |
+ * |
|
110 | 109 |
* @private |
111 | 110 |
*/ |
112 |
- function _refreshNewPullRequestForm(){ |
|
113 |
- var htData = {}; |
|
111 |
+ function _onChangeProject(){ |
|
112 |
+ var data = _getFormValue(); |
|
114 | 113 |
|
115 |
- htData.fromProjectId = htVar.oFromProject.getValue(); |
|
116 |
- htData.toProjectId = htVar.oToProject.getValue(); |
|
117 |
- |
|
118 |
- document.location.href = htVar.sFormURL + "?fromProjectId=" + htData.fromProjectId + "&toProjectId=" + htData.toProjectId; |
|
114 |
+ location.search = "?fromProjectId=" + data.fromProject + "&toProjectId=" + data.toProject; |
|
119 | 115 |
} |
120 | 116 |
|
121 | 117 |
/** |
122 |
- * request to reload pullRequestForm |
|
118 |
+ * Request merge result with changed branch. |
|
119 |
+ * |
|
120 |
+ * @private |
|
123 | 121 |
*/ |
124 |
- function _reloadNewPullRequestForm(){ |
|
125 |
- var htData = {}; |
|
126 |
- htData.fromBranch = htVar.oFromBranch.getValue(); |
|
127 |
- htData.toBranch = htVar.oToBranch.getValue(); |
|
128 |
- htData.fromProjectId = htVar.oFromProject.getValue(); |
|
129 |
- htData.toProjectId = htVar.oToProject.getValue(); |
|
122 |
+ function _onChangeBranch(){ |
|
123 |
+ var data = _getFormValue(); |
|
130 | 124 |
|
131 |
- if(!(htData.fromBranch && htData.toBranch)) { |
|
125 |
+ if(!data.fromBranch && !data.toBranch){ |
|
132 | 126 |
return; |
133 | 127 |
} |
134 | 128 |
|
135 |
- _startSpinner(); |
|
129 |
+ _showMergeResult({"message" : Messages("pullRequest.is.merging")}); |
|
136 | 130 |
|
137 |
- $.ajax(htVar.sFormURL, { |
|
138 |
- "method" : "get", |
|
139 |
- "data" : htData, |
|
140 |
- "success": _onSuccessReloadForm, |
|
141 |
- "error" : _onErrorReloadForm |
|
131 |
+ yobi.ui.Spinner.show(); |
|
132 |
+ |
|
133 |
+ $.ajax(vars.mergeResultURL, { |
|
134 |
+ "data": data |
|
135 |
+ }) |
|
136 |
+ .done(_onSuccessMergeResult) |
|
137 |
+ .fail(_onErrorMergeResult) |
|
138 |
+ .always(function(){ |
|
139 |
+ yobi.ui.Spinner.hide(); |
|
142 | 140 |
}); |
143 | 141 |
} |
144 | 142 |
|
145 | 143 |
/** |
146 |
- * onSuccess to reloadForm |
|
144 |
+ * On success to load mergeResult |
|
145 |
+ * Fill element.commits and form field title/body. |
|
146 |
+ * and show result with parsing responded HTML. |
|
147 |
+ * |
|
148 |
+ * @param resultHTML |
|
149 |
+ * @private |
|
147 | 150 |
*/ |
148 |
- function _onSuccessReloadForm(sRes){ |
|
149 |
- var sTitle = htElement.welInputTitle.val(); |
|
150 |
- var sBody = htElement.welInputBody.val(); |
|
151 |
- |
|
152 |
- htElement.welContainer.html(sRes); |
|
153 |
- _reloadElement(); |
|
154 |
- |
|
155 |
- // 만약 사용자가 입력한 제목이나 본문이 있으면 내용을 유지한다 |
|
156 |
- if(sTitle.length > 0 && htVar.htUserInput.title){ |
|
157 |
- htElement.welInputTitle.val(sTitle); |
|
158 |
- } |
|
159 |
- if(sBody.length > 0 && htVar.htUserInput.body){ |
|
160 |
- htElement.welInputBody.val(sBody); |
|
161 |
- } |
|
162 |
- |
|
163 |
- _initFileUploader(); |
|
164 |
- _stopSpinner(); |
|
165 |
- _updateSummary(); |
|
166 |
- } |
|
167 |
- |
|
168 |
- function _updateSummary() { |
|
169 |
- var success = $(".alert-success"); |
|
170 |
- var error = $(".alert-error"); |
|
171 |
- if(success.length > 0) { |
|
172 |
- htElement.welAbleToMerge.text(Messages("pullRequest.is.safe.to.merge")); |
|
173 |
- } else if(error.length > 0){ |
|
174 |
- htElement.welAbleToMerge.text(Messages("pullRequest.is.not.safe.to.merge")); |
|
175 |
- } else { |
|
176 |
- htElement.welAbleToMerge.text(Messages("pullRequest.diff.noChanges")); |
|
177 |
- } |
|
178 |
- |
|
179 |
- var commits = $(".commits tr"); |
|
180 |
- if(commits.length > 0) { |
|
181 |
- htElement.welCommitCount.text(commits.length - 1); |
|
182 |
- } else { |
|
183 |
- htElement.welCommitCount.text(Messages("pullRequest.commit.is.empty")); |
|
184 |
- } |
|
185 |
- |
|
186 |
- } |
|
187 |
- |
|
188 |
- function _reloadElement(){ |
|
189 |
- htElement.welInputTitle = $('#title'); |
|
190 |
- htElement.welInputBody = $('textarea[data-editor-mode="content-body"]'); |
|
191 |
- htElement.welUploader = $("#upload"); |
|
192 |
- |
|
193 |
- htElement.welInputTitle.on("keyup", _onKeyupInput); |
|
194 |
- htElement.welInputBody.on("keyup", _onKeyupInput); |
|
151 |
+ function _onSuccessMergeResult(resultHTML){ |
|
152 |
+ elements.commits.html(resultHTML); |
|
153 |
+ vars.mergeResult = _getMergeResultData(); |
|
154 |
+ _showMergeResult(vars.mergeResult); |
|
155 |
+ _fillFormTitleBody(vars.mergeResult); |
|
195 | 156 |
} |
196 | 157 |
|
197 | 158 |
/** |
198 |
- * onFailed to reloadForm |
|
159 |
+ * Returns merge result data to show. |
|
160 |
+ * {@code container} relative data relies on views/git/partial_merge_result.scala.html |
|
161 |
+ * |
|
162 |
+ * @returns {{cssClass: string, message: *, isConflict: boolean, numOfCommits: Number, title: *, body: *}} |
|
163 |
+ * @private |
|
199 | 164 |
*/ |
200 |
- function _onErrorReloadForm(oRes){ |
|
201 |
- _stopSpinner(); |
|
202 |
- $yobi.alert(Messages("pullRequest.error.newPullRequestForm", oRes.status, oRes.statusText)); |
|
203 |
- } |
|
165 |
+ function _getMergeResultData(){ |
|
166 |
+ var container = $("#mergeResult"); |
|
167 |
+ var data = { |
|
168 |
+ "cssClass" : "alert-info", |
|
169 |
+ "message" : Messages("pullRequest.diff.noChanges"), |
|
170 |
+ "isConflict" : (container.data("conflict") === "true"), |
|
171 |
+ "numOfCommits": parseInt(container.data("commits"), 10), |
|
172 |
+ "title" : container.data("pullrequestTitle"), |
|
173 |
+ "body" : container.data("pullrequestBody") |
|
174 |
+ }; |
|
204 | 175 |
|
205 |
- function _startSpinner(){ |
|
206 |
- htVar.oSpinner = htVar.oSpinner || new Spinner(); |
|
207 |
- htVar.oSpinner.spin(document.getElementById('spin')); |
|
208 |
- } |
|
209 |
- |
|
210 |
- function _stopSpinner(){ |
|
211 |
- if(htVar.oSpinner){ |
|
212 |
- htVar.oSpinner.stop(); |
|
176 |
+ if(data.numOfCommits > 0){ |
|
177 |
+ data.message = data.isConflict ? Messages("pullRequest.is.not.safe") : Messages("pullRequest.is.safe"); |
|
178 |
+ data.cssClass = data.isConflict ? "alert-error" : "alert-success"; |
|
213 | 179 |
} |
214 |
- htVar.oSpinner = null; |
|
180 |
+ |
|
181 |
+ return data; |
|
182 |
+ } |
|
183 |
+ |
|
184 |
+ function _showMergeResult(mergeResult){ |
|
185 |
+ elements.status.removeClass("alert-success alert-error alert-info") |
|
186 |
+ .addClass(mergeResult.cssClass) |
|
187 |
+ .html(mergeResult.message); |
|
188 |
+ |
|
189 |
+ elements.numOfCommits.html(mergeResult.numOfCommits || ""); |
|
215 | 190 |
} |
216 | 191 |
|
217 | 192 |
/** |
218 |
- * Event handler on submit form |
|
193 |
+ * Fill form input title and body with merge result data |
|
194 |
+ * if user doesn't have typed. |
|
195 |
+ * |
|
196 |
+ * @param data |
|
197 |
+ * @private |
|
219 | 198 |
*/ |
220 |
- function _onSubmitForm(weEvt){ |
|
199 |
+ function _fillFormTitleBody(data){ |
|
200 |
+ var isUserHasTyped = elements.title.data("isUserHasTyped") || |
|
201 |
+ elements.body.data("isUserHasTyped"); |
|
202 |
+ |
|
203 |
+ if(!isUserHasTyped){ |
|
204 |
+ elements.title.val(data.title); |
|
205 |
+ elements.body.val(data.body); |
|
206 |
+ } |
|
207 |
+ } |
|
208 |
+ |
|
209 |
+ /** |
|
210 |
+ * On error occurs to get merge result. |
|
211 |
+ * Show error message and response status. |
|
212 |
+ * |
|
213 |
+ * @param res |
|
214 |
+ * @private |
|
215 |
+ */ |
|
216 |
+ function _onErrorMergeResult(res){ |
|
217 |
+ _showMergeResult({ |
|
218 |
+ "message" : Messages("pullRequest.error.newPullRequestForm", res.status, res.statusText), |
|
219 |
+ "cssClass": "alert-error" |
|
220 |
+ }); |
|
221 |
+ _fillFormTitleBody({"title":"", "body":""}); |
|
222 |
+ } |
|
223 |
+ |
|
224 |
+ /** |
|
225 |
+ * "submit" event handler of the form. |
|
226 |
+ * Returns false if validate fails. |
|
227 |
+ * |
|
228 |
+ * @returns {Boolean} |
|
229 |
+ * @private |
|
230 |
+ */ |
|
231 |
+ function _onSubmitForm(){ |
|
221 | 232 |
return _validateForm(); |
222 | 233 |
} |
223 | 234 |
|
224 | 235 |
/** |
225 | 236 |
* Validate form before submit |
237 |
+ * |
|
238 |
+ * @returns {boolean} |
|
239 |
+ * @private |
|
226 | 240 |
*/ |
227 | 241 |
function _validateForm(){ |
228 |
- // these two fields should be loaded dynamically. |
|
229 |
- htElement.welInputFromBranch = $('input[name="fromBranch"]'); |
|
230 |
- htElement.welInputToBranch = $('input[name="toBranch"]'); |
|
231 |
- htElement.welInputFromProject = $('input[name="fromProjectId"]'); |
|
232 |
- htElement.welInputToProject = $('input[name="toProjectId"]'); |
|
242 |
+ // Check whether is commit exists to send |
|
243 |
+ if(!vars.mergeResult.numOfCommits){ |
|
244 |
+ $yobi.alert(Messages("pullRequest.diff.noChanges")); |
|
245 |
+ return false; |
|
246 |
+ } |
|
233 | 247 |
|
234 |
- // check whether required field is empty |
|
235 |
- var htRequired = { |
|
236 |
- "title" : $.trim(htElement.welInputTitle.val()), |
|
237 |
- "fromProject": $.trim(htElement.welInputFromProject.val()), |
|
238 |
- "toProject" : $.trim(htElement.welInputToProject.val()), |
|
239 |
- "fromBranch": $.trim(htElement.welInputFromBranch.val()), |
|
240 |
- "toBranch" : $.trim(htElement.welInputToBranch.val()) |
|
241 |
- }; |
|
248 |
+ // Show confirm dialog in case of conflict |
|
249 |
+ if(vars.mergeResult.isConflict && !vars.mergeResult.forceSubmit){ |
|
250 |
+ $yobi.confirm(Messages("pullRequest.ignore.conflict"), function(data){ |
|
251 |
+ if(data.nButtonIndex === 1){ |
|
252 |
+ vars.mergeResult.forceSubmit = true; |
|
253 |
+ elements.form.submit(); |
|
254 |
+ } |
|
255 |
+ }); |
|
256 |
+ return false; |
|
257 |
+ } |
|
242 | 258 |
|
243 |
- for(var sMessageKey in htRequired){ |
|
244 |
- if(htRequired[sMessageKey].length === 0){ |
|
245 |
- $yobi.alert(Messages("pullRequest." + sMessageKey + ".required")); |
|
259 |
+ // Check whether required field is empty |
|
260 |
+ var requiredField = _getFormValue(); |
|
261 |
+ |
|
262 |
+ for(var fieldName in requiredField){ |
|
263 |
+ if(requiredField[fieldName].length === 0){ |
|
264 |
+ $yobi.alert(Messages("pullRequest." + fieldName + ".required")); |
|
246 | 265 |
return false; |
247 | 266 |
} |
248 | 267 |
} |
249 | 268 |
|
250 |
- if(!htVar.sFormURL) { |
|
251 |
- return true; |
|
252 |
- } |
|
253 |
- |
|
254 |
- var bCommitNotChanged = $.trim($("#commitChanged").val()) != "true"; |
|
255 |
- |
|
256 |
- if(bCommitNotChanged) { |
|
257 |
- $yobi.alert(Messages("pullRequest.diff.noChanges")); |
|
258 |
- return false; |
|
259 |
- } |
|
260 | 269 |
return true; |
261 | 270 |
} |
262 | 271 |
|
... | ... | @@ -264,24 +273,35 @@ |
264 | 273 |
* initialize fileUploader |
265 | 274 |
*/ |
266 | 275 |
function _initFileUploader(){ |
267 |
- if(htVar.sUploaderId){ |
|
268 |
- htVar.oAttachments.destroy(); |
|
269 |
- yobi.Files.destroyUploader(htVar.sUploaderId); |
|
270 |
- htVar.sUploaderId = null; |
|
276 |
+ if(vars.uploaderId){ |
|
277 |
+ vars.attachments.destroy(); |
|
278 |
+ yobi.Files.destroyUploader(vars.uploaderId); |
|
279 |
+ vars.uploaderId = null; |
|
271 | 280 |
} |
272 | 281 |
|
273 |
- var oUploader = yobi.Files.getUploader(htElement.welUploader, htElement.welInputBody); |
|
282 |
+ var oUploader = yobi.Files.getUploader(elements.uploader, elements.body); |
|
283 |
+ |
|
274 | 284 |
if(oUploader){ |
275 |
- htVar.sUploaderId = oUploader.attr("data-namespace"); |
|
276 |
- htVar.oAttachments = new yobi.Attachments({ |
|
277 |
- "elContainer" : htElement.welUploader, |
|
278 |
- "elTextarea" : htElement.welInputBody, |
|
279 |
- "sTplFileItem" : htVar.sTplFileItem, |
|
280 |
- "sUploaderId" : htVar.sUploaderId |
|
285 |
+ vars.uploaderId = oUploader.attr("data-namespace"); |
|
286 |
+ vars.attachments = new yobi.Attachments({ |
|
287 |
+ "elContainer" : elements.uploader, |
|
288 |
+ "elTextarea" : elements.body, |
|
289 |
+ "sTplFileItem" : vars.tplFileItem, |
|
290 |
+ "sUploaderId" : vars.uploaderId |
|
281 | 291 |
}); |
282 | 292 |
} |
283 | 293 |
} |
284 | 294 |
|
285 |
- _init(htOptions || {}); |
|
295 |
+ function _getFormValue(){ |
|
296 |
+ return { |
|
297 |
+ "title" : $.trim(elements.title.val()), |
|
298 |
+ "fromProject": $.trim(elements.fromProject.val()), |
|
299 |
+ "toProject" : $.trim(elements.toProject.val()), |
|
300 |
+ "fromBranch" : $.trim(elements.fromBranch.val()), |
|
301 |
+ "toBranch" : $.trim(elements.toBranch.val()) |
|
302 |
+ }; |
|
303 |
+ } |
|
304 |
+ |
|
305 |
+ _init(options || {}); |
|
286 | 306 |
}; |
287 | 307 |
})("yobi.git.Write"); |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?