Commit c5a27c42 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Implemented closed/merged details for Issue/MergeRequest.

parent 1606dadd
......@@ -7,22 +7,27 @@ import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Milestone
data class Issue(
@SerializedName("id") val id: Long,
@SerializedName("iid") val iid: Long,
@SerializedName("state") val state: IssueState,
@SerializedName("description") val description: String?,
@SerializedName("author") val author: Author,
@SerializedName("milestone") val milestone: Milestone?,
@SerializedName("project_id") val projectId: Long,
@SerializedName("assignees") val assignees: List<Assignee>,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("title") val title: String?,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("labels") val labels: List<String>,
@SerializedName("user_notes_count") val userNotesCount: Int,
@SerializedName("due_date") val dueDate: LocalDateTime?,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("confidential") val confidential: Boolean,
@SerializedName("upvotes") val upvotes: Int,
@SerializedName("downvotes") val downvotes: Int
@SerializedName("id") val id: Long,
@SerializedName("iid") val iid: Long,
@SerializedName("state") val state: IssueState,
@SerializedName("description") val description: String?,
@SerializedName("author") val author: Author,
@SerializedName("milestone") val milestone: Milestone?,
@SerializedName("project_id") val projectId: Long,
@SerializedName("assignees") val assignees: List<Assignee>,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("title") val title: String?,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("labels") val labels: List<String>,
@SerializedName("user_notes_count") val userNotesCount: Int,
@SerializedName("due_date") val dueDate: LocalDateTime?,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("confidential") val confidential: Boolean,
@SerializedName("upvotes") val upvotes: Int,
@SerializedName("downvotes") val downvotes: Int,
// The closed_by attribute was introduced in GitLab 10.6.
// This value will only be present for issues which were closed after GitLab 10.6 and
// when the user account that closed the issue still exists.
@SerializedName("closed_by") val closedBy: Author?,
@SerializedName("closed_at") val closedAt: LocalDateTime?
)
\ No newline at end of file
......@@ -7,32 +7,39 @@ import ru.terrakok.gitlabclient.entity.Milestone
import ru.terrakok.gitlabclient.entity.User
data class MergeRequest(
@SerializedName("id") val id: Long,
@SerializedName("iid") val iid: Long,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("target_branch") val targetBranch: String?,
@SerializedName("source_branch") val sourceBranch: String?,
@SerializedName("project_id") val projectId: Long,
@SerializedName("title") val title: String?,
@SerializedName("state") val state: MergeRequestState,
@SerializedName("upvotes") val upvotes: Int,
@SerializedName("downvotes") val downvotes: Int,
@SerializedName("author") val author: Author,
@SerializedName("assignee") val assignee: User?,
@SerializedName("source_project_id") val sourceProjectId: Int,
@SerializedName("target_project_id") val targetProjectId: Int,
@SerializedName("description") val description: String?,
@SerializedName("work_in_progress") val workInProgress: Boolean,
@SerializedName("milestone") val milestone: Milestone?,
@SerializedName("merge_when_pipeline_succeeds") val mergeWhenPipelineSucceeds: Boolean,
@SerializedName("merge_status") val mergeStatus: String?,
@SerializedName("sha") val sha: String?,
@SerializedName("merge_commit_sha") val mergeCommitSha: String?,
@SerializedName("user_notes_count") val userNotesCount: Int,
@SerializedName("should_remove_source_branch") val shouldRemoveSourceBranch: Boolean,
@SerializedName("force_remove_source_branch") val forceRemoveSourceBranch: Boolean,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("time_stats") val timeStats: MergeRequestTimeStats?,
@SerializedName("labels") val labels: List<String>
@SerializedName("id") val id: Long,
@SerializedName("iid") val iid: Long,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("target_branch") val targetBranch: String?,
@SerializedName("source_branch") val sourceBranch: String?,
@SerializedName("project_id") val projectId: Long,
@SerializedName("title") val title: String?,
@SerializedName("state") val state: MergeRequestState,
@SerializedName("upvotes") val upvotes: Int,
@SerializedName("downvotes") val downvotes: Int,
@SerializedName("author") val author: Author,
@SerializedName("assignee") val assignee: User?,
@SerializedName("source_project_id") val sourceProjectId: Int,
@SerializedName("target_project_id") val targetProjectId: Int,
@SerializedName("description") val description: String?,
@SerializedName("work_in_progress") val workInProgress: Boolean,
@SerializedName("milestone") val milestone: Milestone?,
@SerializedName("merge_when_pipeline_succeeds") val mergeWhenPipelineSucceeds: Boolean,
@SerializedName("merge_status") val mergeStatus: String?,
@SerializedName("sha") val sha: String?,
@SerializedName("merge_commit_sha") val mergeCommitSha: String?,
@SerializedName("user_notes_count") val userNotesCount: Int,
@SerializedName("should_remove_source_branch") val shouldRemoveSourceBranch: Boolean,
@SerializedName("force_remove_source_branch") val forceRemoveSourceBranch: Boolean,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("time_stats") val timeStats: MergeRequestTimeStats?,
@SerializedName("labels") val labels: List<String>,
// The closed_by attribute was introduced in GitLab 10.6.
// This value will only be present for merge requests which were closed/merged after GitLab 10.6
// and when the user account that closed/merged the issue still exists.
@SerializedName("closed_by") val closedBy: Author?,
@SerializedName("closed_at") val closedAt: LocalDateTime?,
@SerializedName("merged_by") val mergedBy: Author?,
@SerializedName("merged_at") val mergedAt: LocalDateTime?
)
......@@ -22,12 +22,13 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
override val layoutRes = R.layout.fragment_issue_info
@InjectPresenter lateinit var presenter: IssueInfoPresenter
@InjectPresenter
lateinit var presenter: IssueInfoPresenter
@ProvidePresenter
fun providePresenter() =
Toothpick.openScope(DI.ISSUE_SCOPE)
.getInstance(IssueInfoPresenter::class.java)
Toothpick.openScope(DI.ISSUE_SCOPE)
.getInstance(IssueInfoPresenter::class.java)
override fun showIssue(issueInfo: IssueInfoView.IssueInfo) {
val issue = issueInfo.issue
......@@ -37,21 +38,28 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
titleTextView.text = issue.title
stateImageView.setImageResource(R.drawable.circle)
// TODO: issue info (Display action user name for the CLOSED states).
// Wait for https://gitlab.com/gitlab-org/gitlab-ce/issues/41967
when (issue.state) {
IssueState.OPENED -> {
stateImageView.setColorFilter(context!!.color(R.color.green))
subtitleTextView.text = String.format(
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_opened),
issue.author.name,
issue.createdAt.humanTime(resources)
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_opened),
issue.author.name,
issue.createdAt.humanTime(resources)
)
}
IssueState.CLOSED -> {
stateImageView.setColorFilter(context!!.color(R.color.red))
subtitleTextView.text = getString(R.string.target_status_closed)
subtitleTextView.text = if (issue.closedBy != null && issue.closedAt != null) {
String.format(
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_closed),
issue.closedBy.name,
issue.closedAt.humanTime(resources)
)
} else {
getString(R.string.target_status_closed)
}
}
}
avatarImageView.loadRoundedImage(issue.author.avatarUrl, context)
......
......@@ -38,25 +38,43 @@ class MergeRequestInfoFragment : BaseFragment(), MergeRequestInfoView {
?.setTitle("!${mergeRequest.iid}", mrInfo.project.name)
titleTextView.text = mergeRequest.title
// TODO: merge request info (Display action user name for the MERGED/CLOSED states).
// Wait for https://gitlab.com/gitlab-org/gitlab-ce/issues/41905.
when (mergeRequest.state) {
MergeRequestState.OPENED -> {
stateImageView.tint(R.color.green)
subtitleTextView.text = String.format(
getString(R.string.merge_request_info_subtitle),
getString(R.string.target_status_opened),
mergeRequest.author.name,
mergeRequest.createdAt.humanTime(resources)
getString(R.string.merge_request_info_subtitle),
getString(R.string.target_status_opened),
mergeRequest.author.name,
mergeRequest.createdAt.humanTime(resources)
)
}
MergeRequestState.MERGED -> {
stateImageView.tint(R.color.blue)
subtitleTextView.text = getString(R.string.target_status_merged)
subtitleTextView.text =
if (mergeRequest.mergedBy != null && mergeRequest.mergedAt != null) {
String.format(
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_merged),
mergeRequest.mergedBy.name,
mergeRequest.mergedAt.humanTime(resources)
)
} else {
getString(R.string.target_status_merged)
}
}
MergeRequestState.CLOSED -> {
stateImageView.tint(R.color.red)
subtitleTextView.text = getString(R.string.target_status_closed)
subtitleTextView.text =
if (mergeRequest.closedBy != null && mergeRequest.closedAt != null) {
String.format(
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_closed),
mergeRequest.closedBy.name,
mergeRequest.closedAt.humanTime(resources)
)
} else {
getString(R.string.target_status_closed)
}
}
}
avatarImageView.loadRoundedImage(mergeRequest.author.avatarUrl, context)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment