diff --git a/src/github/response.ts b/src/github/response.ts index 2e92924..04d78d0 100644 --- a/src/github/response.ts +++ b/src/github/response.ts @@ -43,6 +43,8 @@ export type TimelineCrossReferencedEvent = OpenAPI.components["schemas"]["timeli export type IssueTimelineResponse = RestEndpointMethodTypes["issues"]["listEventsForTimeline"]["response"]["data"]; export type CheckRunListResponse = RestEndpointMethodTypes["checks"]["listForRef"]["response"]["data"]; +export type UserResponse = IssueListResponse[number]["user"]; + // Param Types export type RepoSearchParams = RestEndpointMethodTypes["search"]["repos"]["parameters"]; export type IssueListParams = PaginationParams & { diff --git a/src/query/column/base.ts b/src/query/column/base.ts index 49d9cc2..d52f184 100644 --- a/src/query/column/base.ts +++ b/src/query/column/base.ts @@ -3,7 +3,7 @@ import { parseUrl, repoAPIToBrowserUrl } from "../../github/url-parse"; import { DateFormat } from "../../util"; -import type { IssueListResponse } from "../../github/response"; +import type { IssueListResponse, UserResponse } from "../../github/response"; import type { TableResult } from "../types"; export interface ColumnGetter { @@ -28,6 +28,18 @@ export function DateCell(value: string | undefined | null, el: HTMLTableCellElem el.setText(DateFormat.DATE_SHORT.format(asDate)); } +export function UserCell(user: UserResponse, el: HTMLElement): void { + const anchor = el.createEl("a", { + cls: "github-link-table-author", + href: user?.html_url ?? "#", + attr: { target: "_blank" }, + }); + if (user?.avatar_url) { + anchor.createEl("img", { cls: "github-link-table-avatar", attr: { src: user.avatar_url } }); + } + anchor.createSpan({ text: user?.login }); +} + /** * Issue and PR columns share types, so some columns are shared */ @@ -51,15 +63,13 @@ export const CommonIssuePRColumns: ColumnsMap = { author: { header: "Author", cell: (row, el) => { - const anchor = el.createEl("a", { - cls: "github-link-table-author", - href: row.user?.html_url, - attr: { target: "_blank" }, - }); - if (row.user?.avatar_url) { - anchor.createEl("img", { cls: "github-link-table-avatar", attr: { src: row.user.avatar_url } }); - } - anchor.createSpan({ text: row.user?.login }); + UserCell(row.user, el); + }, + }, + assignee: { + header: "Assignee", + cell: (row, el) => { + UserCell(row.assignee, el); }, }, created: {