rvlib-shipkit 2.9.0 → 2.11.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/CHANGELOG.md +23 -0
- package/package.json +1 -1
- package/src/cli/cmd_Media.ts +164 -0
- package/src/cli/cmd_Review.ts +2 -1
- package/src/cli/family-pages.ts +1 -0
- package/src/cli/registry.ts +2 -0
- package/src/collections/pings.ts +6 -4
- package/src/core/app-icon.ts +17 -4
- package/src/core/scratch-objects.ts +56 -0
- package/src/core/trace-audit.ts +13 -1
- package/src/home/home-paths.ts +4 -0
- package/src/home/home-routes.ts +36 -2
- package/src/home/hubs.ts +5 -0
- package/src/home/inbox-shape.ts +182 -0
- package/src/home/inbox.ts +48 -0
- package/src/home/run-daemon.ts +12 -2
- package/src/home/serve-web.ts +155 -16
- package/src/ledger/git-scan.ts +73 -25
- package/src/ledger/repo-view.ts +2 -22
- package/src/media-kinds.ts +7 -0
- package/src/media-store/content.ts +51 -0
- package/src/media-store/daemon.ts +91 -0
- package/src/media-store/db.ts +74 -0
- package/src/media-store/fact.ts +9 -0
- package/src/media-store/kind.ts +44 -0
- package/src/media-store/purge.ts +139 -0
- package/src/media-store/remote.ts +93 -0
- package/src/media-store/space.ts +124 -0
- package/src/media-store/sync.ts +101 -0
- package/src/media-store/upload.ts +98 -0
- package/src/repo-config.ts +4 -0
- package/src/review/anim.ts +6 -5
- package/src/review/cells.ts +552 -0
- package/src/review/format.ts +1 -1
- package/src/review/media-kind.ts +84 -0
- package/src/review/media-read.ts +48 -0
- package/src/review/model.ts +43 -5
- package/src/review/previews.ts +153 -0
- package/src/review/routes.ts +105 -47
- package/src/review/store.ts +106 -45
- package/src/review/trailer-desk.ts +79 -46
- package/src/review/trailer-media.ts +163 -0
- package/src/review/trailer-routes.ts +5 -2
- package/src/serve/hub-app/home-st.ts +39 -9
- package/src/serve/hub-app/home.html +2 -1
- package/src/serve/hub-app/hub-app.tsx +7 -23
- package/src/serve/hub-app/icons.tsx +2 -0
- package/src/serve/hub-app/inbox-st.ts +144 -0
- package/src/serve/hub-app/inbox-view.tsx +205 -0
- package/src/serve/hub-app/inbox.css +73 -0
- package/src/serve/hub-app/item-view.tsx +19 -0
- package/src/serve/hub-app/keys.ts +4 -3
- package/src/serve/hub-app/palette-st.ts +2 -1
- package/src/serve/hub-app/project-list.tsx +1 -0
- package/src/serve/hub-app/projects-svc.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +1 -1
- package/src/serve/hub-app/review/kind-view.tsx +21 -22
- package/src/serve/hub-app/review/kit.tsx +11 -12
- package/src/serve/hub-app/review/review-board.tsx +15 -13
- package/src/serve/hub-app/review/review-cells.tsx +241 -0
- package/src/serve/hub-app/review/review-kit.ts +79 -0
- package/src/serve/hub-app/review/review-list.tsx +87 -122
- package/src/serve/hub-app/review/review-page.tsx +22 -79
- package/src/serve/hub-app/review/review-st.ts +269 -698
- package/src/serve/hub-app/review/review-thread.tsx +302 -0
- package/src/serve/hub-app/review/review-views.tsx +322 -253
- package/src/serve/hub-app/review/thread-st.ts +770 -0
- package/src/serve/hub-app/review.css +235 -91
- package/src/serve/hub-runtime.ts +9 -4
- package/src/serve/serve-hub.ts +4 -1
- package/src/serve/warm-cell.ts +6 -1
- package/src/trailer/footage.ts +6 -2
- package/src/trailer/passage.ts +4 -2
- package/src/trailer/prune.ts +6 -10
- package/src/serve/hub-app/review/review-answer.tsx +0 -249
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// the review page's plumbing, no mobx and no view: the browser's storage, a polled loader that keeps its last answer
|
|
2
|
+
// on « not modified », a json post, the clipboard
|
|
3
|
+
import { reach } from '../reach.ts'
|
|
4
|
+
|
|
5
|
+
/** the zoom of a view: fit the column (and the window's height), or a share of the image's own pixels */
|
|
6
|
+
export const ZOOMS = ['fit', '1', '1.5', '2'] as const
|
|
7
|
+
export type Zoom = (typeof ZOOMS)[number]
|
|
8
|
+
|
|
9
|
+
/** what a reload must not lose: a blocked storage only loses persistence */
|
|
10
|
+
export const kept = {
|
|
11
|
+
get(k: string): string | null {
|
|
12
|
+
try {
|
|
13
|
+
return localStorage.getItem(k)
|
|
14
|
+
} catch {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
put(k: string, v: string | null): void {
|
|
19
|
+
try {
|
|
20
|
+
if (v === null) localStorage.removeItem(k)
|
|
21
|
+
else localStorage.setItem(k, v)
|
|
22
|
+
} catch {
|
|
23
|
+
// as above
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** a loader for a polled url: it sends the tag of its last answer for that same url, and on « not modified » gives
|
|
29
|
+
* that answer again (the same object, so nothing draws again). A tag is the store's index build, the same for every
|
|
30
|
+
* url, so it is only sent back to the url that answered it */
|
|
31
|
+
export function etagLoader<T>(url: () => string): () => Promise<T> {
|
|
32
|
+
let last: { url: string; tag: string; value: T } | null = null
|
|
33
|
+
return async () => {
|
|
34
|
+
const u = url()
|
|
35
|
+
const held = last?.url === u ? last : null
|
|
36
|
+
const res = await reach(u, { cache: 'no-store', headers: held ? { 'If-None-Match': held.tag } : {} })
|
|
37
|
+
if (res.status === 304 && held) return held.value
|
|
38
|
+
if (!res.ok) throw new Error(`${u}: HTTP ${res.status} ${await res.text().catch(() => '')}`.trim())
|
|
39
|
+
const value = (await res.json()) as T
|
|
40
|
+
const tag = res.headers.get('ETag')
|
|
41
|
+
last = tag ? { url: u, tag, value } : null
|
|
42
|
+
return value
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function postJson<T>(url: string, body: unknown): Promise<T> {
|
|
47
|
+
const res = await reach(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })
|
|
48
|
+
const text = await res.text()
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
let msg = text
|
|
51
|
+
try {
|
|
52
|
+
msg = (JSON.parse(text) as { error?: string }).error ?? text
|
|
53
|
+
} catch {
|
|
54
|
+
// a plain text answer says it already
|
|
55
|
+
}
|
|
56
|
+
throw new Error(msg || `HTTP ${res.status}`)
|
|
57
|
+
}
|
|
58
|
+
return JSON.parse(text) as T
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** a text to the clipboard: the clipboard api, else (a page over plain http, the phone through a public host) the old
|
|
62
|
+
* copy command on a hidden field */
|
|
63
|
+
export async function copyText(text: string): Promise<boolean> {
|
|
64
|
+
try {
|
|
65
|
+
await navigator.clipboard.writeText(text)
|
|
66
|
+
return true
|
|
67
|
+
} catch {
|
|
68
|
+
const el = document.createElement('textarea')
|
|
69
|
+
el.value = text
|
|
70
|
+
el.setAttribute('readonly', '')
|
|
71
|
+
el.style.position = 'fixed'
|
|
72
|
+
el.style.opacity = '0'
|
|
73
|
+
document.body.appendChild(el)
|
|
74
|
+
el.select()
|
|
75
|
+
const ok = document.execCommand('copy')
|
|
76
|
+
el.remove()
|
|
77
|
+
return ok
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,156 +1,121 @@
|
|
|
1
|
-
// the review page's left column: the search and the filters, one
|
|
1
|
+
// the review page's left column: the search and the filters (asked of the server), one row per thread, a page more
|
|
2
|
+
// when the list's end scrolls into view
|
|
2
3
|
import { observer } from 'mobx-react-lite'
|
|
3
4
|
import { useEffect, useRef } from 'react'
|
|
4
|
-
import
|
|
5
|
-
import type
|
|
5
|
+
import type { ThreadRow } from '../../../review/cells.ts'
|
|
6
|
+
import { MOVE_LABEL, STATUS_LABEL, subjectLabel, type Move, type ShownStatus } from '../../../review/model.ts'
|
|
6
7
|
import { AutoTag, LaneTag, laneColor, Listeners, Rework, ThumbOf, toneOf } from './kit.tsx'
|
|
7
8
|
import { ReviewBoard } from './review-board.tsx'
|
|
8
9
|
import type { ReviewSt } from './review-st.ts'
|
|
9
|
-
import { Caret } from '../tree-row.tsx'
|
|
10
10
|
|
|
11
11
|
const ALL = ''
|
|
12
12
|
|
|
13
|
-
export const ReviewList = observer(({ rv }: { rv: ReviewSt }) =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<div className="rv-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
</
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</div>
|
|
42
|
-
<div className="rv-count">
|
|
43
|
-
{rv.activeCount} active · {rv.pendingCount} waiting{rv.hideHandled ? '' : ` · ${shown.length} / ${rv.threads.length} threads`}
|
|
44
|
-
</div>
|
|
13
|
+
export const ReviewList = observer(({ rv }: { rv: ReviewSt }) => (
|
|
14
|
+
<div className="rv-listcol">
|
|
15
|
+
<div className="rv-filters">
|
|
16
|
+
<input className="rv-search" placeholder="search every version and message" aria-label="search the cards" value={rv.query} onChange={(e) => rv.setQuery(e.currentTarget.value)}
|
|
17
|
+
onKeyDown={(e) => { if (e.key === 'Escape') { rv.setQuery(''); e.currentTarget.blur() } }} />
|
|
18
|
+
<div className="rv-selects">
|
|
19
|
+
<select aria-label="subject" value={rv.subject ?? ALL} onChange={(e) => rv.setFilter({ subject: e.currentTarget.value === ALL ? null : e.currentTarget.value })}>
|
|
20
|
+
<option value={ALL}>every subject</option>
|
|
21
|
+
{rv.subjects.map((k) => <option key={k} value={k}>{subjectLabel(k, rv.spec ?? undefined)}</option>)}
|
|
22
|
+
</select>
|
|
23
|
+
<select aria-label="state" value={rv.status ?? ALL} onChange={(e) => rv.setFilter({ status: e.currentTarget.value === ALL ? null : (e.currentTarget.value as ShownStatus) })}>
|
|
24
|
+
<option value={ALL}>every state</option>
|
|
25
|
+
{(Object.keys(STATUS_LABEL) as ShownStatus[]).map((s) => <option key={s} value={s}>{STATUS_LABEL[s]}</option>)}
|
|
26
|
+
</select>
|
|
27
|
+
</div>
|
|
28
|
+
<span className="seg rv-whose" aria-label="whose move">
|
|
29
|
+
<button className={rv.whose === null ? 'on' : ''} onClick={() => rv.setFilter({ whose: null })}>all</button>
|
|
30
|
+
{(['owner', 'agents', 'none'] as const).map((m: Move) => (
|
|
31
|
+
<button key={m} className={rv.whose === m ? 'on' : ''} onClick={() => rv.setFilter({ whose: m })}>{MOVE_LABEL[m]}</button>
|
|
32
|
+
))}
|
|
33
|
+
</span>
|
|
34
|
+
<div className="rv-switches">
|
|
35
|
+
<label className="rv-switch"><input type="checkbox" checked={rv.hideHandled} onChange={(e) => rv.setHideHandled(e.currentTarget.checked)} />hide handled</label>
|
|
36
|
+
<label className="rv-switch"><input type="checkbox" checked={rv.byLane} onChange={(e) => rv.setByLane(e.currentTarget.checked)} />by lane</label>
|
|
37
|
+
{rv.spec?.dispatcher ? <label className="rv-switch"><input type="checkbox" checked={rv.board} onChange={(e) => rv.setBoard(e.currentTarget.checked)} />board</label> : null}
|
|
38
|
+
</div>
|
|
39
|
+
<div className="rv-count">
|
|
40
|
+
{rv.activeCount} active · {rv.pendingCount} waiting{rv.page ? ` · ${rv.page.total} shown of ${rv.page.counts.threads} threads` : ''}
|
|
45
41
|
</div>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
</div>
|
|
43
|
+
{rv.board && rv.spec?.dispatcher ? <ReviewBoard rv={rv} /> : <Rows rv={rv} />}
|
|
44
|
+
</div>
|
|
45
|
+
))
|
|
46
|
+
|
|
47
|
+
const Rows = observer(({ rv }: { rv: ReviewSt }) => {
|
|
48
|
+
const open = rv.openRow
|
|
49
|
+
return (
|
|
50
|
+
<div className="rv-listscroll">
|
|
51
|
+
{rv.byLane
|
|
52
|
+
? rv.laneGroups.map((g) => (
|
|
53
|
+
<div key={g.lane ?? ''}>
|
|
54
|
+
<LaneHeader rv={rv} lane={g.lane} rows={g.rows} />
|
|
55
|
+
{g.rows.map((r) => <Row key={r.head} rv={rv} r={r} on={r === open} />)}
|
|
56
|
+
</div>
|
|
57
|
+
))
|
|
58
|
+
: rv.rows.map((r) => <Row key={r.head} rv={rv} r={r} on={r === open} />)}
|
|
59
|
+
{rv.page && rv.rows.length === 0 ? (
|
|
60
|
+
<div className="rv-empty">{rv.page.counts.threads === 0 ? 'No card yet. An agent sends one with sk review add.' : rv.hideHandled && !rv.q ? 'Nothing active: « hide handled » hides the handled threads.' : 'No card matches.'}</div>
|
|
61
|
+
) : null}
|
|
62
|
+
{rv.more > 0 ? <More rv={rv} /> : null}
|
|
63
|
+
{rv.page === null && rv.listError === null ? <div className="rv-empty"><span className="spin" /> reading the cards…</div> : null}
|
|
64
|
+
{rv.listError !== null ? <div className="rv-err">{rv.listError}</div> : null}
|
|
65
|
+
{rv.broken.map((b) => <div key={b.id} className="rv-err">unreadable: {b.id} ({b.error})</div>)}
|
|
62
66
|
</div>
|
|
63
67
|
)
|
|
64
68
|
})
|
|
65
69
|
|
|
66
|
-
|
|
70
|
+
/** the next page: asked when it scrolls into view, or on a click */
|
|
71
|
+
const More = observer(({ rv }: { rv: ReviewSt }) => {
|
|
72
|
+
const el = useRef<HTMLButtonElement>(null)
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
const b = el.current
|
|
75
|
+
if (!b || typeof IntersectionObserver === 'undefined') return
|
|
76
|
+
const io = new IntersectionObserver(([e]) => e?.isIntersecting && rv.showMore(), { rootMargin: '200px' })
|
|
77
|
+
io.observe(b)
|
|
78
|
+
return () => io.disconnect()
|
|
79
|
+
}, [rv])
|
|
80
|
+
return <button ref={el} className="ghost rv-more" onClick={() => rv.showMore()}>{rv.more} more</button>
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const LaneHeader = observer(({ rv, lane, rows }: { rv: ReviewSt; lane: string | null; rows: readonly ThreadRow[] }) => (
|
|
67
84
|
<div className="rv-lanehead" style={lane ? { ['--lane' as string]: laneColor(lane) } : undefined}>
|
|
68
85
|
<b>{lane ?? 'no lane'}</b>
|
|
69
|
-
<span className="rv-dim">{
|
|
86
|
+
<span className="rv-dim">{rows.length}</span>
|
|
70
87
|
<span className="sp" />
|
|
71
|
-
<Listeners rv={rv}
|
|
88
|
+
<Listeners rv={rv} heads={rows} />
|
|
72
89
|
</div>
|
|
73
90
|
))
|
|
74
91
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
const unfolded = older.length > 0 && rv.showsVersions(t)
|
|
78
|
-
const n = t.versions.length
|
|
79
|
-
return (
|
|
80
|
-
<>
|
|
81
|
-
<ReviewRow rv={rv} x={t.head} on={t.head.item.id === openId} unread={rv.unread(t)} version={n}
|
|
82
|
-
fold={older.length > 0 ? { open: unfolded, toggle: () => rv.fold(t.head.item.id) } : undefined} />
|
|
83
|
-
{unfolded ? older.map((x, i) => <VersionRow key={x.item.id} rv={rv} x={x} n={n - 1 - i} on={x.item.id === openId} />) : null}
|
|
84
|
-
</>
|
|
85
|
-
)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
const laneStyle = (x: ReviewItem): React.CSSProperties | undefined => {
|
|
89
|
-
const lane = laneOf(x)
|
|
90
|
-
return lane ? { ['--lane' as string]: laneColor(lane) } : undefined
|
|
91
|
-
}
|
|
92
|
+
const ABOUT = (r: ThreadRow, rv: ReviewSt): string =>
|
|
93
|
+
[subjectLabel(r.subject, rv.spec ?? undefined), r.choice ? 'choice' : '', r.clip ? 'clip' : '', r.pair ? 'before/after' : '', r.views > 1 ? `${r.views} views` : ''].filter(Boolean).join(' · ')
|
|
92
94
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
const lane = laneOf(x)
|
|
97
|
-
return (
|
|
98
|
-
<div className={`rv-vrow ${toneOf(status)}${on ? ' on' : ''}${lane ? ' laned' : ''}`} style={laneStyle(x)} onClick={() => rv.pick(x.item.id)}>
|
|
99
|
-
<div className="rv-thumb sm"><ThumbOf rv={rv} x={x} /></div>
|
|
100
|
-
<b className="rv-vn">v{n}</b>
|
|
101
|
-
<span className="rv-badge">{STATUS_LABEL[status]}</span>
|
|
102
|
-
{lane ? <LaneTag lane={lane} /> : null}
|
|
103
|
-
{x.item.origin.by === 'auto' ? <AutoTag rule={x.item.origin.rule} /> : null}
|
|
104
|
-
<span className="rv-vtitle">{x.item.title}</span>
|
|
105
|
-
</div>
|
|
106
|
-
)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
const ReviewRow = observer(({ rv, x, on, version, unread, fold }: {
|
|
110
|
-
rv: ReviewSt
|
|
111
|
-
x: ReviewItem
|
|
112
|
-
on: boolean
|
|
113
|
-
version: number
|
|
114
|
-
unread: boolean
|
|
115
|
-
fold: { open: boolean; toggle: () => void } | undefined
|
|
116
|
-
}) => {
|
|
117
|
-
const r = x.item
|
|
118
|
-
const status = rv.statusOf(x)
|
|
119
|
-
const rework = rv.reworkOf(x)
|
|
120
|
-
// handled by the agent: its answer marked seen, or a newer version sent; never while a lane reworks it
|
|
121
|
-
const muted = !on && !rework && (verdictOf(x)?.seen === true || status === 'superseded' || status === 'withdrawn')
|
|
122
|
-
const lane = laneOf(x)
|
|
95
|
+
const Row = observer(({ rv, r, on }: { rv: ReviewSt; r: ThreadRow; on: boolean }) => {
|
|
96
|
+
// handled: nobody owes anything on it, and no lane reworks it
|
|
97
|
+
const muted = !on && !r.active
|
|
123
98
|
const ref = useRef<HTMLDivElement>(null)
|
|
124
99
|
useEffect(() => {
|
|
125
100
|
if (on) ref.current?.scrollIntoView({ block: 'nearest' })
|
|
126
101
|
}, [on])
|
|
127
|
-
const first = firstView(r)
|
|
128
102
|
return (
|
|
129
|
-
<div ref={ref} className={`rv-row ${toneOf(status)}${on ? ' on' : ''}${muted ? ' muted' : ''}${lane ? ' laned' : ''}`} style={
|
|
130
|
-
<div className="rv-thumb"><ThumbOf rv={rv}
|
|
103
|
+
<div ref={ref} className={`rv-row ${toneOf(r.status)}${on ? ' on' : ''}${muted ? ' muted' : ''}${r.lane ? ' laned' : ''}`} style={r.lane ? { ['--lane' as string]: laneColor(r.lane) } : undefined} onClick={() => rv.pick(r.head)}>
|
|
104
|
+
<div className="rv-thumb"><ThumbOf rv={rv} row={r} /></div>
|
|
131
105
|
<div className="rv-rowbody">
|
|
132
|
-
<div className={`rv-rowtitle${on ||
|
|
133
|
-
{unread ? <span className="rv-unread" title="a message of the agent to read" /> : null}
|
|
106
|
+
<div className={`rv-rowtitle${on || r.waits ? ' strong' : ''}`}>
|
|
107
|
+
{r.unread ? <span className="rv-unread" title="a message of the agent to read" /> : null}
|
|
134
108
|
{r.title}
|
|
135
109
|
</div>
|
|
136
110
|
<div className="rv-rowmeta">
|
|
137
|
-
<span className="rv-badge">{STATUS_LABEL[status]}</span>
|
|
138
|
-
{
|
|
139
|
-
{lane ? <LaneTag lane={lane} /> : null}
|
|
140
|
-
{r.
|
|
141
|
-
<span className="rv-about">
|
|
142
|
-
{aboutText(r, rv.spec ?? undefined)}
|
|
143
|
-
{r.views.some((v) => !isGallery(v) && v.clip) ? ' · clip' : ''}
|
|
144
|
-
{first && isPair(first.files) ? ' · before/after' : ''}
|
|
145
|
-
</span>
|
|
111
|
+
<span className="rv-badge">{STATUS_LABEL[r.status]}</span>
|
|
112
|
+
{r.versions > 1 ? <span className="rv-badge outline" title={`${r.versions} versions in this thread`}>v{r.versions}</span> : null}
|
|
113
|
+
{r.lane ? <LaneTag lane={r.lane} /> : null}
|
|
114
|
+
{r.rule ? <AutoTag rule={r.rule} /> : null}
|
|
115
|
+
<span className="rv-about">{ABOUT(r, rv)}</span>
|
|
146
116
|
</div>
|
|
147
|
-
<Rework
|
|
117
|
+
<Rework r={r.rework} />
|
|
148
118
|
</div>
|
|
149
|
-
{fold ? (
|
|
150
|
-
<button className="rv-fold" aria-label={fold.open ? 'fold the versions' : 'unfold the versions'} onClick={(e) => { e.stopPropagation(); fold.toggle() }}>
|
|
151
|
-
<Caret open={fold.open} />
|
|
152
|
-
</button>
|
|
153
|
-
) : null}
|
|
154
119
|
</div>
|
|
155
120
|
)
|
|
156
121
|
})
|
|
@@ -1,117 +1,60 @@
|
|
|
1
1
|
// a repo's review page (`#page:review`, wiki build/shipkit/review.md, The review page): the cards on the left, the open
|
|
2
|
-
// one
|
|
3
|
-
//
|
|
4
|
-
// views, then its answer), the verdicts in a bar under the thumb. Another card opens at its top. The list is read while
|
|
5
|
-
// the page shows
|
|
2
|
+
// one as a chat on the right (review-thread.tsx). On a phone one pane at a time: the cards, or the card with its answer
|
|
3
|
+
// box and the verdicts under the thumb. Everything is read while the page shows
|
|
6
4
|
import { observer } from 'mobx-react-lite'
|
|
7
|
-
import { useEffect
|
|
5
|
+
import { useEffect } from 'react'
|
|
8
6
|
import { Group, Panel, Separator } from 'react-resizable-panels'
|
|
9
7
|
import type { RepoSt } from '../repo-st.ts'
|
|
10
|
-
import { ReviewForm, VerdictBar } from './review-answer.tsx'
|
|
11
8
|
import { ReviewList } from './review-list.tsx'
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
const PANE_LABEL: Record<PhonePane, string> = { list: 'cards', card: 'card' }
|
|
9
|
+
import type { ReviewSt } from './review-st.ts'
|
|
10
|
+
import { ThreadColumn } from './review-thread.tsx'
|
|
16
11
|
|
|
17
12
|
export const ReviewPage = observer(({ app }: { app: RepoSt }) => {
|
|
18
13
|
const rv = app.review
|
|
19
|
-
const el = useRef<HTMLDivElement | null>(null)
|
|
20
14
|
useEffect(() => {
|
|
21
15
|
rv.start()
|
|
22
16
|
return () => rv.stop()
|
|
23
17
|
}, [rv])
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
const node = el.current
|
|
26
|
-
if (node == null || typeof ResizeObserver === 'undefined') return
|
|
27
|
-
// the pick lands on the next frame: a relayout inside the callback is the observer's loop error
|
|
28
|
-
let raf = 0
|
|
29
|
-
const ro = new ResizeObserver(([e]) => {
|
|
30
|
-
const w = e!.contentRect.width
|
|
31
|
-
cancelAnimationFrame(raf)
|
|
32
|
-
raf = requestAnimationFrame(() => rv.fit(w))
|
|
33
|
-
})
|
|
34
|
-
ro.observe(node)
|
|
35
|
-
return () => {
|
|
36
|
-
cancelAnimationFrame(raf)
|
|
37
|
-
ro.disconnect()
|
|
38
|
-
}
|
|
39
|
-
}, [rv, rv.phone.on])
|
|
40
18
|
if (rv.phone.on)
|
|
41
19
|
return (
|
|
42
20
|
<div className="rv-phone">
|
|
43
|
-
<PhoneTop app={app} />
|
|
44
|
-
<div className="rv-phonetabs seg">
|
|
45
|
-
{(['list', 'card'] as const).map((p) => (
|
|
46
|
-
<button key={p} className={rv.phone.pane === p ? 'on' : ''} onClick={() => rv.phone.show(p)}>
|
|
47
|
-
{PANE_LABEL[p]}{p === 'list' && rv.pendingCount > 0 ? ` · ${rv.pendingCount}` : ''}
|
|
48
|
-
</button>
|
|
49
|
-
))}
|
|
50
|
-
</div>
|
|
51
21
|
{rv.phone.pane === 'list' ? (
|
|
52
|
-
|
|
22
|
+
<>
|
|
23
|
+
<PhoneTop app={app} />
|
|
24
|
+
<div className="rv-phonepane"><ReviewList rv={rv} /></div>
|
|
25
|
+
</>
|
|
53
26
|
) : (
|
|
54
|
-
<
|
|
55
|
-
<ReviewImage rv={rv} />
|
|
56
|
-
<ReviewForm rv={rv} />
|
|
57
|
-
</CardScroll>
|
|
27
|
+
<ThreadColumn rv={rv} />
|
|
58
28
|
)}
|
|
59
|
-
{rv.phone.pane === 'list' ? null : <VerdictBar rv={rv} />}
|
|
60
29
|
<Toast rv={rv} />
|
|
61
30
|
</div>
|
|
62
31
|
)
|
|
63
32
|
return (
|
|
64
33
|
<>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<Panel id="review-stack" defaultSize="68%" minSize={300} className="rv-pane" style={PANEL}>
|
|
74
|
-
<CardScroll rv={rv} className="rv-scroll">
|
|
75
|
-
<ReviewImage rv={rv} />
|
|
76
|
-
<ReviewForm rv={rv} />
|
|
77
|
-
</CardScroll>
|
|
34
|
+
<Toast rv={rv} />
|
|
35
|
+
<Group className="rv-cols" orientation="horizontal">
|
|
36
|
+
<Panel id="review-list" defaultSize="24%" minSize={180} className="rv-pane" style={PANEL}>
|
|
37
|
+
<ReviewList rv={rv} />
|
|
38
|
+
</Panel>
|
|
39
|
+
<Separator className="rsep" />
|
|
40
|
+
<Panel id="review-thread" defaultSize="76%" minSize={360} className="rv-pane" style={PANEL}>
|
|
41
|
+
<ThreadColumn rv={rv} />
|
|
78
42
|
</Panel>
|
|
79
|
-
|
|
80
|
-
<>
|
|
81
|
-
<Panel id="review-image" defaultSize="54%" minSize={300} className="rv-pane" style={PANEL}>
|
|
82
|
-
<CardScroll rv={rv} className="rv-scroll"><ReviewImage rv={rv} /></CardScroll>
|
|
83
|
-
</Panel>
|
|
84
|
-
<Separator className="rsep" />
|
|
85
|
-
<Panel id="review-form" defaultSize="26%" minSize={260} className="rv-pane" style={PANEL}>
|
|
86
|
-
<CardScroll rv={rv} className="rv-scroll"><ReviewForm rv={rv} /></CardScroll>
|
|
87
|
-
</Panel>
|
|
88
|
-
</>
|
|
89
|
-
)}
|
|
90
|
-
</Group>
|
|
43
|
+
</Group>
|
|
91
44
|
</>
|
|
92
45
|
)
|
|
93
46
|
})
|
|
94
47
|
|
|
95
|
-
/** the phone's top line: the way back to the hub (none in another tool's frame),
|
|
96
|
-
* panes, which leave it no room */
|
|
48
|
+
/** the phone's top line over the cards: the way back to the hub (none in another tool's frame), the repo, the count
|
|
49
|
+
* that waits on him. On a phone the page covers the hub's panes, which leave it no room */
|
|
97
50
|
export const PhoneTop = observer(({ app }: { app: RepoSt }) => (
|
|
98
51
|
<div className="rv-phonetop">
|
|
99
52
|
{app.home.embedded ? null : <button className="ghost" onClick={() => app.showReadme()}>◂ hub</button>}
|
|
100
53
|
<b>{app.name}</b>
|
|
101
|
-
<span className="rv-dim">{app.sel?.t === 'trailer' ? 'trailer' :
|
|
54
|
+
<span className="rv-dim">{app.sel?.t === 'trailer' ? 'trailer' : `review${app.review.pendingCount > 0 ? ` · ${app.review.pendingCount} waiting` : ''}`}</span>
|
|
102
55
|
</div>
|
|
103
56
|
))
|
|
104
57
|
|
|
105
|
-
/** a column of the open card: another card opens at its top, never where the last one was scrolled */
|
|
106
|
-
const CardScroll = observer(({ rv, className, children }: { rv: ReviewSt; className: string; children: ReactNode }) => {
|
|
107
|
-
const el = useRef<HTMLDivElement | null>(null)
|
|
108
|
-
const id = rv.open?.item.id
|
|
109
|
-
useEffect(() => {
|
|
110
|
-
if (el.current) el.current.scrollTop = 0
|
|
111
|
-
}, [id])
|
|
112
|
-
return <div ref={el} className={className}>{children}</div>
|
|
113
|
-
})
|
|
114
|
-
|
|
115
58
|
/** what the last copy put on the clipboard, a moment over the page */
|
|
116
59
|
const Toast = observer(({ rv }: { rv: ReviewSt }) => (rv.toast ? <div className="rv-toast" role="status">{rv.toast}</div> : null))
|
|
117
60
|
|