issue: Support issue template feature
If you create ISSUE_TEMPLATE.md file at your repository root, then it will be used for issue template for the project. Also, user can edit issue template at project setting page without pushing ISSUE_TEMPLATE.md to the repository This feature was inspired by Github's same functionality. See: - https://help.github.com/articles/creating-an-issue-template-for-your-repository - Yona Github issue #136
@753f72250b081fd3facd1262f5c4cd3245e5e686
--- app/assets/stylesheets/less/_page.less
+++ app/assets/stylesheets/less/_page.less
... | ... | @@ -3442,7 +3442,7 @@ |
3442 | 3442 |
width: 99%; /*946px;/*866px;*/ |
3443 | 3443 |
} |
3444 | 3444 |
textarea.content{ |
3445 |
- height: 250px; |
|
3445 |
+ height: 300px; |
|
3446 | 3446 |
} |
3447 | 3447 |
textarea.text { |
3448 | 3448 |
resize:vertical; |
--- app/controllers/BoardApp.java
+++ app/controllers/BoardApp.java
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 |
import models.enumeration.ResourceType; |
18 | 18 |
import org.apache.commons.collections.CollectionUtils; |
19 | 19 |
import org.apache.commons.lang3.StringUtils; |
20 |
+import play.api.data.validation.ValidationError; |
|
20 | 21 |
import play.data.Form; |
21 | 22 |
import play.db.ebean.Transactional; |
22 | 23 |
import play.libs.Json; |
... | ... | @@ -167,6 +168,10 @@ |
167 | 168 |
preparedBodyText = BareRepository.readREADME(project); |
168 | 169 |
} |
169 | 170 |
|
171 |
+ if(issueTemplateEditRequested()){ |
|
172 |
+ preparedBodyText = StringUtils.defaultIfBlank(project.getIssueTemplate(), ""); |
|
173 |
+ } |
|
174 |
+ |
|
170 | 175 |
return ok(create.render("post.new", new Form<>(Posting.class), project, isAllowedToNotice, preparedBodyText)); |
171 | 176 |
} |
172 | 177 |
|
... | ... | @@ -176,6 +181,10 @@ |
176 | 181 |
|
177 | 182 |
private static boolean readmeEditRequested() { |
178 | 183 |
return request().getQueryString("readme") != null; |
184 |
+ } |
|
185 |
+ |
|
186 |
+ private static boolean issueTemplateEditRequested() { |
|
187 |
+ return request().getQueryString("issueTemplate") != null; |
|
179 | 188 |
} |
180 | 189 |
|
181 | 190 |
@Transactional |
... | ... | @@ -209,6 +218,12 @@ |
209 | 218 |
commitReadmeFile(project, post); |
210 | 219 |
} |
211 | 220 |
} |
221 |
+ |
|
222 |
+ if (post.issueTemplate != null) { |
|
223 |
+ commitIssueTemplateFile(project, post); |
|
224 |
+ return redirect(routes.ProjectApp.project(project.owner, projectName)); |
|
225 |
+ } |
|
226 |
+ |
|
212 | 227 |
post.save(); |
213 | 228 |
attachUploadFilesToPost(post.asResource()); |
214 | 229 |
NotificationEvent.afterNewPost(post); |
... | ... | @@ -229,6 +244,16 @@ |
229 | 244 |
} |
230 | 245 |
} |
231 | 246 |
|
247 |
+ private static void commitIssueTemplateFile(Project project, Posting post){ |
|
248 |
+ BareCommit bare = new BareCommit(project, UserApp.currentUser()); |
|
249 |
+ try{ |
|
250 |
+ bare.commitTextFile("ISSUE_TEMPLATE.md", post.body, post.title); |
|
251 |
+ } catch (IOException e) { |
|
252 |
+ e.printStackTrace(); |
|
253 |
+ play.Logger.error(e.getMessage()); |
|
254 |
+ } |
|
255 |
+ } |
|
256 |
+ |
|
232 | 257 |
@IsAllowed(value = Operation.READ, resourceType = ResourceType.BOARD_POST) |
233 | 258 |
public static Result post(String userName, String projectName, Long number) { |
234 | 259 |
Project project = Project.findByOwnerAndProjectName(userName, projectName); |
--- app/controllers/IssueApp.java
+++ app/controllers/IssueApp.java
... | ... | @@ -1,23 +1,9 @@ |
1 | 1 |
/** |
2 |
- * Yobi, Project Hosting SW |
|
3 |
- * |
|
4 |
- * Copyright 2012 NAVER Corp. |
|
5 |
- * http://yobi.io |
|
6 |
- * |
|
7 |
- * @author Tae |
|
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 |
- */ |
|
2 |
+ * Yona, 21st Century Project Hosting SW |
|
3 |
+ * <p> |
|
4 |
+ * Copyright Yona & Yobi Authors & NAVER Corp. |
|
5 |
+ * https://yona.io |
|
6 |
+ **/ |
|
21 | 7 |
package controllers; |
22 | 8 |
|
23 | 9 |
import actions.NullProjectCheckAction; |
... | ... | @@ -290,7 +276,8 @@ |
290 | 276 |
@IsCreatable(ResourceType.ISSUE_POST) |
291 | 277 |
public static Result newIssueForm(String ownerName, String projectName) { |
292 | 278 |
Project project = Project.findByOwnerAndProjectName(ownerName, projectName); |
293 |
- return ok(create.render("title.newIssue", new Form<>(Issue.class), project)); |
|
279 |
+ String issueTemplate = StringUtils.defaultIfBlank(project.getIssueTemplate(), ""); |
|
280 |
+ return ok(create.render("title.newIssue", new Form<>(Issue.class), project, issueTemplate)); |
|
294 | 281 |
} |
295 | 282 |
|
296 | 283 |
@Transactional |
... | ... | @@ -418,7 +405,8 @@ |
418 | 405 |
Project project = Project.findByOwnerAndProjectName(ownerName, projectName); |
419 | 406 |
|
420 | 407 |
if (issueForm.hasErrors()) { |
421 |
- return badRequest(create.render("error.validation", issueForm, project)); |
|
408 |
+ String issueTemplate = StringUtils.defaultIfBlank(project.getIssueTemplate(), ""); |
|
409 |
+ return badRequest(create.render("error.validation", issueForm, project, issueTemplate)); |
|
422 | 410 |
} |
423 | 411 |
|
424 | 412 |
final Issue newIssue = issueForm.get(); |
--- app/models/Posting.java
+++ app/models/Posting.java
... | ... | @@ -26,6 +26,9 @@ |
26 | 26 |
public boolean notice; |
27 | 27 |
public boolean readme; |
28 | 28 |
|
29 |
+ @Transient |
|
30 |
+ public String issueTemplate; |
|
31 |
+ |
|
29 | 32 |
@OneToMany(cascade = CascadeType.ALL) |
30 | 33 |
public List<PostingComment> comments; |
31 | 34 |
|
--- app/models/Project.java
+++ app/models/Project.java
... | ... | @@ -1,23 +1,9 @@ |
1 | 1 |
/** |
2 |
- * Yobi, Project Hosting SW |
|
3 |
- * |
|
4 |
- * Copyright 2012 NAVER Corp. |
|
5 |
- * http://yobi.io |
|
6 |
- * |
|
7 |
- * @author Hwi Ahn |
|
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 |
- */ |
|
2 |
+ * Yona, 21st Century Project Hosting SW |
|
3 |
+ * <p> |
|
4 |
+ * Copyright Yona & Yobi Authors & NAVER Corp. |
|
5 |
+ * https://yona.io |
|
6 |
+ **/ |
|
21 | 7 |
package models; |
22 | 8 |
|
23 | 9 |
import com.avaje.ebean.Ebean; |
... | ... | @@ -315,6 +301,16 @@ |
315 | 301 |
} |
316 | 302 |
} |
317 | 303 |
|
304 |
+ public String getIssueTemplate() { |
|
305 |
+ try { |
|
306 |
+ byte[] bytes = RepositoryService.getRepository(this) |
|
307 |
+ .getRawFile("HEAD", "ISSUE_TEMPLATE.md"); |
|
308 |
+ return new String(bytes, FileUtil.detectCharset(bytes)); |
|
309 |
+ } catch (Exception e) { |
|
310 |
+ return null; |
|
311 |
+ } |
|
312 |
+ } |
|
313 |
+ |
|
318 | 314 |
/** |
319 | 315 |
* @return the readme file name or {@code null} if the file does not exist |
320 | 316 |
* @throws IOException Signals that an I/O exception has occurred. |
--- app/views/board/create.scala.html
+++ app/views/board/create.scala.html
... | ... | @@ -1,24 +1,12 @@ |
1 | 1 |
@** |
2 |
-* Yobi, Project Hosting SW |
|
2 |
+* Yona, 21st Century Project Hosting SW |
|
3 | 3 |
* |
4 |
-* Copyright 2012 NAVER Corp. |
|
5 |
-* http://yobi.io |
|
6 |
-* |
|
7 |
-* @author Ahn Hyeok Jun |
|
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. |
|
4 |
+* Copyright Yona & Yobi Authors & NAVER Corp. |
|
5 |
+* https://yona.io |
|
20 | 6 |
**@ |
21 |
-@(title:String, form: play.data.Form[Posting], project:Project, isAllowedToNotice:Boolean, preparedPostBody:String = "") |
|
7 |
+@import play.data.Form |
|
8 |
+@import org.apache.commons.lang3.StringUtils |
|
9 |
+@(title:String, form: Form[Posting], project:Project, isAllowedToNotice:Boolean, preparedPostBody:String = "") |
|
22 | 10 |
|
23 | 11 |
@import utils.AccessControl._ |
24 | 12 |
@import utils.TemplateHelper._ |
... | ... | @@ -26,9 +14,11 @@ |
26 | 14 |
@import models.enumeration._ |
27 | 15 |
@implicitField = @{ helper.FieldConstructor(simpleForm) } |
28 | 16 |
|
29 |
-@readmeUpdateMessage = @{ |
|
17 |
+@titleMessage = @{ |
|
30 | 18 |
if( !requestHeader.getQueryString("readme").equals(None) ) { |
31 | 19 |
"Update README.md" |
20 |
+ } else if( !requestHeader.getQueryString("issueTemplate").equals(None) ) { |
|
21 |
+ "ISSUE_TEMPLATE.md: Project Issue Template" |
|
32 | 22 |
} |
33 | 23 |
} |
34 | 24 |
|
... | ... | @@ -44,7 +34,7 @@ |
44 | 34 |
</dt> |
45 | 35 |
<dd> |
46 | 36 |
@defining(form.errors().get("title")) { errors => |
47 |
- <input type="text" id="title" name="title" class="zen-mode text title @if(errors != null) {error}" maxlength="250" tabindex="1" value="@readmeUpdateMessage"/> |
|
37 |
+ <input type="text" id="title" name="title" class="zen-mode text title @if(errors != null) {error}" maxlength="250" tabindex="1" value="@titleMessage"/> |
|
48 | 38 |
@if(errors != null) { |
49 | 39 |
<div class="message"> |
50 | 40 |
@for(error <- errors) { |
... | ... | @@ -54,24 +44,34 @@ |
54 | 44 |
} |
55 | 45 |
} |
56 | 46 |
</dd> |
47 |
+ <dd> |
|
48 |
+ @if(!requestHeader.getQueryString("issueTemplate").equals(None)){ |
|
49 |
+ <div class="attach-wrap"> |
|
50 |
+ <span class="help help-droppable">@Messages("issue.template.no.attachment.allow")</span> |
|
51 |
+ </div> |
|
52 |
+ } |
|
53 |
+ </dd> |
|
57 | 54 |
<dd style="position: relative;"> |
58 | 55 |
@common.editor("body", preparedPostBody, "tabindex=2") |
59 | 56 |
</dd> |
60 | 57 |
</dl> |
61 | 58 |
@** fileUploader **@ |
62 |
- @if(!UserApp.currentUser.isAnonymous) { |
|
59 |
+ @if(requestHeader.getQueryString("issueTemplate").equals(None)) { |
|
60 |
+ @if(!UserApp.currentUser.isAnonymous) { |
|
63 | 61 |
@common.fileUploader(ResourceType.BOARD_POST, null) |
62 |
+ } |
|
64 | 63 |
} |
65 | 64 |
@** end of fileUploader **@ |
66 | 65 |
|
67 | 66 |
<div class="right-txt mt10 mb10"> |
68 |
- @if(isAllowedToNotice ){ |
|
67 |
+ @if(isAllowedToNotice && requestHeader.getQueryString("issueTemplate").equals(None)){ |
|
69 | 68 |
<label class="checkbox"> |
70 | 69 |
<input type="checkbox" id="notice" name="notice"> |
71 | 70 |
@Messages("post.notice.label") |
72 | 71 |
</label> |
73 | 72 |
} |
74 | 73 |
|
74 |
+ <input type="hidden" id="issueTemplate" name="issueTemplate" @boolToCheckedString(!requestHeader.getQueryString("issueTemplate").equals(None))> |
|
75 | 75 |
@if(isProjectResourceCreatable(UserApp.currentUser(), project, ResourceType.COMMIT)){ |
76 | 76 |
@if(project.isGit && !requestHeader.getQueryString("readme").equals(None)){ |
77 | 77 |
<label class="checkbox"> |
--- app/views/issue/create.scala.html
+++ app/views/issue/create.scala.html
... | ... | @@ -1,24 +1,11 @@ |
1 | 1 |
@** |
2 |
-* Yobi, Project Hosting SW |
|
2 |
+* Yona, 21st Century Project Hosting SW |
|
3 | 3 |
* |
4 |
-* Copyright 2012 NAVER Corp. |
|
5 |
-* http://yobi.io |
|
6 |
-* |
|
7 |
-* @author Ahn Hyeok Jun |
|
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. |
|
4 |
+* Copyright Yona & Yobi Authors & NAVER Corp. |
|
5 |
+* https://yona.io |
|
20 | 6 |
**@ |
21 |
-@(title:String, issueForm: play.data.Form[Issue], project:Project) |
|
7 |
+@import play.data.Form |
|
8 |
+@(title:String, issueForm: Form[Issue], project:Project, issueTemplate:String = "") |
|
22 | 9 |
@import helper._ |
23 | 10 |
@import scala.collection.mutable.Map |
24 | 11 |
@import models.enumeration.ResourceType |
... | ... | @@ -58,7 +45,7 @@ |
58 | 45 |
<div class="span9 span-left-pane"> |
59 | 46 |
<dl> |
60 | 47 |
<dd style="position: relative;"> |
61 |
- @common.editor("body", "", "tabindex=2", "content-body") |
|
48 |
+ @common.editor("body", issueTemplate, "tabindex=2", "content-body") |
|
62 | 49 |
</dd> |
63 | 50 |
</dl> |
64 | 51 |
|
--- app/views/project/setting.scala.html
+++ app/views/project/setting.scala.html
... | ... | @@ -1,24 +1,11 @@ |
1 | 1 |
@** |
2 |
-* Yobi, Project Hosting SW |
|
2 |
+* Yona, 21st Century Project Hosting SW |
|
3 | 3 |
* |
4 |
-* Copyright 2012 NAVER Corp. |
|
5 |
-* http://yobi.io |
|
6 |
-* |
|
7 |
-* @author Sangcheol Hwang |
|
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. |
|
4 |
+* Copyright Yona & Yobi Authors & NAVER Corp. |
|
5 |
+* https://yona.io |
|
20 | 6 |
**@ |
21 |
-@(message: String)(projectForm: play.data.Form[Project], project: Project, branches: List[String]) |
|
7 |
+@import play.data.Form |
|
8 |
+@(message: String)(projectForm: Form[Project], project: Project, branches: List[String]) |
|
22 | 9 |
|
23 | 10 |
@import helper._ |
24 | 11 |
@import utils.TemplateHelper._ |
... | ... | @@ -88,6 +75,12 @@ |
88 | 75 |
</div> |
89 | 76 |
</div> |
90 | 77 |
<div class="box-wrap middle"> |
78 |
+ <div class="cu-label">@Messages("issue.template")</div> |
|
79 |
+ <div class="cu-desc"> |
|
80 |
+ <a href="@routes.BoardApp.newPostForm(project.owner, project.name)?issueTemplate=true" class="ybtn" target="_blank">@Messages("issue.template.edit")</a> |
|
81 |
+ </div> |
|
82 |
+ </div> |
|
83 |
+ <div class="box-wrap middle"> |
|
91 | 84 |
<div class="cu-label">@Messages("project.codeAccessible")</div> |
92 | 85 |
<div class="cu-desc"> |
93 | 86 |
<input name="isCodeAccessibleMemberOnly" type="radio" id="codeAccessibleMemberOnly" class="radio-btn" value="true" @if(project.isCodeAccessibleMemberOnly){checked="checked"}><label for="codeAccessibleMemberOnly" class="bg-radiobtn label-public">@Messages("button.yes")</label> |
--- conf/messages
+++ conf/messages
... | ... | @@ -286,6 +286,9 @@ |
286 | 286 |
issue.state.closed = Closed |
287 | 287 |
issue.state.enrolled = Status entered |
288 | 288 |
issue.state.open = Open |
289 |
+issue.template = Issue Template |
|
290 |
+issue.template.edit = Edit |
|
291 |
+issue.template.no.attachment.allow = Issue templates do not support attachments. |
|
289 | 292 |
issue.unvote.description = Click here if you no longer agree with this issue. |
290 | 293 |
issue.unwatch = Unsubscribe this issue |
291 | 294 |
issue.unwatch.start = You will no longer get notifications about this issue |
--- conf/messages.ko-KR
+++ conf/messages.ko-KR
... | ... | @@ -285,6 +285,9 @@ |
285 | 285 |
issue.state.closed = 닫힘 |
286 | 286 |
issue.state.enrolled = 등록 |
287 | 287 |
issue.state.open = 열림 |
288 |
+issue.template = 이슈 템플릿 |
|
289 |
+issue.template.edit = 편집 |
|
290 |
+issue.template.no.attachment.allow = 이슈 템플릿 작성시에는 첨부파일 기능을 지원하지 않습니다. |
|
288 | 291 |
issue.unvote.description = 공감을 취소하려면 버튼을 누릅니다. |
289 | 292 |
issue.unwatch = 이슈 그만지켜보기 |
290 | 293 |
issue.unwatch.start = 이제 이 이슈에 관한 알림을 받지 않습니다 |
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?