mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-28 19:11:03 +08:00
fix(pr-view): update reviewers summary and types
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { CheckStatus, PRComment, PRReviewer } from "./types"
|
||||
import type { CheckStatus, PRComment, PRReviewer, ReviewerState } from "./types"
|
||||
import type { PRResult, GhThread, GhReviewRequest, GhReview } from "./am-pr-types"
|
||||
|
||||
export function parsePRResult(json: string): PRResult | null {
|
||||
@@ -55,7 +55,7 @@ export function formatCheckDuration(startedAt?: string, completedAt?: string): s
|
||||
return secs < 60 ? `${secs}s` : `${Math.floor(secs / 60)}m ${secs % 60}s`
|
||||
}
|
||||
|
||||
const REVIEWER_STATE: Record<string, PRReviewer["state"]> = {
|
||||
const REVIEWER_STATE: Record<string, ReviewerState> = {
|
||||
APPROVED: "approved",
|
||||
CHANGES_REQUESTED: "changes_requested",
|
||||
COMMENTED: "commented",
|
||||
|
||||
@@ -71,10 +71,12 @@ export interface PRComment {
|
||||
createdAt?: number
|
||||
}
|
||||
|
||||
export type ReviewerState = "approved" | "changes_requested" | "pending" | "commented"
|
||||
|
||||
export interface PRReviewer {
|
||||
login: string
|
||||
avatar?: string
|
||||
state: "approved" | "changes_requested" | "pending" | "commented"
|
||||
state: ReviewerState
|
||||
}
|
||||
|
||||
export interface PRStatus {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/** @jsxImportSource solid-js */
|
||||
import { For, Show, createSignal } from "solid-js"
|
||||
import { Icon } from "@kilocode/kilo-ui/icon"
|
||||
import type { PRReviewer } from "./pr-types"
|
||||
import type { PRReviewer, ReviewerState } from "./pr-types"
|
||||
import { SectionHeading } from "./SectionHeading"
|
||||
|
||||
const REVIEWER_ICON: Record<PRReviewer["state"], string> = {
|
||||
const REVIEWER_ICON: Record<ReviewerState, string> = {
|
||||
approved: "circle-check",
|
||||
changes_requested: "refresh",
|
||||
commented: "edit",
|
||||
pending: "dash",
|
||||
}
|
||||
|
||||
const REVIEWER_LABEL: Record<PRReviewer["state"], string> = {
|
||||
const REVIEWER_LABEL: Record<ReviewerState, string> = {
|
||||
approved: "Approved",
|
||||
changes_requested: "Changes requested",
|
||||
commented: "Commented",
|
||||
|
||||
@@ -19,14 +19,11 @@ function summaryRows(pr: PRStatus): Array<{ icon: string; label: string; status:
|
||||
})
|
||||
}
|
||||
|
||||
const reviewers = pr.comments?.reviewers
|
||||
if (reviewers && reviewers.length > 0) {
|
||||
const approved = reviewers.filter((r) => r.state === "approved").length
|
||||
const changes = reviewers.filter((r) => r.state === "changes_requested").length
|
||||
const status = approved === reviewers.length ? "success" : changes > 0 ? "failure" : "pending"
|
||||
if (pr.review) {
|
||||
const status = pr.review === "approved" ? "success" : pr.review === "changes_requested" ? "failure" : "pending"
|
||||
rows.push({
|
||||
icon: status === "success" ? "circle-check" : status === "failure" ? "circle-x-outline" : "play",
|
||||
label: approved === reviewers.length ? "All reviewers approved" : `${approved}/${reviewers.length} approvals`,
|
||||
label: status === "success" ? "Approved" : status === "failure" ? "Changes requested" : "Review pending",
|
||||
status,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,8 +25,10 @@ export interface PRComment {
|
||||
createdAt?: number
|
||||
}
|
||||
|
||||
export type ReviewerState = "approved" | "changes_requested" | "pending" | "commented"
|
||||
|
||||
export interface PRReviewer {
|
||||
login: string
|
||||
avatar?: string
|
||||
state: "approved" | "changes_requested" | "pending" | "commented"
|
||||
state: ReviewerState
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user