@qzsy/dsh-yunxiao-panel 1.1.0 → 1.2.1
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/README.md +59 -27
- package/dist/client.js +109 -9
- package/dist/index.js +15 -10
- package/package.json +1 -1
- package/test/render-test.mjs +30 -1
package/README.md
CHANGED
|
@@ -24,19 +24,32 @@ and a repository chip row for its merge requests.
|
|
|
24
24
|
dynamic-programming fuzzy match): full pinyin (`qunxing`), pinyin initials
|
|
25
25
|
(`qxkj`), project codes (`QXERP`), and mixed forms all match, and the hit
|
|
26
26
|
ranges are highlighted in the rows.
|
|
27
|
-
- **我的工作台** —
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
- **我的工作台** — a cross-project workbench with two scopes, switched at the top
|
|
28
|
+
and remembered per browser:
|
|
29
|
+
- **我的** aggregates the work items assigned to the token's user; **组织** drops
|
|
30
|
+
that filter and covers every open item in the organization (up to 400, open
|
|
31
|
+
ones first), so an organization manager can triage work unrelated to them.
|
|
32
|
+
- a hero card with a status ring (completion in the middle), a plain-language
|
|
33
|
+
summary, and a **优先处理** row that picks the most urgent open item (bugs
|
|
34
|
+
first) and opens it in one click,
|
|
35
|
+
- four clickable KPI cards (**全部工作项 / 未完成 / 缺陷 / 待评审**), then status,
|
|
36
|
+
project, type and trend charts whose **bars, slices and legends filter the
|
|
37
|
+
list**; organization scope adds a **按负责人** chart,
|
|
34
38
|
- a scrollable **work-item list** (serial, project code + **Chinese project
|
|
35
|
-
name**, type, status, relative time) with
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
name**, assignee in organization scope, type, status, relative time) with
|
|
40
|
+
removable filter chips; rows open the detail pane,
|
|
41
|
+
- merge requests waiting for review (all open ones in organization scope), with
|
|
42
|
+
a direct link to Yunxiao when the list is empty.
|
|
43
|
+
- **Change status from the detail pane** — the pane shows the current status, a
|
|
44
|
+
dropdown of the whole workflow for that work item type, and a **标记完成**
|
|
45
|
+
button that picks the type's own done status (缺陷 → 已修复, 需求 → 已完成, else
|
|
46
|
+
已关闭). The item is repainted in the detail, every project list and the
|
|
47
|
+
workbench (including its status chart) before the request returns, and a
|
|
48
|
+
failure rolls every snapshot back.
|
|
49
|
+
- **在对话中处理** opens a workspace picker first: it lists the local DSH
|
|
50
|
+
workspaces (suggesting the one whose name matches the repository or project),
|
|
51
|
+
remembers the choice per Yunxiao project, and shows it on the button so the
|
|
52
|
+
next handoff is a single click with a **切换** action beside it.
|
|
40
53
|
- **Repository page** — clicking any repository (in the repository list or under
|
|
41
54
|
**未绑定的仓库**) opens its own page with four tabs:
|
|
42
55
|
**概览 / 提交 / 工作项 / 合并请求**.
|
|
@@ -124,23 +137,29 @@ while it revalidates in the background.
|
|
|
124
137
|
| Data | Query key | staleTime | gcTime |
|
|
125
138
|
|---|---|---|---|
|
|
126
139
|
| bootstrap (repos / namespaces / projects) | `['bootstrap']` | 30s | 10min |
|
|
127
|
-
| workbench aggregation | `['workbench']` |
|
|
140
|
+
| workbench aggregation (per scope) | `['workbench', scope]` | 30s (+90s poll while visible) | 10min |
|
|
128
141
|
| work items page | `['workitems', spaceId, category]` | 30s | 10min |
|
|
129
142
|
| merge requests page | `['prs', repoId, state]` | 30s | 10min |
|
|
130
|
-
| one work item | `['workitem', id]` |
|
|
143
|
+
| one work item | `['workitem', id]` | 15s | 10min |
|
|
144
|
+
| workflow statuses | `['workflow', spaceId, typeId]` | 10min | 10min |
|
|
145
|
+
| repository detail / activity | `['repo-detail' | 'repo-activity', …]` | 2min | 10min |
|
|
146
|
+
| DSH workspaces | `['workspaces']` | 60s | 10min |
|
|
131
147
|
| types / members / me | `['workitem-types' | 'members' | 'me', …]` | 5min | 10min |
|
|
132
148
|
|
|
133
149
|
- Window focus and reconnect revalidate stale queries (`refetchOnWindowFocus`).
|
|
134
|
-
- **刷新**
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
|
|
138
|
-
|
|
150
|
+
- **刷新** clears the Host cache, drops the localStorage snapshot, resets every
|
|
151
|
+
query, and tells other open tabs to refresh too.
|
|
152
|
+
- A status write paints the new status into the detail, every project list and the
|
|
153
|
+
workbench immediately, broadcasts it to other tabs, and rolls back on failure.
|
|
154
|
+
- The Host keeps its own short-lived cache and **overlays recent status writes on
|
|
155
|
+
stale search results** for 3 minutes, so a list refetched right after a write
|
|
156
|
+
cannot resurrect the old status.
|
|
139
157
|
- **localStorage persistence**: 700ms after the cache changes, the freshest
|
|
140
|
-
successful queries are snapshotted under `dsh.yunxiao.queryCache.
|
|
141
|
-
(2 MB cap, largest entries skipped, failures clear the snapshot).
|
|
142
|
-
|
|
143
|
-
|
|
158
|
+
successful queries are snapshotted under `dsh.yunxiao.queryCache.v2`
|
|
159
|
+
(2 MB cap, largest entries skipped, failures clear the snapshot). Snapshots
|
|
160
|
+
older than 24 hours are discarded on load; the v1 key is removed automatically.
|
|
161
|
+
Hydrated data keeps its original `updatedAt`, so the first paint after a reload
|
|
162
|
+
is instant and a background revalidation follows when the data is stale.
|
|
144
163
|
- The bundle is generated by `scripts/sync-vendor-query.mjs` from
|
|
145
164
|
`vendor/react-query.min.cjs` (React stays external and resolves through the
|
|
146
165
|
host module table); the license is kept at `vendor/react-query.LICENSE`.
|
|
@@ -154,7 +173,7 @@ loopback-only same-origin facade at `/api/yunxiao`:
|
|
|
154
173
|
|---|---|
|
|
155
174
|
| `GET /bootstrap` | repositories (all pages), namespaces, projects, connection state |
|
|
156
175
|
| `GET /repos?page&search` | one page of repositories |
|
|
157
|
-
| `GET /workbench` | cross-project aggregation:
|
|
176
|
+
| `GET /workbench?scope=mine\|org` | cross-project aggregation: items, stats, reviews per scope |
|
|
158
177
|
| `GET /repo-detail?id` | repository detail + decoded root README |
|
|
159
178
|
| `GET /repo-activity?id&ref` | recent commits + contributors (avatars) |
|
|
160
179
|
| `GET /file?repoId&ref&path` | raw file bytes (README images, relative links) |
|
|
@@ -165,6 +184,9 @@ loopback-only same-origin facade at `/api/yunxiao`:
|
|
|
165
184
|
| `GET /members?spaceId` | project members for the assignee picker |
|
|
166
185
|
| `GET /me` | the user behind the personal access token |
|
|
167
186
|
| `POST /workitems` | create a work item (`ProjexCreateWorkitem`) |
|
|
187
|
+
| `GET /workflow?spaceId&typeId` | workflow statuses of a work item type |
|
|
188
|
+
| `POST /workitem-status` | move a work item to another status (`PUT /workitems/{id}`) |
|
|
189
|
+
| `GET /workspaces` | local DSH workspaces for the chat handoff picker |
|
|
168
190
|
| `GET /prs?repoId&state&page` | `codeup .../changeRequests` |
|
|
169
191
|
| `GET /status` | token / organization presence |
|
|
170
192
|
| `POST /refresh` | drop the short-lived cache |
|
|
@@ -187,14 +209,24 @@ Published on npm as **`@qzsy/dsh-yunxiao-panel`**. Install it from the Harness
|
|
|
187
209
|
Plugin Manager by package name, or during development install this directory
|
|
188
210
|
with `plugin_manager install_bundle` (absolute package directory).
|
|
189
211
|
|
|
190
|
-
|
|
191
|
-
|
|
212
|
+
Each person needs their own Yunxiao personal access token in the environment
|
|
213
|
+
(see *Data path*); the panel never ships a credential. The token needs Codeup
|
|
214
|
+
read access and Projex read/write access (to change status and create work
|
|
215
|
+
items). After installation and setting the environment variables, restart the
|
|
216
|
+
Harness and reload the Web page; the 云效 icon appears in the left rail between
|
|
217
|
+
the command palette and the Git entry.
|
|
218
|
+
|
|
219
|
+
Project↔repository bindings, the remembered chat workspace and the workbench
|
|
220
|
+
scope live in the browser's local storage, so each teammate binds and picks once
|
|
221
|
+
per browser.
|
|
192
222
|
|
|
193
223
|
## Test
|
|
194
224
|
|
|
195
225
|
The browser half has a jsdom render test that mounts the real component against
|
|
196
226
|
a mocked facade and exercises repository switching, the unbound-project state,
|
|
197
|
-
the work-item list and detail pane,
|
|
227
|
+
the work-item list and detail pane, status changes (including the list repaint),
|
|
228
|
+
the chat handoff with its workspace picker and remembered choice, the workbench
|
|
229
|
+
scopes, and the merge-request tab.
|
|
198
230
|
|
|
199
231
|
```bash
|
|
200
232
|
npm install --no-save react@18 react-dom@18 jsdom@24
|
package/dist/client.js
CHANGED
|
@@ -208,6 +208,8 @@ window.__ModuleLoader__.load({
|
|
|
208
208
|
const PROJECT_STORAGE_KEY = 'dsh.yunxiao.projectMap'
|
|
209
209
|
/** Remembered DSH workspace per Yunxiao project: { [projectId]: workspaceId, __last: workspaceId }. */
|
|
210
210
|
const CHAT_WORKSPACE_KEY = 'dsh.yunxiao.chatWorkspace'
|
|
211
|
+
const WORK_SCOPE_KEY = 'dsh.yunxiao.workScope'
|
|
212
|
+
const UNASSIGNED = '未指派'
|
|
211
213
|
const PROJECT_ID_STORAGE_KEY = 'dsh.yunxiao.project'
|
|
212
214
|
const VIEW_STORAGE_KEY = 'dsh.yunxiao.view'
|
|
213
215
|
const REPO_VIEW_KEY = 'dsh.yunxiao.repoView'
|
|
@@ -369,6 +371,16 @@ window.__ModuleLoader__.load({
|
|
|
369
371
|
kpiOpenBugs: '{n} 个未关闭',
|
|
370
372
|
kpiReviewHint: '点击定位到评审列表',
|
|
371
373
|
kpiReviewClear: '暂无待评审',
|
|
374
|
+
scopeMine: '我的',
|
|
375
|
+
scopeOrg: '组织',
|
|
376
|
+
scopeHintMine: '只看指派给我的工作项',
|
|
377
|
+
scopeHintOrg: '组织内所有项目的待办,与你是否相关无关',
|
|
378
|
+
heroSummaryOrg: '组织内还有 {open} 项未完成,{bugs} 个缺陷待处理,{reviews} 个合并请求待评审',
|
|
379
|
+
orgEyebrow: '组织视角',
|
|
380
|
+
kpiReviewOrg: '待评审合并请求',
|
|
381
|
+
orgReviews: '组织待评审',
|
|
382
|
+
byAssignee: '按负责人',
|
|
383
|
+
assigneesUnit: '位负责人',
|
|
372
384
|
heroSummary: '还有 {open} 项未完成,{bugs} 个缺陷待处理,{reviews} 个合并请求等你评审',
|
|
373
385
|
doneSection: '已完成 / 已关闭',
|
|
374
386
|
statusUnit: '种状态',
|
|
@@ -559,6 +571,16 @@ window.__ModuleLoader__.load({
|
|
|
559
571
|
kpiOpenBugs: '{n} still open',
|
|
560
572
|
kpiReviewHint: 'Click to jump to reviews',
|
|
561
573
|
kpiReviewClear: 'Nothing to review',
|
|
574
|
+
scopeMine: 'Mine',
|
|
575
|
+
scopeOrg: 'Organization',
|
|
576
|
+
scopeHintMine: 'Only items assigned to me',
|
|
577
|
+
scopeHintOrg: 'Every open item in the organization, related to you or not',
|
|
578
|
+
heroSummaryOrg: '{open} open items, {bugs} bugs to fix, {reviews} merge requests waiting for review across the organization',
|
|
579
|
+
orgEyebrow: 'Organization view',
|
|
580
|
+
kpiReviewOrg: 'Open merge requests',
|
|
581
|
+
orgReviews: 'Organization reviews',
|
|
582
|
+
byAssignee: 'By assignee',
|
|
583
|
+
assigneesUnit: 'assignees',
|
|
562
584
|
heroSummary: '{open} open items, {bugs} bugs to fix, {reviews} merge requests waiting for you',
|
|
563
585
|
doneSection: 'Done / closed',
|
|
564
586
|
statusUnit: 'statuses',
|
|
@@ -981,6 +1003,14 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
981
1003
|
.yx-chatpick-badge[data-kind="project"]{color:#16a34a;background:color-mix(in srgb,#22c55e 14%,transparent)}
|
|
982
1004
|
.yx-chatpick-badge[data-kind="suggest"]{color:#6366f1;background:color-mix(in srgb,#6366f1 14%,transparent)}
|
|
983
1005
|
.yx-chatpick-badge[data-kind="last"]{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-3)}
|
|
1006
|
+
.yx-scope{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
1007
|
+
.yx-scope-seg{display:inline-flex;padding:3px;gap:2px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-2)}
|
|
1008
|
+
.yx-scope-btn{height:28px;padding:0 16px;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer;transition:background .15s ease,color .15s ease,box-shadow .15s ease}
|
|
1009
|
+
.yx-scope-btn:hover{color:var(--dsw-alias-label-primary)}
|
|
1010
|
+
.yx-scope-btn[data-active="true"]{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font-weight:600;box-shadow:0 1px 4px rgba(0,0,0,.12)}
|
|
1011
|
+
.yx-scope-btn[data-scope="org"][data-active="true"]{color:#8b5cf6;background:color-mix(in srgb,#8b5cf6 12%,var(--dsw-alias-bg-layer-1))}
|
|
1012
|
+
.yx-scope-hint{font-size:11.5px;color:var(--dsw-alias-label-tertiary)}
|
|
1013
|
+
.yx-work-assignee{flex:none;max-width:96px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 6px;border-radius:999px;font-size:10.5px;line-height:16px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-3)}
|
|
984
1014
|
@media (max-width:1100px){.yx-detail{position:absolute;right:0;top:0;bottom:0;width:min(440px,92vw);box-shadow:var(--dsw-elevation-prominent,-8px 0 24px rgba(0,0,0,.16));z-index:30}.yx-main{position:relative}}
|
|
985
1015
|
@media (max-width:760px){
|
|
986
1016
|
.yx-aside{position:absolute;left:0;top:0;bottom:0;z-index:40;width:min(300px,86vw);flex:0 0 auto;transform:translateX(-100%);transition:transform .2s ease;box-shadow:none}
|
|
@@ -1999,19 +2029,56 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
1999
2029
|
})
|
|
2000
2030
|
}
|
|
2001
2031
|
|
|
2002
|
-
function WorkbenchPage({ t, state, data, error, onRetry, onRefresh, onOpenItem, refreshing }) {
|
|
2032
|
+
function WorkbenchPage({ t, state, data, error, onRetry, onRefresh, onOpenItem, refreshing, scope = 'mine', onScope }) {
|
|
2033
|
+
const isOrg = scope === 'org'
|
|
2003
2034
|
const [statusFilter, setStatusFilter] = useState(null)
|
|
2004
2035
|
const [typeFilter, setTypeFilter] = useState(null)
|
|
2005
2036
|
const [projectFilter, setProjectFilter] = useState(null)
|
|
2037
|
+
const [assigneeFilter, setAssigneeFilter] = useState(null)
|
|
2006
2038
|
const [reviewPulse, setReviewPulse] = useState(false)
|
|
2007
2039
|
const reviewRef = useRef(null)
|
|
2008
2040
|
const pulseTimer = useRef(0)
|
|
2009
2041
|
useEffect(() => () => window.clearTimeout(pulseTimer.current), [])
|
|
2042
|
+
// A different scope is a different dataset, so old filters would only hide rows.
|
|
2043
|
+
useEffect(() => {
|
|
2044
|
+
setStatusFilter(null)
|
|
2045
|
+
setTypeFilter(null)
|
|
2046
|
+
setProjectFilter(null)
|
|
2047
|
+
setAssigneeFilter(null)
|
|
2048
|
+
}, [scope])
|
|
2049
|
+
const scopeBar = onScope
|
|
2050
|
+
? h(
|
|
2051
|
+
'div',
|
|
2052
|
+
{ className: 'yx-scope' },
|
|
2053
|
+
h(
|
|
2054
|
+
'div',
|
|
2055
|
+
{ className: 'yx-scope-seg', role: 'tablist' },
|
|
2056
|
+
['mine', 'org'].map((value) =>
|
|
2057
|
+
h(
|
|
2058
|
+
'button',
|
|
2059
|
+
{
|
|
2060
|
+
key: value,
|
|
2061
|
+
type: 'button',
|
|
2062
|
+
role: 'tab',
|
|
2063
|
+
className: 'yx-scope-btn',
|
|
2064
|
+
'data-scope': value,
|
|
2065
|
+
'data-active': String(scope === value),
|
|
2066
|
+
'aria-selected': String(scope === value),
|
|
2067
|
+
onClick: () => onScope(value),
|
|
2068
|
+
},
|
|
2069
|
+
value === 'org' ? t('scopeOrg') : t('scopeMine'),
|
|
2070
|
+
),
|
|
2071
|
+
),
|
|
2072
|
+
),
|
|
2073
|
+
h('span', { className: 'yx-scope-hint' }, isOrg ? t('scopeHintOrg') : t('scopeHintMine')),
|
|
2074
|
+
)
|
|
2075
|
+
: null
|
|
2010
2076
|
|
|
2011
2077
|
if (state === 'loading' || state === 'idle') {
|
|
2012
2078
|
return h(
|
|
2013
2079
|
'div',
|
|
2014
2080
|
{ className: 'yx-work' },
|
|
2081
|
+
scopeBar,
|
|
2015
2082
|
h(
|
|
2016
2083
|
'div',
|
|
2017
2084
|
{ className: 'yx-work-head yx-hero' },
|
|
@@ -2056,15 +2123,17 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2056
2123
|
const finished = toneCounts.done + toneCounts.closed
|
|
2057
2124
|
const completion = items.length ? Math.round((finished / items.length) * 100) : 0
|
|
2058
2125
|
const reviews = (data.prs ?? []).filter(
|
|
2059
|
-
(pr) => (pr.state === 'UNDER_REVIEW' || pr.state === 'OPENED') && pr.reviewers.includes(me.name),
|
|
2126
|
+
(pr) => (pr.state === 'UNDER_REVIEW' || pr.state === 'OPENED') && (isOrg || pr.reviewers.includes(me.name)),
|
|
2060
2127
|
)
|
|
2061
2128
|
const timeOf = (item) => {
|
|
2062
2129
|
const value = item.gmtModified
|
|
2063
2130
|
const time = typeof value === 'number' ? value : Date.parse(value)
|
|
2064
2131
|
return Number.isFinite(time) ? time : 0
|
|
2065
2132
|
}
|
|
2133
|
+
const assigneeOf = (item) => item.assignedTo?.name || UNASSIGNED
|
|
2066
2134
|
const filteredItems = items
|
|
2067
2135
|
.filter((item) => {
|
|
2136
|
+
if (assigneeFilter && assigneeOf(item) !== assigneeFilter) return false
|
|
2068
2137
|
if (statusFilter === 'open' && !isOpenItem(item)) return false
|
|
2069
2138
|
if (statusFilter && statusFilter !== 'open' && item.status !== statusFilter) return false
|
|
2070
2139
|
if (typeFilter === 'bug' && !isBugItem(item)) return false
|
|
@@ -2079,8 +2148,9 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2079
2148
|
const statusName = statusFilter === 'open' ? t('kpiOpen') : statusFilter
|
|
2080
2149
|
const typeName = typeFilter === 'bug' ? t('kpiBugs') : typeFilter
|
|
2081
2150
|
const projectName = projectFilter ? projectNames.get(projectFilter) || projectFilter : null
|
|
2082
|
-
const hasFilter = Boolean(statusFilter || typeFilter || projectFilter)
|
|
2151
|
+
const hasFilter = Boolean(statusFilter || typeFilter || projectFilter || assigneeFilter)
|
|
2083
2152
|
const clearFilters = () => {
|
|
2153
|
+
setAssigneeFilter(null)
|
|
2084
2154
|
setStatusFilter(null)
|
|
2085
2155
|
setTypeFilter(null)
|
|
2086
2156
|
setProjectFilter(null)
|
|
@@ -2129,7 +2199,7 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2129
2199
|
},
|
|
2130
2200
|
{
|
|
2131
2201
|
key: 'review',
|
|
2132
|
-
label: t('kpiReview'),
|
|
2202
|
+
label: isOrg ? t('kpiReviewOrg') : t('kpiReview'),
|
|
2133
2203
|
value: reviews.length,
|
|
2134
2204
|
color: WB.violet,
|
|
2135
2205
|
icon: 'review',
|
|
@@ -2203,6 +2273,7 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2203
2273
|
statusFilter ? { key: 'status', label: statusName, clear: () => setStatusFilter(null) } : null,
|
|
2204
2274
|
typeFilter ? { key: 'type', label: typeName, clear: () => setTypeFilter(null) } : null,
|
|
2205
2275
|
projectFilter ? { key: 'project', label: projectName, clear: () => setProjectFilter(null) } : null,
|
|
2276
|
+
assigneeFilter ? { key: 'assignee', label: assigneeFilter, clear: () => setAssigneeFilter(null) } : null,
|
|
2206
2277
|
].filter(Boolean)
|
|
2207
2278
|
|
|
2208
2279
|
const firstDoneIndex = filteredItems.findIndex((item) => !isOpenItem(item))
|
|
@@ -2263,6 +2334,7 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2263
2334
|
return h(
|
|
2264
2335
|
'div',
|
|
2265
2336
|
{ className: 'yx-work' },
|
|
2337
|
+
scopeBar,
|
|
2266
2338
|
h(
|
|
2267
2339
|
'div',
|
|
2268
2340
|
{ className: 'yx-work-head yx-hero' },
|
|
@@ -2273,7 +2345,7 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2273
2345
|
h(
|
|
2274
2346
|
'div',
|
|
2275
2347
|
{ className: 'yx-hero-eyebrow' },
|
|
2276
|
-
`${t('workbenchHello').replace('{name}', me.name)} · ${t('updatedAt')} ${new Date(
|
|
2348
|
+
`${isOrg ? t('orgEyebrow') : t('workbenchHello').replace('{name}', me.name)} · ${t('updatedAt')} ${new Date(
|
|
2277
2349
|
data.generatedAt,
|
|
2278
2350
|
).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`,
|
|
2279
2351
|
),
|
|
@@ -2281,7 +2353,7 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2281
2353
|
h(
|
|
2282
2354
|
'div',
|
|
2283
2355
|
{ className: 'yx-hero-summary' },
|
|
2284
|
-
fillTemplate(t('heroSummary'), {
|
|
2356
|
+
fillTemplate(t(isOrg ? 'heroSummaryOrg' : 'heroSummary'), {
|
|
2285
2357
|
open: { value: openCount, color: WB.blue },
|
|
2286
2358
|
bugs: { value: openBugCount, color: WB.red },
|
|
2287
2359
|
reviews: { value: reviews.length, color: WB.violet },
|
|
@@ -2393,6 +2465,20 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2393
2465
|
labelOf: (item) => projectNames.get(item.name) || item.name,
|
|
2394
2466
|
}),
|
|
2395
2467
|
),
|
|
2468
|
+
isOrg
|
|
2469
|
+
? chartCard(
|
|
2470
|
+
'assignee',
|
|
2471
|
+
WB.teal,
|
|
2472
|
+
t('byAssignee'),
|
|
2473
|
+
`${(stats.byAssignee ?? []).length} ${t('assigneesUnit')}`,
|
|
2474
|
+
h(BarList, {
|
|
2475
|
+
items: (stats.byAssignee ?? []).slice(0, 8),
|
|
2476
|
+
active: assigneeFilter,
|
|
2477
|
+
onPick: (name) => setAssigneeFilter(assigneeFilter === name ? null : name),
|
|
2478
|
+
colorOf: (item) => (item.name === UNASSIGNED ? WB.slate : paletteColor(item.name)),
|
|
2479
|
+
}),
|
|
2480
|
+
)
|
|
2481
|
+
: null,
|
|
2396
2482
|
chartCard(
|
|
2397
2483
|
'type',
|
|
2398
2484
|
WB.red,
|
|
@@ -2475,6 +2561,7 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2475
2561
|
item.projectName
|
|
2476
2562
|
? h('span', { className: 'yx-work-project', title: item.projectName }, item.projectName)
|
|
2477
2563
|
: null,
|
|
2564
|
+
isOrg ? h('span', { className: 'yx-work-assignee' }, assigneeOf(item)) : null,
|
|
2478
2565
|
item.workitemType
|
|
2479
2566
|
? h(
|
|
2480
2567
|
'span',
|
|
@@ -2538,7 +2625,7 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2538
2625
|
'div',
|
|
2539
2626
|
{ className: 'yx-card-head' },
|
|
2540
2627
|
h('img', { className: 'yx-card-icon', src: WB_ICONS.review, alt: '', 'aria-hidden': 'true', width: 26, height: 26 }),
|
|
2541
|
-
h('h4', { className: 'yx-card-title' }, t('myReviews')),
|
|
2628
|
+
h('h4', { className: 'yx-card-title' }, isOrg ? t('orgReviews') : t('myReviews')),
|
|
2542
2629
|
reviews.length ? h('span', { className: 'yx-count-pill yx-count-pill--violet' }, String(reviews.length)) : null,
|
|
2543
2630
|
),
|
|
2544
2631
|
reviews.length
|
|
@@ -2622,6 +2709,17 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2622
2709
|
const [chatMemory, setChatMemory] = useState(() => readJsonStorage(CHAT_WORKSPACE_KEY, {}))
|
|
2623
2710
|
const [bindRepoSearch, setBindRepoSearch] = useState('')
|
|
2624
2711
|
const [repoMenuOpen, setRepoMenuOpen] = useState(false)
|
|
2712
|
+
const [workScope, setWorkScope] = useState(() =>
|
|
2713
|
+
readStringStorage(WORK_SCOPE_KEY) === 'org' ? 'org' : 'mine',
|
|
2714
|
+
)
|
|
2715
|
+
const switchWorkScope = useCallback((value) => {
|
|
2716
|
+
setWorkScope(value === 'org' ? 'org' : 'mine')
|
|
2717
|
+
try {
|
|
2718
|
+
window.localStorage.setItem(WORK_SCOPE_KEY, value === 'org' ? 'org' : 'mine')
|
|
2719
|
+
} catch {
|
|
2720
|
+
// storage is optional
|
|
2721
|
+
}
|
|
2722
|
+
}, [])
|
|
2625
2723
|
const [navOpen, setNavOpen] = useState(false)
|
|
2626
2724
|
const [unboundSearch, setUnboundSearch] = useState('')
|
|
2627
2725
|
const [refreshing, setRefreshing] = useState(false)
|
|
@@ -2785,8 +2883,8 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
2785
2883
|
const openRepoRow = useCallback((row) => openRepoView(row.repo), [openRepoView])
|
|
2786
2884
|
|
|
2787
2885
|
const workbenchQuery = useQuery({
|
|
2788
|
-
queryKey: ['workbench'],
|
|
2789
|
-
queryFn: () => getJson(`${API}/workbench`),
|
|
2886
|
+
queryKey: ['workbench', workScope],
|
|
2887
|
+
queryFn: () => getJson(`${API}/workbench?scope=${workScope}`),
|
|
2790
2888
|
enabled: view === 'workbench' && bootState === 'ready',
|
|
2791
2889
|
staleTime: 30_000,
|
|
2792
2890
|
// Picks up changes made on the Yunxiao website; paused while the tab is hidden.
|
|
@@ -4915,6 +5013,8 @@ button.yx-bar-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
|
4915
5013
|
onRetry: fetchWorkbench,
|
|
4916
5014
|
onRefresh: refresh,
|
|
4917
5015
|
refreshing,
|
|
5016
|
+
scope: workScope,
|
|
5017
|
+
onScope: switchWorkScope,
|
|
4918
5018
|
onOpenItem: (item) => openIssue(item, item.projectId),
|
|
4919
5019
|
})
|
|
4920
5020
|
: view === 'repo'
|
package/dist/index.js
CHANGED
|
@@ -417,11 +417,12 @@ function createYunxiaoApi() {
|
|
|
417
417
|
return { id: user?.id ?? "", name: user?.name ?? "", email: user?.email ?? "" };
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
|
-
async function workbench() {
|
|
420
|
+
async function workbench(scope = "mine") {
|
|
421
421
|
const creds = resolveCredentials();
|
|
422
422
|
if (!creds.connected)
|
|
423
423
|
throw new ApiError("missing-credentials", "Yunxiao credentials are not configured", 401);
|
|
424
|
-
|
|
424
|
+
const org = scope === "org";
|
|
425
|
+
return cached(org ? "workbench:org" : "workbench", 30000, async () => {
|
|
425
426
|
const currentUser = await me();
|
|
426
427
|
const boot = await bootstrap();
|
|
427
428
|
const projects = (boot.projects ?? []).filter((project) => !project.status || project.status === "NORMAL");
|
|
@@ -434,8 +435,8 @@ function createYunxiaoApi() {
|
|
|
434
435
|
const rows = await workitems({
|
|
435
436
|
spaceId: project.id,
|
|
436
437
|
category: "Req,Bug,Task",
|
|
437
|
-
perPage: 50,
|
|
438
|
-
assignedTo: currentUser.id
|
|
438
|
+
perPage: org ? 100 : 50,
|
|
439
|
+
assignedTo: org ? undefined : currentUser.id
|
|
439
440
|
});
|
|
440
441
|
for (const item of rows) {
|
|
441
442
|
items.push({
|
|
@@ -449,8 +450,10 @@ function createYunxiaoApi() {
|
|
|
449
450
|
}
|
|
450
451
|
};
|
|
451
452
|
await Promise.all(Array.from({ length: Math.min(5, queue.length) }, worker));
|
|
452
|
-
|
|
453
|
-
const
|
|
453
|
+
const terminal = /已完成|完成|已修复|已解决|已上线|已发布|已验收|关闭|取消|拒绝|挂起|不修复/;
|
|
454
|
+
const isTerminal = (item) => terminal.test(String(item.status || ""));
|
|
455
|
+
items.sort((a, b) => (org ? Number(isTerminal(a)) - Number(isTerminal(b)) : 0) || Number(b.gmtModified ?? 0) - Number(a.gmtModified ?? 0));
|
|
456
|
+
const capped = items.slice(0, org ? 400 : 200);
|
|
454
457
|
let prs = [];
|
|
455
458
|
try {
|
|
456
459
|
const rows = await call(creds, {
|
|
@@ -458,7 +461,7 @@ function createYunxiaoApi() {
|
|
|
458
461
|
path: "/changeRequests",
|
|
459
462
|
query: { perPage: 50 }
|
|
460
463
|
});
|
|
461
|
-
prs = (rows ?? []).map(pickChangeRequest).filter((cr) => cr.author === currentUser.name || cr.reviewers.includes(currentUser.name)).slice(0, 12);
|
|
464
|
+
prs = (rows ?? []).map(pickChangeRequest).filter((cr) => org ? cr.state === "OPENED" || cr.state === "UNDER_REVIEW" : cr.author === currentUser.name || cr.reviewers.includes(currentUser.name)).slice(0, org ? 20 : 12);
|
|
462
465
|
} catch {}
|
|
463
466
|
const countBy = (rows, keyOf) => {
|
|
464
467
|
const map = new Map;
|
|
@@ -535,6 +538,7 @@ function createYunxiaoApi() {
|
|
|
535
538
|
}
|
|
536
539
|
}
|
|
537
540
|
return {
|
|
541
|
+
scope: org ? "org" : "mine",
|
|
538
542
|
me: currentUser,
|
|
539
543
|
generatedAt: Date.now(),
|
|
540
544
|
projects: projects.map((project) => ({
|
|
@@ -549,6 +553,7 @@ function createYunxiaoApi() {
|
|
|
549
553
|
byStatus: countBy(capped, (item) => item.status),
|
|
550
554
|
byType: countBy(capped, (item) => item.workitemType || item.categoryId),
|
|
551
555
|
byProject: countBy(capped, (item) => item.projectCode || item.projectName).slice(0, 8),
|
|
556
|
+
byAssignee: countBy(capped, (item) => item.assignedTo?.name || "未指派").slice(0, 10),
|
|
552
557
|
trend,
|
|
553
558
|
trendUnit,
|
|
554
559
|
updated7d
|
|
@@ -824,7 +829,7 @@ function createYunxiaoApi() {
|
|
|
824
829
|
body: { status: String(statusId) }
|
|
825
830
|
});
|
|
826
831
|
for (const key of [...cache.keys()]) {
|
|
827
|
-
if (key === `workitem:${id}` || key.startsWith("workitems:") || key
|
|
832
|
+
if (key === `workitem:${id}` || key.startsWith("workitems:") || key.startsWith("workbench"))
|
|
828
833
|
cache.delete(key);
|
|
829
834
|
}
|
|
830
835
|
cacheEpoch += 1;
|
|
@@ -842,7 +847,7 @@ function createYunxiaoApi() {
|
|
|
842
847
|
workitem: async (id) => overlayItem(await workitem(id)),
|
|
843
848
|
changeRequests,
|
|
844
849
|
me,
|
|
845
|
-
workbench: async () => overlayWorkbench(await workbench()),
|
|
850
|
+
workbench: async (scope) => overlayWorkbench(await workbench(scope)),
|
|
846
851
|
repoDetail,
|
|
847
852
|
fileBlob,
|
|
848
853
|
workitemImage,
|
|
@@ -962,7 +967,7 @@ async function handle(req, res, api, ctx) {
|
|
|
962
967
|
return;
|
|
963
968
|
}
|
|
964
969
|
if (route === "/workbench") {
|
|
965
|
-
sendJson(res, 200, await api.workbench());
|
|
970
|
+
sendJson(res, 200, await api.workbench(readQuery(url, "scope") === "org" ? "org" : "mine"));
|
|
966
971
|
return;
|
|
967
972
|
}
|
|
968
973
|
if (route === "/workitem-types") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qzsy/dsh-yunxiao-panel",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Yunxiao (阿里云云效) panel for the DeepSeek Harness Web client: a cross-project workbench with charts, project/repository navigation, Projex work items, Codeup commits and merge requests.",
|
|
6
6
|
"license": "MIT",
|
package/test/render-test.mjs
CHANGED
|
@@ -54,7 +54,7 @@ const dict = {
|
|
|
54
54
|
kpiCompletion: '完成率', kpiShare: '占比', kpiOpenBugs: '{n} 个未关闭', kpiReviewHint: '点击定位到评审列表',
|
|
55
55
|
changeStatus: '改为其他状态…', markDone: '标记完成', statusSaving: '更新中…', statusFinished: '已完成',
|
|
56
56
|
statusChanged: '已改为「{name}」',
|
|
57
|
-
kpiReviewClear: '暂无待评审', heroSummary: '还有 {open} 项未完成,{bugs} 个缺陷待处理,{reviews} 个合并请求等你评审',
|
|
57
|
+
kpiReviewClear: '暂无待评审', scopeMine: '我的', scopeOrg: '组织', orgReviews: '组织待评审', byAssignee: '按负责人', assigneesUnit: '位负责人', heroSummary: '还有 {open} 项未完成,{bugs} 个缺陷待处理,{reviews} 个合并请求等你评审',
|
|
58
58
|
doneSection: '已完成 / 已关闭', statusUnit: '种状态', projectsUnit: '个项目', typesUnit: '种类型',
|
|
59
59
|
trendTotal: '合计 ', trendPeak: '峰值 ', trendLatest: '最近 ', toneTodo: '待处理', toneConfirm: '待确认',
|
|
60
60
|
toneDoing: '处理中', toneDone: '已完成', toneClosed: '已关闭',
|
|
@@ -861,6 +861,35 @@ if (container.querySelector('.yx-aside').getAttribute('data-open') !== 'false')
|
|
|
861
861
|
throw new Error('drawer stayed open after navigation')
|
|
862
862
|
}
|
|
863
863
|
|
|
864
|
+
// organization scope: the same workbench without the assignee filter
|
|
865
|
+
const workNav = [...container.querySelectorAll('.yx-nav-item')].find((button) =>
|
|
866
|
+
button.textContent.includes('我的工作台'),
|
|
867
|
+
)
|
|
868
|
+
await act(async () => {
|
|
869
|
+
workNav.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }))
|
|
870
|
+
})
|
|
871
|
+
await flush()
|
|
872
|
+
if (!calls.some((entry) => entry.includes('/workbench?scope=mine'))) throw new Error('personal scope was not requested')
|
|
873
|
+
const orgButton = [...container.querySelectorAll('.yx-scope-btn')].find((button) => button.textContent.includes('组织'))
|
|
874
|
+
if (!orgButton) throw new Error('organization scope switch missing')
|
|
875
|
+
await act(async () => {
|
|
876
|
+
orgButton.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }))
|
|
877
|
+
})
|
|
878
|
+
await flush()
|
|
879
|
+
if (!calls.some((entry) => entry.includes('/workbench?scope=org'))) throw new Error('organization scope was not requested')
|
|
880
|
+
if (container.querySelector('.yx-scope-btn[data-active="true"]')?.textContent !== '组织') {
|
|
881
|
+
throw new Error('organization scope did not become active')
|
|
882
|
+
}
|
|
883
|
+
if (dom.window.localStorage.getItem('dsh.yunxiao.workScope') !== 'org') throw new Error('scope was not remembered')
|
|
884
|
+
const mineButton = [...container.querySelectorAll('.yx-scope-btn')].find((button) => button.textContent === '我的')
|
|
885
|
+
await act(async () => {
|
|
886
|
+
mineButton.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }))
|
|
887
|
+
})
|
|
888
|
+
await flush()
|
|
889
|
+
if (container.querySelector('.yx-scope-btn[data-active="true"]')?.textContent !== '我的') {
|
|
890
|
+
throw new Error('personal scope did not come back')
|
|
891
|
+
}
|
|
892
|
+
|
|
864
893
|
console.log('render test passed')
|
|
865
894
|
console.log('sidebar label:', sidebarOptions.label(), '| order:', sidebarOptions.order)
|
|
866
895
|
console.log('chat prompt starts with:', startedPrompt.split('\n').slice(0, 2).join(' / '))
|