opencode-github-pr 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +440 -2
- package/demo/fixtures.ts +224 -0
- package/dist/pr-dashboard.tui.js +8710 -0
- package/package.json +65 -4
- package/plugins/app/DashboardView.tsx +373 -0
- package/plugins/app/PRRow.tsx +241 -0
- package/plugins/app/StatusMessage.tsx +22 -0
- package/plugins/app/actions.tsx +25 -0
- package/plugins/app/config.ts +165 -0
- package/plugins/app/theme.ts +53 -0
- package/plugins/app/usePRData.ts +364 -0
- package/plugins/domain/format.ts +27 -0
- package/plugins/domain/messages.ts +183 -0
- package/plugins/domain/pr-filters.ts +40 -0
- package/plugins/domain/pr-links.ts +12 -0
- package/plugins/domain/pr-status.ts +128 -0
- package/plugins/domain/types.ts +94 -0
- package/plugins/infra/git.ts +416 -0
- package/plugins/infra/github-enterprise.ts +31 -0
- package/plugins/infra/loader.ts +356 -0
- package/plugins/infra/mappers.ts +93 -0
- package/plugins/infra/octokit.ts +131 -0
- package/plugins/infra/queries.ts +155 -0
- package/plugins/pr-dashboard.ts +8 -0
- package/plugins/pr-dashboard.tui.tsx +238 -0
package/package.json
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-github-pr",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "GitHub pull request dashboard for the OpenCode sidebar: CI, review and merge status for your PRs.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"opencode",
|
|
7
|
+
"opencode-plugin",
|
|
8
|
+
"github",
|
|
9
|
+
"pull-requests",
|
|
10
|
+
"tui"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/987poiuytrewq/opencode-github-pr.git"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/987poiuytrewq/opencode-github-pr#readme",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/987poiuytrewq/opencode-github-pr/issues"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./plugins/pr-dashboard.ts",
|
|
24
|
+
"./tui": "./dist/pr-dashboard.tui.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"plugins/",
|
|
28
|
+
"dist/",
|
|
29
|
+
"demo/fixtures.ts",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "make test",
|
|
35
|
+
"test:unit": "make test-unit",
|
|
36
|
+
"test:integration": "make test-integration",
|
|
37
|
+
"test:e2e": "make test-e2e",
|
|
38
|
+
"test:watch": "make test-watch",
|
|
39
|
+
"build:tui": "bun build plugins/pr-dashboard.tui.tsx --outfile dist/pr-dashboard.tui.js --target bun --external @opencode/plugin/tui --external @opentui/core --external @opentui/solid --external @opencode/theme/tui --external solid-js",
|
|
40
|
+
"prepare": "bun run build:tui",
|
|
41
|
+
"typecheck": "make typecheck",
|
|
42
|
+
"format:check": "make format-check"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@opencode/plugin": "2.0.20",
|
|
46
|
+
"@opencode/theme": "2.0.20",
|
|
47
|
+
"@opentui/core": "0.6.6",
|
|
48
|
+
"@opentui/solid": "0.6.6",
|
|
49
|
+
"@types/bun": "1.3.14",
|
|
50
|
+
"bun-types": "1.3.14",
|
|
51
|
+
"solid-js": "^1.9.14",
|
|
52
|
+
"typescript": "^5.9.3"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@octokit/plugin-retry": "^8.1.0",
|
|
56
|
+
"@octokit/plugin-throttling": "^11.0.3",
|
|
57
|
+
"@octokit/rest": "^22.0.1",
|
|
58
|
+
"open": "^11.0.4"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@opencode/plugin": "^2.0.20",
|
|
62
|
+
"@opencode/theme": "^2.0.20",
|
|
63
|
+
"@opentui/core": "^0.6.6",
|
|
64
|
+
"@opentui/solid": "^0.6.6",
|
|
65
|
+
"solid-js": "^1.9.12"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show } from "solid-js"
|
|
3
|
+
import type { ResolvedTheme } from "@opencode/theme/tui"
|
|
4
|
+
import type { BoxRenderable } from "@opentui/core"
|
|
5
|
+
import { useRenderer } from "@opentui/solid"
|
|
6
|
+
import {
|
|
7
|
+
DashboardStatus,
|
|
8
|
+
type DashboardState,
|
|
9
|
+
type PRLinkTarget,
|
|
10
|
+
type PRListErrorKind,
|
|
11
|
+
type PRScope,
|
|
12
|
+
type PRStatusFilter,
|
|
13
|
+
} from "../domain/types"
|
|
14
|
+
import { filterPRs } from "../domain/pr-filters"
|
|
15
|
+
import { skin, type Skin } from "./theme"
|
|
16
|
+
import { errorMessages } from "../domain/messages"
|
|
17
|
+
import { PRRow } from "./PRRow"
|
|
18
|
+
import type { DashboardIcons, DashboardSpacing } from "./config"
|
|
19
|
+
import { StatusMessage } from "./StatusMessage"
|
|
20
|
+
|
|
21
|
+
export function DashboardView(props: {
|
|
22
|
+
theme: ResolvedTheme
|
|
23
|
+
state: DashboardState
|
|
24
|
+
setSelectedIdx: (n: number) => void
|
|
25
|
+
onOpen: (n: number, target?: PRLinkTarget) => void
|
|
26
|
+
scope: PRScope
|
|
27
|
+
statusFilter: PRStatusFilter
|
|
28
|
+
onCycleScope: () => void
|
|
29
|
+
onCycleStatus: () => void
|
|
30
|
+
onLoadMore: () => Promise<void>
|
|
31
|
+
pageSize: number
|
|
32
|
+
colors: Partial<Skin>
|
|
33
|
+
icons: DashboardIcons
|
|
34
|
+
spacing: DashboardSpacing
|
|
35
|
+
showSingleStatusCount: boolean
|
|
36
|
+
}) {
|
|
37
|
+
const sk = createMemo(() => skin(props.theme, props.colors))
|
|
38
|
+
const [scopeHovered, setScopeHovered] = createSignal(false)
|
|
39
|
+
const [statusHovered, setStatusHovered] = createSignal(false)
|
|
40
|
+
const [page, setPage] = createSignal(0)
|
|
41
|
+
const [previousHovered, setPreviousHovered] = createSignal(false)
|
|
42
|
+
const [nextHovered, setNextHovered] = createSignal(false)
|
|
43
|
+
let view: BoxRenderable | undefined
|
|
44
|
+
const [titleWidth, setTitleWidth] = createSignal(48)
|
|
45
|
+
const renderer = useRenderer()
|
|
46
|
+
createEffect(() => {
|
|
47
|
+
props.statusFilter
|
|
48
|
+
props.scope
|
|
49
|
+
setPage(0)
|
|
50
|
+
})
|
|
51
|
+
onMount(() => {
|
|
52
|
+
const iconWidth = Math.max(
|
|
53
|
+
Bun.stringWidth(props.icons.openPR),
|
|
54
|
+
Bun.stringWidth(props.icons.closedPR),
|
|
55
|
+
Bun.stringWidth(props.icons.draftPR),
|
|
56
|
+
Bun.stringWidth(props.icons.mergedPR),
|
|
57
|
+
)
|
|
58
|
+
const updateTitleWidth = () => {
|
|
59
|
+
const measuredWidth = view?.width
|
|
60
|
+
const availableWidth = measuredWidth && measuredWidth > 0 ? measuredWidth : renderer.width
|
|
61
|
+
if (availableWidth <= 0) return
|
|
62
|
+
const nextWidth = Math.max(1, Math.floor(availableWidth) - iconWidth - 1)
|
|
63
|
+
setTitleWidth((current) => current === nextWidth ? current : nextWidth)
|
|
64
|
+
}
|
|
65
|
+
updateTitleWidth()
|
|
66
|
+
const needsPostLayoutMeasurement = !view || view.width <= 0
|
|
67
|
+
if (needsPostLayoutMeasurement) renderer.once("frame", updateTitleWidth)
|
|
68
|
+
view?.on("resize", updateTitleWidth)
|
|
69
|
+
renderer.on("resize", updateTitleWidth)
|
|
70
|
+
onCleanup(() => {
|
|
71
|
+
renderer.off("frame", updateTitleWidth)
|
|
72
|
+
view?.off("resize", updateTitleWidth)
|
|
73
|
+
renderer.off("resize", updateTitleWidth)
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const prs = () => filterPRs(
|
|
78
|
+
props.state.prs,
|
|
79
|
+
props.scope,
|
|
80
|
+
props.statusFilter,
|
|
81
|
+
props.state.currentBranch,
|
|
82
|
+
props.state.viewerLogin,
|
|
83
|
+
)
|
|
84
|
+
const pageCount = () => Math.max(1, Math.ceil(prs().length / props.pageSize))
|
|
85
|
+
const totalPageCount = () => {
|
|
86
|
+
const totalCount = props.state.pagination.totalCount
|
|
87
|
+
return totalCount === null ? null : Math.max(1, Math.ceil(totalCount / props.pageSize))
|
|
88
|
+
}
|
|
89
|
+
const currentPage = () => Math.min(page(), pageCount() - 1)
|
|
90
|
+
const pagePRs = () =>
|
|
91
|
+
prs().slice(currentPage() * props.pageSize, (currentPage() + 1) * props.pageSize)
|
|
92
|
+
const filtersMatch = () =>
|
|
93
|
+
props.state.pagination.listing === props.statusFilter &&
|
|
94
|
+
props.state.pagination.scope === props.scope &&
|
|
95
|
+
props.state.pagination.scopeValue === (props.scope === "branch" ? props.state.currentBranch : null)
|
|
96
|
+
const canGoPrevious = () => currentPage() > 0
|
|
97
|
+
const canGoNext = () =>
|
|
98
|
+
currentPage() < pageCount() - 1 ||
|
|
99
|
+
(filtersMatch() &&
|
|
100
|
+
props.state.pagination.hasMore &&
|
|
101
|
+
!props.state.pagination.loading)
|
|
102
|
+
const listIsAvailable = () =>
|
|
103
|
+
props.state.status === DashboardStatus.Ok ||
|
|
104
|
+
(props.state.status === DashboardStatus.Error && props.state.prs.length > 0)
|
|
105
|
+
const listingPending = () => !filtersMatch()
|
|
106
|
+
const scopeListingPending = () =>
|
|
107
|
+
props.state.pagination.scope !== props.scope ||
|
|
108
|
+
props.state.pagination.scopeValue !== (props.scope === "branch" ? props.state.currentBranch : null)
|
|
109
|
+
|
|
110
|
+
const goNext = async () => {
|
|
111
|
+
if (currentPage() < pageCount() - 1) {
|
|
112
|
+
const next = currentPage() + 1
|
|
113
|
+
setPage(next)
|
|
114
|
+
if (
|
|
115
|
+
filtersMatch() &&
|
|
116
|
+
props.state.pagination.hasMore
|
|
117
|
+
) void props.onLoadMore()
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
if (
|
|
121
|
+
!filtersMatch() ||
|
|
122
|
+
!props.state.pagination.hasMore ||
|
|
123
|
+
props.state.pagination.loading
|
|
124
|
+
) return
|
|
125
|
+
|
|
126
|
+
const previousPage = currentPage()
|
|
127
|
+
await props.onLoadMore()
|
|
128
|
+
if (pageCount() > previousPage + 1) setPage(previousPage + 1)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const errorPresentation = (): { title: string; description: string } => {
|
|
132
|
+
const detail = props.state.error ?? errorMessages.unknown
|
|
133
|
+
const kind: PRListErrorKind = props.state.errorKind ?? "unknown"
|
|
134
|
+
switch (kind) {
|
|
135
|
+
case "authentication":
|
|
136
|
+
return {
|
|
137
|
+
title: "GitHub sign-in failed",
|
|
138
|
+
description: "Run gh auth login or set GITHUB_TOKEN or GH_TOKEN.",
|
|
139
|
+
}
|
|
140
|
+
case "forbidden":
|
|
141
|
+
return {
|
|
142
|
+
title: "Permission denied",
|
|
143
|
+
description: "Give your token read access to this repo.",
|
|
144
|
+
}
|
|
145
|
+
case "rate-limit":
|
|
146
|
+
const retryAt = /(?:resets at|try again at)\s+(.+?)(?:\.)?$/i.exec(detail)?.[1]
|
|
147
|
+
return {
|
|
148
|
+
title: "Rate limit exceeded",
|
|
149
|
+
description: retryAt ? `Try again at ${retryAt.replace(/\.$/, "")}.` : "Wait a little, then try again.",
|
|
150
|
+
}
|
|
151
|
+
case "not-found":
|
|
152
|
+
return {
|
|
153
|
+
title: "Repo not found",
|
|
154
|
+
description: "Check the URL and your access.",
|
|
155
|
+
}
|
|
156
|
+
case "invalid-query":
|
|
157
|
+
return {
|
|
158
|
+
title: "Invalid request",
|
|
159
|
+
description: "Update the plugin, then refresh.",
|
|
160
|
+
}
|
|
161
|
+
case "timeout":
|
|
162
|
+
return {
|
|
163
|
+
title: "Request timed out",
|
|
164
|
+
description: "Try again. Check your connection if it keeps happening.",
|
|
165
|
+
}
|
|
166
|
+
case "network":
|
|
167
|
+
return {
|
|
168
|
+
title: "Cannot reach GitHub",
|
|
169
|
+
description: "Check your internet connection and try again.",
|
|
170
|
+
}
|
|
171
|
+
case "server":
|
|
172
|
+
return {
|
|
173
|
+
title: "GitHub is unavailable",
|
|
174
|
+
description: "Try again in a moment.",
|
|
175
|
+
}
|
|
176
|
+
case "unknown":
|
|
177
|
+
return {
|
|
178
|
+
title: "Couldn't load PRs",
|
|
179
|
+
description: `Try again. Details: ${detail}`,
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<box
|
|
186
|
+
ref={(element) => { view = element }}
|
|
187
|
+
flexDirection="column"
|
|
188
|
+
paddingBottom={1}
|
|
189
|
+
gap={0}
|
|
190
|
+
width="100%"
|
|
191
|
+
>
|
|
192
|
+
<box
|
|
193
|
+
flexDirection="row"
|
|
194
|
+
gap={1}
|
|
195
|
+
paddingLeft={0}
|
|
196
|
+
paddingRight={0}
|
|
197
|
+
>
|
|
198
|
+
<text fg={sk().text}>
|
|
199
|
+
<b>Pull Requests</b>
|
|
200
|
+
</text>
|
|
201
|
+
<box flexGrow={1}></box>
|
|
202
|
+
<box flexDirection="row" gap={1}>
|
|
203
|
+
<box
|
|
204
|
+
flexDirection="row"
|
|
205
|
+
gap={1}
|
|
206
|
+
onMouseOver={() => setScopeHovered(true)}
|
|
207
|
+
onMouseOut={() => setScopeHovered(false)}
|
|
208
|
+
onMouseUp={() => props.onCycleScope()}
|
|
209
|
+
>
|
|
210
|
+
<Show when={props.icons.scope}>
|
|
211
|
+
<text fg={sk().muted} selectable={false}>{props.icons.scope}</text>
|
|
212
|
+
</Show>
|
|
213
|
+
<text fg={scopeHovered() ? sk().accent : sk().muted} selectable={false}>
|
|
214
|
+
{props.scope}
|
|
215
|
+
</text>
|
|
216
|
+
</box>
|
|
217
|
+
<text
|
|
218
|
+
fg={statusHovered() ? sk().accent : sk().muted}
|
|
219
|
+
selectable={false}
|
|
220
|
+
onMouseOver={() => setStatusHovered(true)}
|
|
221
|
+
onMouseOut={() => setStatusHovered(false)}
|
|
222
|
+
onMouseUp={() => props.onCycleStatus()}
|
|
223
|
+
>
|
|
224
|
+
{props.statusFilter}
|
|
225
|
+
</text>
|
|
226
|
+
</box>
|
|
227
|
+
</box>
|
|
228
|
+
|
|
229
|
+
<Show when={props.state.status === DashboardStatus.Loading}>
|
|
230
|
+
<StatusMessage
|
|
231
|
+
icon={props.icons.loading}
|
|
232
|
+
title="Loading PRs"
|
|
233
|
+
titleColor={sk().muted}
|
|
234
|
+
descriptionColor={sk().muted}
|
|
235
|
+
/>
|
|
236
|
+
</Show>
|
|
237
|
+
|
|
238
|
+
<Show when={listingPending() && props.state.status !== DashboardStatus.Loading}>
|
|
239
|
+
<StatusMessage
|
|
240
|
+
icon={props.icons.loading}
|
|
241
|
+
title={scopeListingPending() ? `Loading ${props.scope} PRs` : "Loading PRs"}
|
|
242
|
+
titleColor={sk().muted}
|
|
243
|
+
descriptionColor={sk().muted}
|
|
244
|
+
/>
|
|
245
|
+
</Show>
|
|
246
|
+
|
|
247
|
+
<Show when={props.state.status === DashboardStatus.NoRepo}>
|
|
248
|
+
<StatusMessage
|
|
249
|
+
icon={props.icons.info}
|
|
250
|
+
title="No GitHub repo"
|
|
251
|
+
description="Add a GitHub remote or switch to the right project."
|
|
252
|
+
titleColor={sk().muted}
|
|
253
|
+
descriptionColor={sk().muted}
|
|
254
|
+
/>
|
|
255
|
+
</Show>
|
|
256
|
+
|
|
257
|
+
<Show when={props.state.status === DashboardStatus.Error}>
|
|
258
|
+
<StatusMessage
|
|
259
|
+
icon={props.icons.error}
|
|
260
|
+
title={errorPresentation().title}
|
|
261
|
+
description={errorPresentation().description}
|
|
262
|
+
titleColor={sk().error}
|
|
263
|
+
descriptionColor={sk().muted}
|
|
264
|
+
/>
|
|
265
|
+
</Show>
|
|
266
|
+
|
|
267
|
+
<Show
|
|
268
|
+
when={
|
|
269
|
+
listIsAvailable() &&
|
|
270
|
+
!listingPending() &&
|
|
271
|
+
filtersMatch() &&
|
|
272
|
+
prs().length === 0 &&
|
|
273
|
+
(props.state.status === DashboardStatus.Ok || props.state.prs.length > 0)
|
|
274
|
+
}
|
|
275
|
+
>
|
|
276
|
+
<StatusMessage
|
|
277
|
+
icon={props.icons.info}
|
|
278
|
+
title={errorMessages.noMatchingPRs}
|
|
279
|
+
titleColor={sk().muted}
|
|
280
|
+
descriptionColor={sk().muted}
|
|
281
|
+
/>
|
|
282
|
+
</Show>
|
|
283
|
+
|
|
284
|
+
<Show when={listIsAvailable() && filtersMatch() && prs().length > 0}>
|
|
285
|
+
<box flexDirection="column" gap={0} width="100%">
|
|
286
|
+
<box flexDirection="column" gap={1} paddingTop={1} width="100%">
|
|
287
|
+
<For each={pagePRs()}>
|
|
288
|
+
{(pr, i) => (
|
|
289
|
+
<PRRow
|
|
290
|
+
pr={pr}
|
|
291
|
+
titleWidth={titleWidth()}
|
|
292
|
+
secondaryBackground={sk().panelAlt}
|
|
293
|
+
onClick={(target) => {
|
|
294
|
+
props.setSelectedIdx(currentPage() * props.pageSize + i())
|
|
295
|
+
props.onOpen(pr.number, target)
|
|
296
|
+
}}
|
|
297
|
+
text={sk().text}
|
|
298
|
+
muted={sk().muted}
|
|
299
|
+
pass={sk().success}
|
|
300
|
+
fail={sk().error}
|
|
301
|
+
warn={sk().warning}
|
|
302
|
+
draft={sk().draft}
|
|
303
|
+
merged={sk().merged}
|
|
304
|
+
icons={props.icons}
|
|
305
|
+
spacing={props.spacing}
|
|
306
|
+
showSingleStatusCount={props.showSingleStatusCount}
|
|
307
|
+
/>
|
|
308
|
+
)}
|
|
309
|
+
</For>
|
|
310
|
+
</box>
|
|
311
|
+
<Show when={pageCount() > 1 || (filtersMatch() && props.state.pagination.hasMore)}>
|
|
312
|
+
<box
|
|
313
|
+
flexDirection="row"
|
|
314
|
+
justifyContent="flex-end"
|
|
315
|
+
gap={1}
|
|
316
|
+
paddingTop={1}
|
|
317
|
+
paddingRight={1}
|
|
318
|
+
width="100%"
|
|
319
|
+
>
|
|
320
|
+
<box
|
|
321
|
+
width={Bun.stringWidth(props.icons.previousPage) + 2}
|
|
322
|
+
marginLeft={-1}
|
|
323
|
+
marginRight={-1}
|
|
324
|
+
flexDirection="row"
|
|
325
|
+
justifyContent="center"
|
|
326
|
+
alignItems="center"
|
|
327
|
+
onMouseOver={() => canGoPrevious() && setPreviousHovered(true)}
|
|
328
|
+
onMouseOut={() => setPreviousHovered(false)}
|
|
329
|
+
onMouseUp={() => canGoPrevious() && setPage(currentPage() - 1)}
|
|
330
|
+
>
|
|
331
|
+
<text
|
|
332
|
+
fg={canGoPrevious() && previousHovered() ? sk().accent : sk().muted}
|
|
333
|
+
selectable={false}
|
|
334
|
+
>
|
|
335
|
+
{props.icons.previousPage}
|
|
336
|
+
</text>
|
|
337
|
+
</box>
|
|
338
|
+
<text fg={sk().muted} selectable={false}>
|
|
339
|
+
{`${currentPage() + 1} of ${totalPageCount() ?? pageCount()}${totalPageCount() === null && filtersMatch() && props.state.pagination.hasMore ? "+" : ""}`}
|
|
340
|
+
</text>
|
|
341
|
+
<box
|
|
342
|
+
width={Bun.stringWidth(props.icons.nextPage) + 2}
|
|
343
|
+
marginLeft={-1}
|
|
344
|
+
marginRight={-1}
|
|
345
|
+
flexDirection="row"
|
|
346
|
+
justifyContent="center"
|
|
347
|
+
alignItems="center"
|
|
348
|
+
onMouseOver={() => canGoNext() && setNextHovered(true)}
|
|
349
|
+
onMouseOut={() => setNextHovered(false)}
|
|
350
|
+
onMouseUp={() => canGoNext() && void goNext()}
|
|
351
|
+
>
|
|
352
|
+
<text
|
|
353
|
+
fg={canGoNext() && nextHovered() ? sk().accent : sk().muted}
|
|
354
|
+
selectable={false}
|
|
355
|
+
>
|
|
356
|
+
{props.icons.nextPage}
|
|
357
|
+
</text>
|
|
358
|
+
</box>
|
|
359
|
+
</box>
|
|
360
|
+
</Show>
|
|
361
|
+
<Show when={filtersMatch() && props.state.pagination.limitReached}>
|
|
362
|
+
<StatusMessage
|
|
363
|
+
icon={props.icons.info}
|
|
364
|
+
title="GitHub search is limited to 1,000 matching PRs"
|
|
365
|
+
titleColor={sk().muted}
|
|
366
|
+
descriptionColor={sk().muted}
|
|
367
|
+
/>
|
|
368
|
+
</Show>
|
|
369
|
+
</box>
|
|
370
|
+
</Show>
|
|
371
|
+
</box>
|
|
372
|
+
)
|
|
373
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/** @jsxImportSource @opentui/solid */
|
|
2
|
+
import { createSignal, For, Show } from "solid-js"
|
|
3
|
+
import type { PR, PRLinkTarget } from "../domain/types"
|
|
4
|
+
import { truncateTitle } from "../domain/format"
|
|
5
|
+
import {
|
|
6
|
+
checkStatusGroups,
|
|
7
|
+
commentThreadCounts,
|
|
8
|
+
mergeReadiness,
|
|
9
|
+
reviewStatusGroups,
|
|
10
|
+
type StatusCategory,
|
|
11
|
+
} from "../domain/pr-status"
|
|
12
|
+
import type { DashboardSpacing } from "./config"
|
|
13
|
+
|
|
14
|
+
function statusColor(status: StatusCategory, props: {
|
|
15
|
+
pass: string
|
|
16
|
+
fail: string
|
|
17
|
+
warn: string
|
|
18
|
+
muted: string
|
|
19
|
+
}): string {
|
|
20
|
+
return {
|
|
21
|
+
pass: props.pass,
|
|
22
|
+
fail: props.fail,
|
|
23
|
+
pending: props.warn,
|
|
24
|
+
neutral: props.muted,
|
|
25
|
+
none: props.muted,
|
|
26
|
+
}[status]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function ClickableText(props: {
|
|
30
|
+
label: string
|
|
31
|
+
color: string
|
|
32
|
+
target: PRLinkTarget
|
|
33
|
+
onClick: (target: PRLinkTarget) => void
|
|
34
|
+
}) {
|
|
35
|
+
const [hovered, setHovered] = createSignal(false)
|
|
36
|
+
return (
|
|
37
|
+
<text
|
|
38
|
+
fg={props.color}
|
|
39
|
+
selectable={false}
|
|
40
|
+
onMouseOver={(event) => {
|
|
41
|
+
event.stopPropagation()
|
|
42
|
+
setHovered(true)
|
|
43
|
+
}}
|
|
44
|
+
onMouseOut={(event) => {
|
|
45
|
+
event.stopPropagation()
|
|
46
|
+
setHovered(false)
|
|
47
|
+
}}
|
|
48
|
+
onMouseUp={(event) => {
|
|
49
|
+
event.stopPropagation()
|
|
50
|
+
props.onClick(props.target)
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
{hovered() ? <u>{props.label}</u> : props.label}
|
|
54
|
+
</text>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function ClickableIndicator(props: {
|
|
59
|
+
icon: string
|
|
60
|
+
count?: number | string
|
|
61
|
+
gap: number
|
|
62
|
+
color: string
|
|
63
|
+
target: PRLinkTarget
|
|
64
|
+
onClick: (target: PRLinkTarget) => void
|
|
65
|
+
}) {
|
|
66
|
+
const [hovered, setHovered] = createSignal(false)
|
|
67
|
+
return (
|
|
68
|
+
<box
|
|
69
|
+
flexDirection="row"
|
|
70
|
+
gap={props.count === undefined ? 0 : props.gap}
|
|
71
|
+
onMouseOver={(event) => {
|
|
72
|
+
event.stopPropagation()
|
|
73
|
+
setHovered(true)
|
|
74
|
+
}}
|
|
75
|
+
onMouseOut={(event) => {
|
|
76
|
+
event.stopPropagation()
|
|
77
|
+
setHovered(false)
|
|
78
|
+
}}
|
|
79
|
+
onMouseUp={(event) => {
|
|
80
|
+
event.stopPropagation()
|
|
81
|
+
props.onClick(props.target)
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
<text fg={props.color} selectable={false}>
|
|
85
|
+
{hovered() ? <u>{props.icon}</u> : props.icon}
|
|
86
|
+
</text>
|
|
87
|
+
<Show when={props.count !== undefined}>
|
|
88
|
+
<text fg={props.color} selectable={false}>
|
|
89
|
+
{hovered() ? <u>{props.count}</u> : props.count}
|
|
90
|
+
</text>
|
|
91
|
+
</Show>
|
|
92
|
+
</box>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function PRRow(props: {
|
|
97
|
+
pr: PR
|
|
98
|
+
titleWidth: number
|
|
99
|
+
secondaryBackground: string
|
|
100
|
+
onClick: (target: PRLinkTarget) => void
|
|
101
|
+
text: string
|
|
102
|
+
muted: string
|
|
103
|
+
pass: string
|
|
104
|
+
fail: string
|
|
105
|
+
warn: string
|
|
106
|
+
draft: string
|
|
107
|
+
merged: string
|
|
108
|
+
icons: {
|
|
109
|
+
openPR: string
|
|
110
|
+
closedPR: string
|
|
111
|
+
draftPR: string
|
|
112
|
+
mergedPR: string
|
|
113
|
+
review: string
|
|
114
|
+
openComment: string
|
|
115
|
+
check: string
|
|
116
|
+
}
|
|
117
|
+
spacing: DashboardSpacing
|
|
118
|
+
showSingleStatusCount: boolean
|
|
119
|
+
}) {
|
|
120
|
+
const [titleHovered, setTitleHovered] = createSignal(false)
|
|
121
|
+
const title = () => truncateTitle(props.pr.title, props.titleWidth)
|
|
122
|
+
const icon = () => props.pr.isMerged
|
|
123
|
+
? props.icons.mergedPR
|
|
124
|
+
: props.pr.isDraft
|
|
125
|
+
? props.icons.draftPR
|
|
126
|
+
: props.pr.isClosed
|
|
127
|
+
? props.icons.closedPR
|
|
128
|
+
: props.icons.openPR
|
|
129
|
+
const iconColor = () => props.pr.isMerged
|
|
130
|
+
? props.merged
|
|
131
|
+
: props.pr.isDraft
|
|
132
|
+
? props.draft
|
|
133
|
+
: statusColor(mergeReadiness(props.pr), props)
|
|
134
|
+
const checks = () => checkStatusGroups(props.pr)
|
|
135
|
+
const reviews = () => reviewStatusGroups(props.pr)
|
|
136
|
+
const comments = () => commentThreadCounts(props.pr)
|
|
137
|
+
const commentStatuses = () => {
|
|
138
|
+
const open = comments()?.open
|
|
139
|
+
const truncated = comments()?.truncated
|
|
140
|
+
return open ? [{ icon: props.icons.openComment, count: `${open}${truncated ? "+" : ""}` }] : []
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<box
|
|
145
|
+
flexDirection="column"
|
|
146
|
+
width="100%"
|
|
147
|
+
paddingLeft={0}
|
|
148
|
+
paddingRight={0}
|
|
149
|
+
>
|
|
150
|
+
<box
|
|
151
|
+
flexDirection="row"
|
|
152
|
+
gap={1}
|
|
153
|
+
width="100%"
|
|
154
|
+
onMouseOver={() => setTitleHovered(true)}
|
|
155
|
+
onMouseOut={() => setTitleHovered(false)}
|
|
156
|
+
onMouseUp={() => props.onClick("overview")}
|
|
157
|
+
>
|
|
158
|
+
<ClickableText
|
|
159
|
+
label={icon()}
|
|
160
|
+
color={iconColor()}
|
|
161
|
+
target="mergeStatus"
|
|
162
|
+
onClick={props.onClick}
|
|
163
|
+
/>
|
|
164
|
+
<text fg={props.text} selectable={false} height={1} wrapMode="none">
|
|
165
|
+
{titleHovered() ? <u>{title()}</u> : title()}
|
|
166
|
+
</text>
|
|
167
|
+
</box>
|
|
168
|
+
<box flexDirection="row" gap={1} paddingLeft={2} width="100%" backgroundColor={props.secondaryBackground}>
|
|
169
|
+
<ClickableText
|
|
170
|
+
label={`#${props.pr.number}`}
|
|
171
|
+
color={props.muted}
|
|
172
|
+
target="overview"
|
|
173
|
+
onClick={props.onClick}
|
|
174
|
+
/>
|
|
175
|
+
<ClickableText
|
|
176
|
+
label={`+${props.pr.additions}`}
|
|
177
|
+
color={props.pass}
|
|
178
|
+
target="files"
|
|
179
|
+
onClick={props.onClick}
|
|
180
|
+
/>
|
|
181
|
+
<ClickableText
|
|
182
|
+
label={`-${props.pr.deletions}`}
|
|
183
|
+
color={props.fail}
|
|
184
|
+
target="files"
|
|
185
|
+
onClick={props.onClick}
|
|
186
|
+
/>
|
|
187
|
+
<box flexGrow={1}></box>
|
|
188
|
+
<box flexDirection="row" gap={props.spacing.differentTypeGroups}>
|
|
189
|
+
<Show when={commentStatuses().length > 0}>
|
|
190
|
+
<For each={commentStatuses()}>
|
|
191
|
+
{(comment) => (
|
|
192
|
+
<ClickableIndicator
|
|
193
|
+
icon={comment.icon}
|
|
194
|
+
count={comment.count}
|
|
195
|
+
gap={props.spacing.iconToCount}
|
|
196
|
+
color={props.muted}
|
|
197
|
+
target="files"
|
|
198
|
+
onClick={props.onClick}
|
|
199
|
+
/>
|
|
200
|
+
)}
|
|
201
|
+
</For>
|
|
202
|
+
</Show>
|
|
203
|
+
<Show when={reviews().length > 0}>
|
|
204
|
+
<box flexDirection="row" gap={props.spacing.sameTypeGroups}>
|
|
205
|
+
<For each={reviews()}>
|
|
206
|
+
{(group) => (
|
|
207
|
+
<ClickableIndicator
|
|
208
|
+
icon={props.icons.review}
|
|
209
|
+
count={reviews().length > 1 || (props.showSingleStatusCount && group.count > 0)
|
|
210
|
+
? group.count
|
|
211
|
+
: undefined}
|
|
212
|
+
gap={props.spacing.iconToCount}
|
|
213
|
+
color={statusColor(group.status, props)}
|
|
214
|
+
target="overview"
|
|
215
|
+
onClick={props.onClick}
|
|
216
|
+
/>
|
|
217
|
+
)}
|
|
218
|
+
</For>
|
|
219
|
+
</box>
|
|
220
|
+
</Show>
|
|
221
|
+
<box flexDirection="row" gap={props.spacing.sameTypeGroups}>
|
|
222
|
+
<For each={checks()}>
|
|
223
|
+
{(group) => (
|
|
224
|
+
<ClickableIndicator
|
|
225
|
+
icon={props.icons.check}
|
|
226
|
+
count={checks().length > 1 || (props.showSingleStatusCount && group.count > 0)
|
|
227
|
+
? group.count
|
|
228
|
+
: undefined}
|
|
229
|
+
gap={props.spacing.iconToCount}
|
|
230
|
+
color={statusColor(group.status, props)}
|
|
231
|
+
target="checks"
|
|
232
|
+
onClick={props.onClick}
|
|
233
|
+
/>
|
|
234
|
+
)}
|
|
235
|
+
</For>
|
|
236
|
+
</box>
|
|
237
|
+
</box>
|
|
238
|
+
</box>
|
|
239
|
+
</box>
|
|
240
|
+
)
|
|
241
|
+
}
|