97 IssueStatusPhase.Done -> done++ |
97 IssueStatusPhase.Done -> done++ |
98 } |
98 } |
99 } |
99 } |
100 } |
100 } |
101 |
101 |
|
102 data class CommitLink(val url: String, val hash: String, val message: String) |
|
103 |
102 class IssueDetailView( |
104 class IssueDetailView( |
103 val issue: Issue, |
105 val issue: Issue, |
104 val comments: List<IssueComment>, |
106 val comments: List<IssueComment>, |
105 val project: Project, |
107 val project: Project, |
106 val version: Version?, |
108 val version: Version?, |
108 projectIssues: List<Issue>, |
110 projectIssues: List<Issue>, |
109 val currentRelations: List<IssueRelation>, |
111 val currentRelations: List<IssueRelation>, |
110 /** |
112 /** |
111 * Optional resource key to an error message for the relation editor. |
113 * Optional resource key to an error message for the relation editor. |
112 */ |
114 */ |
113 val relationError: String? |
115 val relationError: String?, |
|
116 commitRefs: List<CommitRef> |
114 ) : View() { |
117 ) : View() { |
115 val relationTypes = RelationType.values() |
118 val relationTypes = RelationType.values() |
116 val linkableIssues = projectIssues.filterNot { it.id == issue.id } |
119 val linkableIssues = projectIssues.filterNot { it.id == issue.id } |
|
120 val commitLinks: List<CommitLink> |
117 |
121 |
118 private val parser: Parser |
122 private val parser: Parser |
119 private val renderer: HtmlRenderer |
123 private val renderer: HtmlRenderer |
120 |
124 |
121 init { |
125 init { |
129 |
133 |
130 issue.description = formatMarkdown(issue.description ?: "") |
134 issue.description = formatMarkdown(issue.description ?: "") |
131 for (comment in comments) { |
135 for (comment in comments) { |
132 comment.commentFormatted = formatMarkdown(comment.comment) |
136 comment.commentFormatted = formatMarkdown(comment.comment) |
133 } |
137 } |
134 } |
138 |
|
139 val commitBaseUrl = project.repoUrl |
|
140 commitLinks = (if (commitBaseUrl == null || project.vcs == VcsType.None) emptyList() else commitRefs.map { |
|
141 CommitLink(buildCommitUrl(commitBaseUrl, project.vcs, it.hash), it.hash, it.message) |
|
142 }) |
|
143 } |
|
144 |
|
145 private fun buildCommitUrl(baseUrl: String, vcs: VcsType, hash: String): String = |
|
146 with (StringBuilder(baseUrl)) { |
|
147 if (!endsWith("/")) append('/') |
|
148 when (vcs) { |
|
149 VcsType.Mercurial -> append("rev/") |
|
150 else -> append("commit/") |
|
151 } |
|
152 append(hash) |
|
153 toString() |
|
154 } |
135 |
155 |
136 private fun formatEmojis(text: String) = text |
156 private fun formatEmojis(text: String) = text |
137 .replace("(/)", "✅") |
157 .replace("(/)", "✅") |
138 .replace("(x)", "❌") |
158 .replace("(x)", "❌") |
139 .replace("(!)", "⚡") |
159 .replace("(!)", "⚡") |