feat: #123 Add assignee column

Closes: #123
This commit is contained in:
Nathan Smith 2024-06-30 16:10:28 -04:00
parent 99af75cffe
commit f5eca6a566
2 changed files with 22 additions and 10 deletions

View file

@ -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 & {

View file

@ -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<T> {
@ -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: {