dsh-jira-work-overview 0.16.1 → 0.16.3
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 +27 -1
- package/README.md +3 -0
- package/README.zh.md +7 -3
- package/client.js +119 -11
- package/index.js +50 -13
- package/package.json +1 -1
- package/test/README.md +1 -0
- package/test/dsh-jira-credential.mjs +30 -1
- package/test/dsh-jira-visual.mjs +11 -3
- package/test/dsh-jira-workspace-menu.mjs +170 -0
- package/test/run-offline.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,33 @@ All notable changes to **dsh-jira-work-overview** are documented here.
|
|
|
4
4
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The first 25 releases were built in a single day, so the dates are real but the cadence was not: each entry lists what changed, not how long it took.
|
|
6
6
|
|
|
7
|
-
## [
|
|
7
|
+
## [0.16.3] - 2026-11-23
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **配置页「Jira 连接」里的服务地址现在是可编辑输入框。** 输入框默认留空、placeholder 显示当前生效的
|
|
12
|
+
地址;填好点「保存地址」(或回车)就写进当前 profile 的 Cordis patch(`baseUrl` 改成 volatile 字段),
|
|
13
|
+
保存后立刻生效,不用重装插件。只接受完整的 `http(s)` 地址(自动去掉尾部斜杠),空值 / 其它协议直接
|
|
14
|
+
拒绝并在页面上报错;「其余配置写在 cordis.patch.yml 里,这个页面只改令牌」的说明也同步改掉了。
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **没配令牌时失败提示里的「去配置」按钮看不清。** 它原来用 `.jmw-btn.primary` 的
|
|
19
|
+
`--dsw-alias-brand-primary` 当底色,浅色 / 深色主题下会变成白底白字;现在改成和配置页「保存并验证」
|
|
20
|
+
完全一致的 `.jmw-cred-btn primary` + 内联深底白字(`#4d6bfe`),并删掉了已无用的 `.jmw-btn.primary` 规则。
|
|
21
|
+
|
|
22
|
+
## [0.16.2] - 2026-11-23
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- **左栏工作区的右键菜单里「关联 Jira 项目…」会整页消失(绑定选项没了)。** 浏览器侧的插件入口是
|
|
27
|
+
**并发创建**的(`dsh-client-modules` 用 `Promise.all` 同时 `create` 每个插件),本插件只 inject
|
|
28
|
+
`slots` / `remote`,而 `contextMenus` 服务自己还要等 `locale`、`shortcuts` —— 所以 `apply()` 时它
|
|
29
|
+
经常还没 `provide`。旧代码在这里只 `ctx.get('contextMenus')` 拿一次,拿不到就跳过注册,这一页就
|
|
30
|
+
再也没有「关联 / 取消关联 Jira 项目」——面板、角标都正常,只有右键菜单少东西。现在改用
|
|
31
|
+
`ctx.inject(['contextMenus'], child => …)` 等服务出现再注册(官方 `dsh-client-ui-file-actions`
|
|
32
|
+
同款写法);老基座没有 `ctx.inject` 时退回直接注册。新增离线套件
|
|
33
|
+
`test/dsh-jira-workspace-menu.mjs` 专门模拟「服务晚到」。
|
|
8
34
|
|
|
9
35
|
## [0.16.1] - 2026-11-22
|
|
10
36
|
|
package/README.md
CHANGED
|
@@ -277,6 +277,8 @@ The current version is **0.16.0** (2026-11-20). The changelog records 30 version
|
|
|
277
277
|
| 0.14.0 | 2026-11-19 | feature | highlight follows **Jira's own priority order**; **first npm release** |
|
|
278
278
|
| 0.15.0 | 2026-11-19 | feature | transitions update **in place**, your own changes no longer notify you, typed failure hints |
|
|
279
279
|
| 0.15.1 | 2026-11-19 | **fix** | the four `/api` routes were never registered in a real host (404) |
|
|
280
|
+
| 0.16.3 | 2026-11-23 | **fix** | the Jira site URL is now an editable field in the config page (placeholder = current URL, saved to the profile Cordis patch); the failure hint's **Configure** button matches **Save and verify** |
|
|
281
|
+
| 0.16.2 | 2026-11-23 | **fix** | the workspace context menu's **Link Jira project…** could vanish for a whole page (client startup race); covered by a new offline suite |
|
|
280
282
|
| 0.16.1 | 2026-11-22 | fix | Windows notifications and *Show in file manager*, the Linux editor picker, UNC patch paths; three-OS CI and the release preflight; a planning walkthrough in both READMEs |
|
|
281
283
|
| 0.16.0 | 2026-11-20 | feature | **site-wide search**, **group by epic**, the **计划** (plan) button on every row |
|
|
282
284
|
|
|
@@ -299,6 +301,7 @@ Every user-visible defect, newest first (implementation detail is in the matchin
|
|
|
299
301
|
|
|
300
302
|
| Version | Symptom | Cause / fix |
|
|
301
303
|
| --- | --- | --- |
|
|
304
|
+
| 0.16.2 | The workspace right-click menu lost **Link Jira project…** (so there was no way to bind a project), while the panel itself kept working | Browser-side plugins are created concurrently, and this one only waits for `slots` / `remote`; `contextMenus` waits for `locale` / `shortcuts` too, so a single `ctx.get('contextMenus')` in `apply()` could see it missing and skip the registration for the whole page. It now registers through `ctx.inject(['contextMenus'], …)` once the service appears; an older host without `ctx.inject` falls back to the direct path |
|
|
302
305
|
| 0.16.1 | On Windows, new assignments and status changes produced **no notification at all** | A Windows toast must be posted under a **registered** AUMID; an unregistered one makes `CreateToastNotifier()` throw `Element not found (0x80070490)`, which was swallowed. It now tries `DSH_NOTIFY_AUMID` → `DeepSeek Harness` → `com.deepseek.harness` → the built-in PowerShell AUMID in order; the script statements are joined with newlines (`{; try … }` is a PowerShell syntax error, so nothing ran) |
|
|
303
306
|
| 0.16.1 | On Windows, *Show in file manager* opened Explorer but still reported a failure | `explorer.exe /select,` exits with code 1 even on success. That branch now tolerates a non-zero exit; only a process that never starts counts as a failure |
|
|
304
307
|
| 0.16.1 | With the profile on a network share, the config file was treated as an unknown path | Absolute-path detection only accepted `/…` and `C:\…`. It now also accepts UNC paths (`\\server\share\…`) |
|
package/README.zh.md
CHANGED
|
@@ -308,7 +308,8 @@ Jira Cloud **没有**给第三方 issue 事件的 websocket / SSE 长连接(
|
|
|
308
308
|
- **后台监视**:开关 + 检查间隔(按秒填,最小 15)+ 通知开关,下面有小字说明。
|
|
309
309
|
**这三个是「改了就生效」**:拨开关立刻写、间隔输入后失焦 / 回车立刻写(输入过程中 700ms 防抖),
|
|
310
310
|
**没有保存按钮**——只有令牌那种敏感值才需要点按钮确认落库(详见「配置」一节)。
|
|
311
|
-
- 页面按功能分成四组,每组是「标题 + 内容」:**认证令牌**(邮箱 + 令牌都能改)/ **Jira
|
|
311
|
+
- 页面按功能分成四组,每组是「标题 + 内容」:**认证令牌**(邮箱 + 令牌都能改)/ **Jira 连接**(服务地址可改:
|
|
312
|
+
输入框留空 = 不修改,placeholder 显示当前生效地址,点「保存地址」立刻写进 profile 并生效)/
|
|
312
313
|
**查询**(每次拉取条数可改 + 请求超时只读)/ **后台监视**(开关 + 间隔 + 通知,改了就生效)。
|
|
313
314
|
(项目名与看板 id 不再出现在配置页——面板上方的项目 tab 已经能自由切换项目了。)
|
|
314
315
|
- 页面底部说明「令牌只写进 DSH 凭据库 + 界面只显示打码首尾」,并给一条去 Atlassian 新建/吊销令牌的链接。
|
|
@@ -489,8 +490,8 @@ Zed(`zed`)、Sublime Text(`subl`)、gedit(`gedit`)——**找到可
|
|
|
489
490
|
**其余字段**:上面这张表是 profile 的 `cordis.patch.yml` 里那一行 `config:` 的字段(`apiToken` 除外,
|
|
490
491
|
它只为兼容旧版明文配置保留)。宿主**不会**自动给第三方插件渲染设置表单——Host 设置文档
|
|
491
492
|
(`ConfigForm` / `settingsSchema`)里也没有 secret 字段类型,所以插件自己贡献了那一行的配置页
|
|
492
|
-
|
|
493
|
-
|
|
493
|
+
(见上面「换令牌」一节):配置页负责**换令牌**、**站点地址**、**邮箱**与上面三项监视设置,`maxResults`
|
|
494
|
+
(**0 = 不限制**,正数 10–5000)也在这里改;只有超时在「查询」组里只读列出。要改只读项,
|
|
494
495
|
直接改 `cordis.patch.yml` 那一行(或让 agent 改)后重新加载插件。
|
|
495
496
|
|
|
496
497
|
## 版本与升级
|
|
@@ -530,6 +531,8 @@ Zed(`zed`)、Sublime Text(`subl`)、gedit(`gedit`)——**找到可
|
|
|
530
531
|
| 0.14.0 | 2026-11-19 | 功能 | 高亮挂到 **Jira 自己的优先级名次**;**首次发布到 npm** |
|
|
531
532
|
| 0.15.0 | 2026-11-19 | 功能 | 改状态**不再全量重拉**、自己改的状态不再通知自己、失败提示按类型 |
|
|
532
533
|
| 0.15.1 | 2026-11-19 | **修复** | 四条 `/api` 路由在真宿主里没注册(404) |
|
|
534
|
+
| 0.16.3 | 2026-11-23 | **修复** | 配置页「Jira 连接」的服务地址改成可编辑输入框(placeholder = 当前地址,写进 profile 的 Cordis patch);失败提示里的「去配置」按钮和「保存并验证」同款样式 |
|
|
535
|
+
| 0.16.2 | 2026-11-23 | **修复** | 左栏工作区右键菜单的「关联 Jira 项目…」会整页消失(客户端启动竞态);新增离线套件守住 |
|
|
533
536
|
| 0.16.1 | 2026-11-22 | 修复 | Windows 通知与「在文件管理器中显示」、Linux 编辑器直选、UNC 路径;三平台 CI 与发版预检;README 补计划会话图解 |
|
|
534
537
|
| 0.16.0 | 2026-11-20 | 功能 | **整站搜索**、**按 epic 分组**、任务行**「计划」**(plan 模式会话) |
|
|
535
538
|
|
|
@@ -553,6 +556,7 @@ plugin_manager install_bundle(target="dsh-jira-work-overview") # 已装过则
|
|
|
553
556
|
|
|
554
557
|
| 版本 | 现象 | 原因 / 处理 |
|
|
555
558
|
| --- | --- | --- |
|
|
559
|
+
| 0.16.2 | 左栏工作区的右键菜单里「关联 Jira 项目…」整页消失,没法给工作区绑项目;面板本身正常 | 浏览器侧插件是**并发创建**的,本插件只等 `slots` / `remote`,而 `contextMenus` 还要等 `locale` / `shortcuts`:`apply()` 里只 `ctx.get('contextMenus')` 拿一次,没拿到就跳过注册,这一页就再也没有这条菜单。现在改用 `ctx.inject(['contextMenus'], …)` 等服务出现再注册;老基座没有 `ctx.inject` 时退回直接注册 |
|
|
556
560
|
| 0.16.1 | Windows 上新任务 / 状态变化**一条通知都没有**(macOS 正常) | Windows 的 Toast 必须挂在一个**已注册的** AUMID 上,未注册时 `CreateToastNotifier()` 抛 `Element not found (0x80070490)`,而它被静默吞掉了。现在按 `DSH_NOTIFY_AUMID` → `DeepSeek Harness` → `com.deepseek.harness` → 系统自带的 PowerShell AUMID 依次试;脚本里的语句改用换行拼接(`{; try … }` 是 PowerShell 语法错误,整段都不执行) |
|
|
557
561
|
| 0.16.1 | Windows 上「在文件管理器中显示」明明已打开,却报 `打开失败` | `explorer.exe /select,` 成功时也返回退出码 1,被当成了失败。现在这个分支允许非零退出码,只有进程根本起不来才算失败 |
|
|
558
562
|
| 0.16.1 | profile 放在网络共享盘上时,配置文件被当成「路径未知」,打开 / 显示全都用不了 | 绝对路径判定只认 `/…` 与 `C:\…`。现在也认 UNC(`\\server\share\…`) |
|
package/client.js
CHANGED
|
@@ -214,6 +214,12 @@ window.__ModuleLoader__.load({
|
|
|
214
214
|
credGroupQuery: '查询',
|
|
215
215
|
credGroupWatch: '后台监视',
|
|
216
216
|
fBaseUrl: '服务地址',
|
|
217
|
+
baseUrlSave: '保存地址',
|
|
218
|
+
baseUrlSaving: '保存中…',
|
|
219
|
+
baseUrlSaved: 'Jira 站点地址已更新为 {baseUrl},立刻生效。',
|
|
220
|
+
baseUrlSaveFailed: '保存站点地址失败:{message}',
|
|
221
|
+
baseUrlHint: '改完点「保存地址」立刻生效(写进当前 profile 的 Cordis patch),不用重装插件;输入框留空 = 不修改。',
|
|
222
|
+
baseUrlPlaceholderFallback: 'https://your-site.atlassian.net',
|
|
217
223
|
fEmail: '账号邮箱',
|
|
218
224
|
fProject: '项目',
|
|
219
225
|
fBoard: '看板',
|
|
@@ -269,7 +275,7 @@ window.__ModuleLoader__.load({
|
|
|
269
275
|
credClearFailed: '删除失败:{message}',
|
|
270
276
|
credTokensLink: '在 Atlassian 里新建 / 吊销令牌',
|
|
271
277
|
credNote: '令牌只写进 DSH 凭据库,界面永远只显示打码首尾;换完立刻生效,不用重启 DSH。',
|
|
272
|
-
credOther: '
|
|
278
|
+
credOther: '其余配置(超时、项目、看板等)写在 profile 的 cordis.patch.yml 里;这个页面改令牌、邮箱、站点地址与监视设置。',
|
|
273
279
|
credOpen: '配置',
|
|
274
280
|
credClose: '收起令牌设置',
|
|
275
281
|
patchTitle: '配置文件',
|
|
@@ -442,6 +448,12 @@ window.__ModuleLoader__.load({
|
|
|
442
448
|
credGroupQuery: 'Query',
|
|
443
449
|
credGroupWatch: 'Background watch',
|
|
444
450
|
fBaseUrl: 'Base URL',
|
|
451
|
+
baseUrlSave: 'Save URL',
|
|
452
|
+
baseUrlSaving: 'Saving…',
|
|
453
|
+
baseUrlSaved: 'Jira site URL updated to {baseUrl}; effective immediately.',
|
|
454
|
+
baseUrlSaveFailed: 'Saving the site URL failed: {message}',
|
|
455
|
+
baseUrlHint: 'Click "Save URL" to apply it immediately (it is written into the current profile\'s Cordis patch) — no reinstall needed; leave the field empty to keep the current value.',
|
|
456
|
+
baseUrlPlaceholderFallback: 'https://your-site.atlassian.net',
|
|
445
457
|
fEmail: 'Account email',
|
|
446
458
|
fProject: 'Project',
|
|
447
459
|
fBoard: 'Board',
|
|
@@ -497,7 +509,7 @@ window.__ModuleLoader__.load({
|
|
|
497
509
|
credClearFailed: 'Removing failed: {message}',
|
|
498
510
|
credTokensLink: 'Create or revoke tokens at Atlassian',
|
|
499
511
|
credNote: 'The token goes into the DSH credential store only, and the UI ever shows the masked head and tail; a saved token takes effect at once, no restart needed.',
|
|
500
|
-
credOther: 'The rest of the configuration (
|
|
512
|
+
credOther: 'The rest of the configuration (timeout, project, board…) lives in the profile\'s cordis.patch.yml; this page changes the token, email, site URL and watch settings.',
|
|
501
513
|
credOpen: 'Configure',
|
|
502
514
|
credClose: 'Hide token settings',
|
|
503
515
|
patchTitle: 'Configuration file',
|
|
@@ -1881,8 +1893,6 @@ window.__ModuleLoader__.load({
|
|
|
1881
1893
|
background:var(--dsw-alias-interactive-bg-hover,rgba(38,49,72,.06));border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));
|
|
1882
1894
|
border-radius:var(--dsw-radius-sm,8px)}
|
|
1883
1895
|
.jmw-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(38,49,72,.1))}
|
|
1884
|
-
.jmw-btn.primary{color:#fff;background:var(--dsw-alias-brand-primary,#4d6bfe);border-color:transparent}
|
|
1885
|
-
.jmw-btn.primary:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 86%,#000)}
|
|
1886
1896
|
.jmw-skel{height:13px;margin:12px 40px;border-radius:7px;
|
|
1887
1897
|
background:linear-gradient(90deg,transparent,var(--dsw-alias-interactive-bg-hover,rgba(38,49,72,.08)),transparent);
|
|
1888
1898
|
background-size:220px 100%;animation:jmw-pulse 1.1s ease-in-out infinite}
|
|
@@ -2706,7 +2716,10 @@ window.__ModuleLoader__.load({
|
|
|
2706
2716
|
actions.push(h('button', {
|
|
2707
2717
|
key: 'config',
|
|
2708
2718
|
type: 'button',
|
|
2709
|
-
|
|
2719
|
+
// 和配置页里的「保存并验证」用同一套按钮样式(类 + 内联兜底色),
|
|
2720
|
+
// 别再用 .jmw-btn.primary —— 它在浅色/深色主题下会跟着品牌色变成白底白字。
|
|
2721
|
+
className: 'jmw-cred-btn primary',
|
|
2722
|
+
style: BTN_PRIMARY,
|
|
2710
2723
|
onClick: () => setCredOpen(true),
|
|
2711
2724
|
}, t('failOpenConfig')));
|
|
2712
2725
|
}
|
|
@@ -3120,6 +3133,11 @@ window.__ModuleLoader__.load({
|
|
|
3120
3133
|
// 账号邮箱是可改字段,和令牌一起保存(Basic 认证 = 邮箱 + 令牌)。
|
|
3121
3134
|
email: '',
|
|
3122
3135
|
emailTouched: false,
|
|
3136
|
+
// Jira 站点地址:输入框默认留空、placeholder 显示当前生效地址;填了才写。
|
|
3137
|
+
baseUrlDraft: '',
|
|
3138
|
+
baseUrlBusy: false,
|
|
3139
|
+
baseUrlMessage: '',
|
|
3140
|
+
baseUrlError: '',
|
|
3123
3141
|
busy: '',
|
|
3124
3142
|
message: '',
|
|
3125
3143
|
error: '',
|
|
@@ -3139,6 +3157,7 @@ window.__ModuleLoader__.load({
|
|
|
3139
3157
|
let watchDebounce = null;
|
|
3140
3158
|
let watchFlashTimer = null;
|
|
3141
3159
|
let patchFlashTimer = null;
|
|
3160
|
+
let baseUrlFlashTimer = null;
|
|
3142
3161
|
|
|
3143
3162
|
function readWatch(payload, previous) {
|
|
3144
3163
|
const watch = payload?.watch ?? previous?.watch ?? null;
|
|
@@ -3232,6 +3251,38 @@ window.__ModuleLoader__.load({
|
|
|
3232
3251
|
return state.email.trim() !== current;
|
|
3233
3252
|
}
|
|
3234
3253
|
|
|
3254
|
+
// 站点地址:写进当前 profile 的 Cordis patch(volatile 字段),下一次请求就用新地址。
|
|
3255
|
+
// 输入框本身留空、placeholder 显示当前值;空输入不发请求(= 不修改)。
|
|
3256
|
+
async function saveBaseUrl() {
|
|
3257
|
+
const value = state.baseUrlDraft.trim();
|
|
3258
|
+
if (!value) return;
|
|
3259
|
+
clearTimeout(baseUrlFlashTimer);
|
|
3260
|
+
setState((prev) => ({ ...prev, baseUrlBusy: true, baseUrlMessage: '', baseUrlError: '' }));
|
|
3261
|
+
try {
|
|
3262
|
+
const response = await watchFetch(SETTINGS_PATH, {
|
|
3263
|
+
method: 'POST',
|
|
3264
|
+
headers: { accept: 'application/json', 'content-type': 'application/json' },
|
|
3265
|
+
body: JSON.stringify({ baseUrl: value }),
|
|
3266
|
+
});
|
|
3267
|
+
const payload = await response.json().catch(() => null);
|
|
3268
|
+
if (payload?.ok !== true) throw new Error(payload?.error || `HTTP ${response.status}`);
|
|
3269
|
+
setState((prev) => ({
|
|
3270
|
+
...prev,
|
|
3271
|
+
baseUrlBusy: false,
|
|
3272
|
+
baseUrlDraft: '',
|
|
3273
|
+
baseUrlError: '',
|
|
3274
|
+
baseUrlMessage: t('baseUrlSaved', { baseUrl: String(payload?.applied?.baseUrl ?? value) }),
|
|
3275
|
+
// 保存成功顺带刷新一遍状态:placeholder 立刻显示新的生效地址。
|
|
3276
|
+
...readWatch(payload, prev),
|
|
3277
|
+
}));
|
|
3278
|
+
baseUrlFlashTimer = setTimeout(() => setState((prev) => ({ ...prev, baseUrlMessage: '' })), 2600);
|
|
3279
|
+
if (typeof baseUrlFlashTimer?.unref === 'function') baseUrlFlashTimer.unref();
|
|
3280
|
+
void refresh();
|
|
3281
|
+
} catch (error) {
|
|
3282
|
+
setState((prev) => ({ ...prev, baseUrlBusy: false, baseUrlError: t('baseUrlSaveFailed', { message: String(error?.message ?? error) }) }));
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3235
3286
|
// 监视设置「改了就生效」:开关一拨、间隔一改就写进当前 profile 的 Cordis patch,
|
|
3236
3287
|
// 不需要「保存」按钮(只有令牌那种敏感值才需要显式确认后再落库)。
|
|
3237
3288
|
async function pushWatch(patch) {
|
|
@@ -3509,7 +3560,43 @@ window.__ModuleLoader__.load({
|
|
|
3509
3560
|
h('a', { key: 'tokens', className: 'jmw-cred-link', href: TOKENS_URL, target: '_blank', rel: 'noreferrer' }, t('credTokensLink')),
|
|
3510
3561
|
]),
|
|
3511
3562
|
credGroup('connection', t('credGroupConnection'), [
|
|
3512
|
-
|
|
3563
|
+
// 站点地址改成可编辑输入框:留空 = 不修改,placeholder 显示当前生效的地址。
|
|
3564
|
+
h('div', { key: 'baseUrl', className: 'jmw-cred-form' }, [
|
|
3565
|
+
h('label', { key: 'label', className: 'jmw-cred-label', htmlFor: 'jmw-base-url' }, t('fBaseUrl')),
|
|
3566
|
+
h('input', {
|
|
3567
|
+
key: 'input',
|
|
3568
|
+
id: 'jmw-base-url',
|
|
3569
|
+
className: 'jmw-cred-input',
|
|
3570
|
+
type: 'url',
|
|
3571
|
+
inputMode: 'url',
|
|
3572
|
+
autoComplete: 'off',
|
|
3573
|
+
spellCheck: false,
|
|
3574
|
+
placeholder: String(settings.baseUrl ?? '') || t('baseUrlPlaceholderFallback'),
|
|
3575
|
+
value: state.baseUrlDraft,
|
|
3576
|
+
onInput: (event) => setState((prev) => ({
|
|
3577
|
+
...prev,
|
|
3578
|
+
baseUrlDraft: event?.target?.value ?? '',
|
|
3579
|
+
baseUrlMessage: '',
|
|
3580
|
+
baseUrlError: '',
|
|
3581
|
+
})),
|
|
3582
|
+
onKeyDown: (event) => {
|
|
3583
|
+
if (event?.key === 'Enter') void saveBaseUrl();
|
|
3584
|
+
},
|
|
3585
|
+
}),
|
|
3586
|
+
h('div', { key: 'actions', className: 'jmw-cred-actions' }, [
|
|
3587
|
+
h('button', {
|
|
3588
|
+
key: 'save',
|
|
3589
|
+
type: 'button',
|
|
3590
|
+
className: 'jmw-cred-btn primary',
|
|
3591
|
+
style: BTN_PRIMARY,
|
|
3592
|
+
disabled: state.baseUrlBusy === true || state.baseUrlDraft.trim() === '',
|
|
3593
|
+
onClick: () => { void saveBaseUrl(); },
|
|
3594
|
+
}, state.baseUrlBusy ? t('baseUrlSaving') : t('baseUrlSave')),
|
|
3595
|
+
]),
|
|
3596
|
+
h('div', { key: 'hint', className: 'jmw-cred-hint' }, t('baseUrlHint')),
|
|
3597
|
+
state.baseUrlMessage ? h('div', { key: 'message', className: 'jmw-cred-msg ok' }, state.baseUrlMessage) : null,
|
|
3598
|
+
state.baseUrlError ? h('div', { key: 'error', className: 'jmw-cred-msg err' }, state.baseUrlError) : null,
|
|
3599
|
+
]),
|
|
3513
3600
|
]),
|
|
3514
3601
|
credGroup('query', t('credGroupQuery'), [
|
|
3515
3602
|
h('div', { key: 'results', className: 'jmw-cred-row' }, [
|
|
@@ -3740,15 +3827,21 @@ window.__ModuleLoader__.load({
|
|
|
3740
3827
|
}, CredentialSettings));
|
|
3741
3828
|
|
|
3742
3829
|
// 左栏「工作区」行的右键菜单:关联 / 取消关联 Jira 项目。
|
|
3743
|
-
// 结构化菜单是抽象贡献(不是 React
|
|
3744
|
-
|
|
3745
|
-
|
|
3830
|
+
// 结构化菜单是抽象贡献(不是 React 组件),只能注册在 dsh-client-ui-context-menu 的
|
|
3831
|
+
// `contextMenus` 服务上。**这个服务不保证在本插件 apply 时已经就绪**:浏览器侧的插件入口
|
|
3832
|
+
// 是并发创建的,本插件只 inject 了 slots / remote,而 contextMenus 自己还要等 locale、
|
|
3833
|
+
// shortcuts(0.16.1 及以前这里直接 ctx.get 一次,拿到 undefined 就整页都没有这条菜单 ——
|
|
3834
|
+
// 「关联 Jira 项目…」随机消失就是这么来的)。现在用 ctx.inject 等它出现再注册;
|
|
3835
|
+
// 老基座没有 ctx.inject 时退回直接注册。
|
|
3836
|
+
function registerWorkspaceProjectMenu(host) {
|
|
3837
|
+
const contextMenus = typeof host.get === 'function' ? host.get('contextMenus') : undefined;
|
|
3838
|
+
if (!contextMenus || typeof contextMenus.register !== 'function') return;
|
|
3746
3839
|
try {
|
|
3747
|
-
|
|
3840
|
+
host.effect?.(() => contextMenus.register({
|
|
3748
3841
|
id: `${PLUGIN_ID}.workspace-project`,
|
|
3749
3842
|
target: 'workspace',
|
|
3750
3843
|
order: 500,
|
|
3751
|
-
observe: () => [
|
|
3844
|
+
observe: () => [host.get('workspaces')?.list].filter(Boolean),
|
|
3752
3845
|
resolve: (target) => {
|
|
3753
3846
|
const entries = [projectMenuEntry(target)];
|
|
3754
3847
|
const unlink = projectUnlinkEntry(target);
|
|
@@ -3760,6 +3853,21 @@ window.__ModuleLoader__.load({
|
|
|
3760
3853
|
console.warn(`${NS}: workspace menu unavailable`, error);
|
|
3761
3854
|
}
|
|
3762
3855
|
}
|
|
3856
|
+
if (typeof ctx.inject === 'function') {
|
|
3857
|
+
ctx.inject(['contextMenus'], (child) => {
|
|
3858
|
+
try {
|
|
3859
|
+
registerWorkspaceProjectMenu(child);
|
|
3860
|
+
} catch (error) {
|
|
3861
|
+
console.warn(`${NS}: workspace menu unavailable`, error);
|
|
3862
|
+
}
|
|
3863
|
+
});
|
|
3864
|
+
} else {
|
|
3865
|
+
try {
|
|
3866
|
+
registerWorkspaceProjectMenu(ctx);
|
|
3867
|
+
} catch (error) {
|
|
3868
|
+
console.warn(`${NS}: workspace menu unavailable`, error);
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3763
3871
|
|
|
3764
3872
|
// 侧栏会话行:角标(工作区关联的项目)与 hover 卡片一行。两个都是可选的洞,缺了不影响面板。
|
|
3765
3873
|
ctx.slots.inject('sidebar.session.row.trailing', () => ctx.slots.register({
|
package/index.js
CHANGED
|
@@ -295,6 +295,8 @@ const TEXT = {
|
|
|
295
295
|
'err.noCredential': 'Jira 凭据缺失:请把 {key} 写进 DSH 凭据库、设为环境变量,或填进插件配置的 apiToken。',
|
|
296
296
|
'err.credentialUnreadable': '读不出 DSH 凭据库里的 {key}:{message}',
|
|
297
297
|
'err.noBaseUrl': '还没有配置 Jira 站点地址:打开面板标题右侧的「配置」填上 baseUrl(例如 https://your-site.atlassian.net),或在 profile 的 cordis.patch.yml 那一行里加 baseUrl。',
|
|
298
|
+
'err.baseUrlRequired': '请填上 Jira 站点地址(例如 https://your-site.atlassian.net)。',
|
|
299
|
+
'err.invalidBaseUrl': '「{value}」不是有效的 Jira 站点地址:要完整的 http(s) 地址,例如 https://your-site.atlassian.net。',
|
|
298
300
|
'err.noEmail': 'Jira 配置缺少 email:Basic 认证需要登录邮箱。',
|
|
299
301
|
'err.network': '连不上 {baseUrl}({path}):{cause}',
|
|
300
302
|
'err.http': 'Jira {status} {statusText}({path}):{detail}',
|
|
@@ -496,6 +498,8 @@ const TEXT = {
|
|
|
496
498
|
'err.noCredential': 'Missing Jira credential: put {key} into the DSH credential store, set it as an environment variable, or fill apiToken in the plugin config.',
|
|
497
499
|
'err.credentialUnreadable': 'Could not read {key} from the DSH credential store: {message}',
|
|
498
500
|
'err.noBaseUrl': 'No Jira site URL yet: open the "Configure" dialog in the panel header and set baseUrl (for example https://your-site.atlassian.net), or add baseUrl to this profile\'s cordis.patch.yml row.',
|
|
501
|
+
'err.baseUrlRequired': 'Enter the Jira site URL (for example https://your-site.atlassian.net).',
|
|
502
|
+
'err.invalidBaseUrl': '"{value}" is not a valid Jira site URL: use a full http(s) address such as https://your-site.atlassian.net.',
|
|
499
503
|
'err.noEmail': 'Missing email in the Jira config: Basic auth requires a login email.',
|
|
500
504
|
'err.network': 'Cannot reach {baseUrl} ({path}): {cause}',
|
|
501
505
|
'err.http': 'Jira {status} {statusText} ({path}): {detail}',
|
|
@@ -723,8 +727,12 @@ export const inject = ['tools'];
|
|
|
723
727
|
* `apiToken` 只为兼容旧版明文配置保留,首次加载后会迁移走。
|
|
724
728
|
*/
|
|
725
729
|
export const Config = Schema.object({
|
|
730
|
+
// 站点地址是「运行时可改」的:配置页里是一个可编辑输入框,改完立刻生效(不用重装插件)。
|
|
731
|
+
// 因此和邮箱 / 监视设置一样标成 volatile —— 只有 volatile 字段才能经宿主 settings 服务写回
|
|
732
|
+
// 当前 profile 的 Cordis patch,并由 Loader 提交到运行中的引用。
|
|
726
733
|
baseUrl: Schema.string()
|
|
727
734
|
.default(DEFAULTS.baseUrl)
|
|
735
|
+
.volatile()
|
|
728
736
|
.description(t('config.baseUrl')),
|
|
729
737
|
email: Schema.string().default('').volatile().description(t('config.email')),
|
|
730
738
|
credentialKey: Schema.string()
|
|
@@ -1046,6 +1054,31 @@ function limitOf(settings) {
|
|
|
1046
1054
|
return normalizeLimit(liveSetting(settings, 'maxResults', DEFAULTS.maxResults));
|
|
1047
1055
|
}
|
|
1048
1056
|
|
|
1057
|
+
/**
|
|
1058
|
+
* 站点根地址(volatile,配置页可改):每次现读,去首尾空白、去尾部斜杠。
|
|
1059
|
+
* 改成 volatile 之后 `settings.baseUrl` 在运行时是引用对象,必须走 liveSetting 脱壳。
|
|
1060
|
+
*/
|
|
1061
|
+
function baseUrlOf(settings) {
|
|
1062
|
+
const value = liveSetting(settings, 'baseUrl', '');
|
|
1063
|
+
return typeof value === 'string' ? value.trim().replace(/\/+$/, '') : '';
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/** 配置页写入的站点地址必须是完整的 http(s) URL;空串 / 其它协议一律拒绝。 */
|
|
1067
|
+
function normalizeBaseUrl(value) {
|
|
1068
|
+
const text = String(unwrapValue(value) ?? '').trim().replace(/\/+$/, '');
|
|
1069
|
+
if (!text) throw new Error(t('err.baseUrlRequired'));
|
|
1070
|
+
let url;
|
|
1071
|
+
try {
|
|
1072
|
+
url = new URL(text);
|
|
1073
|
+
} catch {
|
|
1074
|
+
throw new Error(t('err.invalidBaseUrl', { value: text }));
|
|
1075
|
+
}
|
|
1076
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
1077
|
+
throw new Error(t('err.invalidBaseUrl', { value: text }));
|
|
1078
|
+
}
|
|
1079
|
+
return text;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1049
1082
|
function normalizeConfig(config) {
|
|
1050
1083
|
const raw = config && typeof config === 'object' ? config : {};
|
|
1051
1084
|
const settings = { ...DEFAULTS };
|
|
@@ -1108,9 +1141,9 @@ function createJira(ctx, settings) {
|
|
|
1108
1141
|
/** 优先级顺序缓存 `{ ranks: Map, expires: number }`;见 priorityRanks()。 */
|
|
1109
1142
|
priorityCache: null,
|
|
1110
1143
|
|
|
1111
|
-
/**
|
|
1144
|
+
/** 站点地址(必填):每次现读 volatile 值,配置页改完立刻生效。 */
|
|
1112
1145
|
site() {
|
|
1113
|
-
return
|
|
1146
|
+
return baseUrlOf(settings);
|
|
1114
1147
|
},
|
|
1115
1148
|
|
|
1116
1149
|
/** 每个入口(工具 / 命令 / 路由 / 轮询)开工前同步一次语言。 */
|
|
@@ -1170,7 +1203,7 @@ function createJira(ctx, settings) {
|
|
|
1170
1203
|
query.set(name, String(value));
|
|
1171
1204
|
}
|
|
1172
1205
|
const qs = query.toString();
|
|
1173
|
-
const url = `${
|
|
1206
|
+
const url = `${this.site()}${path}${qs ? `?${qs}` : ''}`;
|
|
1174
1207
|
|
|
1175
1208
|
const auth = Buffer.from(`${this.email()}:${token}`, 'utf8').toString('base64');
|
|
1176
1209
|
let response;
|
|
@@ -1185,7 +1218,7 @@ function createJira(ctx, settings) {
|
|
|
1185
1218
|
// 这里把 cause 里的真实原因带出来,方便自查。
|
|
1186
1219
|
if (signal?.aborted) throw error;
|
|
1187
1220
|
const cause = error?.cause?.code ?? error?.cause?.message ?? error?.message ?? error;
|
|
1188
|
-
throw new JiraError('network', t('err.network', { baseUrl:
|
|
1221
|
+
throw new JiraError('network', t('err.network', { baseUrl: this.site(), path, cause }));
|
|
1189
1222
|
}
|
|
1190
1223
|
const text = await response.text();
|
|
1191
1224
|
|
|
@@ -1212,7 +1245,7 @@ function createJira(ctx, settings) {
|
|
|
1212
1245
|
|
|
1213
1246
|
let response;
|
|
1214
1247
|
try {
|
|
1215
|
-
response = await fetch(`${
|
|
1248
|
+
response = await fetch(`${this.site()}${path}`, {
|
|
1216
1249
|
method: 'POST',
|
|
1217
1250
|
headers: {
|
|
1218
1251
|
Authorization: `Basic ${auth}`,
|
|
@@ -1225,7 +1258,7 @@ function createJira(ctx, settings) {
|
|
|
1225
1258
|
} catch (error) {
|
|
1226
1259
|
if (signal?.aborted) throw error;
|
|
1227
1260
|
const cause = error?.cause?.code ?? error?.cause?.message ?? error?.message ?? error;
|
|
1228
|
-
throw new JiraError('network', t('err.network', { baseUrl:
|
|
1261
|
+
throw new JiraError('network', t('err.network', { baseUrl: this.site(), path, cause }));
|
|
1229
1262
|
}
|
|
1230
1263
|
|
|
1231
1264
|
const text = await response.text();
|
|
@@ -2149,7 +2182,7 @@ function registerTransitionRoute(ctx, jira) {
|
|
|
2149
2182
|
*/
|
|
2150
2183
|
function publicSettings(settings) {
|
|
2151
2184
|
return {
|
|
2152
|
-
baseUrl: settings
|
|
2185
|
+
baseUrl: baseUrlOf(settings),
|
|
2153
2186
|
email: liveSetting(settings, 'email', '') || t('err.emailNotSet'),
|
|
2154
2187
|
projectKey: settings.projectKey,
|
|
2155
2188
|
boardId: settings.boardId,
|
|
@@ -2281,7 +2314,7 @@ async function resolveToken(ctx, settings) {
|
|
|
2281
2314
|
async function verifyCredential(settings, token, signal, email) {
|
|
2282
2315
|
const account = typeof email === 'string' && email ? email : liveSetting(settings, 'email', '');
|
|
2283
2316
|
const auth = Buffer.from(`${account}:${token}`, 'utf8').toString('base64');
|
|
2284
|
-
const response = await fetch(`${settings
|
|
2317
|
+
const response = await fetch(`${baseUrlOf(settings)}/rest/api/3/myself`, {
|
|
2285
2318
|
headers: { Authorization: `Basic ${auth}`, Accept: 'application/json' },
|
|
2286
2319
|
signal,
|
|
2287
2320
|
});
|
|
@@ -2435,6 +2468,10 @@ async function writeSettings(ctx, settings, patch) {
|
|
|
2435
2468
|
if (typeof patch?.email === 'string' && patch.email.trim()) {
|
|
2436
2469
|
ops.push({ op: 'set', path: ['email'], value: patch.email.trim() });
|
|
2437
2470
|
}
|
|
2471
|
+
// 站点地址(配置页里的可编辑输入框):必须是完整的 http(s) URL,否则抛错、不写。
|
|
2472
|
+
if (Object.prototype.hasOwnProperty.call(patch ?? {}, 'baseUrl')) {
|
|
2473
|
+
ops.push({ op: 'set', path: ['baseUrl'], value: normalizeBaseUrl(patch.baseUrl) });
|
|
2474
|
+
}
|
|
2438
2475
|
const language = String(unwrapValue(patch?.language) ?? '').trim().toLowerCase();
|
|
2439
2476
|
if (language === 'auto' || language === 'zh' || language === 'en') {
|
|
2440
2477
|
ops.push({ op: 'set', path: ['language'], value: language });
|
|
@@ -3086,7 +3123,7 @@ async function fetchPlanIssue(jira, key, signal) {
|
|
|
3086
3123
|
parentSummary: String(fields.parent?.fields?.summary ?? '').trim(),
|
|
3087
3124
|
hasDescription: hasPlanDescription(fields.description),
|
|
3088
3125
|
links: Array.isArray(fields.issuelinks) ? fields.issuelinks.length : 0,
|
|
3089
|
-
url: `${jira.
|
|
3126
|
+
url: `${jira.site()}/browse/${body?.key ?? key}`,
|
|
3090
3127
|
};
|
|
3091
3128
|
}
|
|
3092
3129
|
|
|
@@ -3528,7 +3565,7 @@ function transitionTool(jira, settings) {
|
|
|
3528
3565
|
return [
|
|
3529
3566
|
t('transition.updated', { key }),
|
|
3530
3567
|
t('transition.updatedLine', { from: info.current || '—', to: result.status, id: match.id, name: match.name }),
|
|
3531
|
-
`- ${jira.
|
|
3568
|
+
`- ${jira.site()}/browse/${key}`,
|
|
3532
3569
|
].join('\n');
|
|
3533
3570
|
},
|
|
3534
3571
|
};
|
|
@@ -3684,7 +3721,7 @@ function renderWorkList(issues, jql, scope, jira, limitHit) {
|
|
|
3684
3721
|
t('list.header', { scope: scopeLabel(scope), count: issues.length }),
|
|
3685
3722
|
'',
|
|
3686
3723
|
t('list.meta', {
|
|
3687
|
-
baseUrl: settings
|
|
3724
|
+
baseUrl: baseUrlOf(settings),
|
|
3688
3725
|
project: projectSummary(issues, settings.projectKey),
|
|
3689
3726
|
account: liveSetting(settings, 'email', '') || t('list.accountMissing'),
|
|
3690
3727
|
}),
|
|
@@ -3981,7 +4018,7 @@ function buildItemJson(issue, jira, ranks) {
|
|
|
3981
4018
|
sprintState: typeof sprint?.state === 'string' ? sprint.state : '',
|
|
3982
4019
|
sprintStart: typeof sprint?.startDate === 'string' ? sprint.startDate.slice(0, 10) : '',
|
|
3983
4020
|
sprintEnd: typeof sprint?.endDate === 'string' ? sprint.endDate.slice(0, 10) : '',
|
|
3984
|
-
url: key ? `${jira.
|
|
4021
|
+
url: key ? `${jira.site()}/browse/${key}` : jira.site(),
|
|
3985
4022
|
};
|
|
3986
4023
|
}
|
|
3987
4024
|
|
|
@@ -4027,7 +4064,7 @@ function renderIssue(issue, options) {
|
|
|
4027
4064
|
if (typeof fields.updated === 'string') meta.push(t('issue.meta.updated', { value: fields.updated.replace('T', ' ').slice(0, 16) }));
|
|
4028
4065
|
|
|
4029
4066
|
if (meta.length) lines.push('', meta.join(' · '));
|
|
4030
|
-
if (issue?.key) lines.push('', t('issue.link', { url: `${options.settings
|
|
4067
|
+
if (issue?.key) lines.push('', t('issue.link', { url: `${baseUrlOf(options.settings)}/browse/${issue.key}` }));
|
|
4031
4068
|
|
|
4032
4069
|
lines.push('', t('issue.descriptionHeader'), '', adfToText(fields.description).trim() || t('issue.noDescription'));
|
|
4033
4070
|
|
package/package.json
CHANGED
package/test/README.md
CHANGED
|
@@ -50,6 +50,7 @@ skip without `JIRA_*` credentials (no secrets are configured on purpose — this
|
|
|
50
50
|
| `dsh-jira-visual.mjs` | no | rendering: grouping, collapse, project tabs, status filter, header total, priority highlight, **virtualization** (windowed DOM vs. placeholder height), **in-place status change** (no `/jira` re-fetch, local row + counts), fallback when `@tanstack/react-virtual` is missing |
|
|
51
51
|
| `dsh-jira-selfwatch.mjs` | no | the watch loop's diff: someone else's status change notifies, a change **you** made (panel POST or `jira_transition`) is swallowed and its baseline advanced, a colleague changing it right afterwards still notifies, a failed write leaves no stale expectation |
|
|
52
52
|
| `dsh-jira-plan.mjs` | no | the per-row **「计划」 button** end to end: a planning session is created in the project's linked workspace, `/plan` runs before the first message, that message carries the `JIRA_PLAN_SESSION:<KEY>` token plus the "only report the changes to make" / "stop if the issue is unclear" rules, a second click reuses the same session (local binding, then a token search through the session log), gaps are listed for a thin issue, and a missing workspace / plan-mode policy fails loudly |
|
|
53
|
+
| `dsh-jira-workspace-menu.mjs` | no | the workspace context menu **when `contextMenus` arrives late**: the plugin waits for the service via `ctx.inject` (a single `ctx.get` at apply used to lose the 「关联 Jira 项目…」 entry for the whole page), then registers a `workspace` contribution whose entry opens the panel and reads the link mapping; also covers the older host without `ctx.inject` |
|
|
53
54
|
| `dsh-jira-credential.mjs` | no | configure dialog + all six fetch routes: token/email save, verification and rejection, masked value, two-step clear, watch/language/fetch-size writes, paging (`--limit=0`, safety cap) |
|
|
54
55
|
| `dsh-jira-i18n.mjs` | no | language matrix (`DSH_JIRA_LANG`, `--lang`, `?lang`, config, host preference), Jira data kept verbatim, dictionary parity (zh/en key sets), host paging assertions, the "open `cordis.patch.yml`" route |
|
|
55
56
|
| `dsh-jira-platform.mjs` | no | **platform dispatch, verified without a VM**: forces `process.platform` and puts fake `cmd.exe` / `explorer.exe` / `rundll32.exe` / `powershell.exe` / `where` / `xdg-open` / `notify-send` shims on `PATH` that only log their `argv`, so every platform branch really spawns something and the test asserts the exact command + arguments (open / reveal / choose / custom app / editor picker / Unix `PATH` split / `X_OK` check / UNC patch path / `explorer.exe` exit code 1 / toast script and its AUMID fallback list) |
|
|
@@ -560,7 +560,7 @@ console.log('未配置时显示:', field(page, 'jmw-cred-none') !== undefined, '
|
|
|
560
560
|
console.log('输入框存在:', field(page, 'jmw-cred-input') !== undefined, '| 邮箱输入框:', field(page, 'jmw-cred-email') !== undefined,
|
|
561
561
|
'| 邮箱回填:', field(page, 'jmw-cred-email')?.props?.value);
|
|
562
562
|
console.log('保存按钮禁用(没输入、邮箱也没改):', buttonByText(page, '保存并验证')?.props.disabled === true);
|
|
563
|
-
console.log('
|
|
563
|
+
console.log('站点地址是可编辑输入框:', collect(page, (row) => row.type === 'input' && row.props?.id === 'jmw-base-url').length === 1, '| 键值对(只读项):', collect(page, (row) => String(row.props?.className ?? '') === 'jmw-cred-pair').map((row) => text(row)).join(' ').slice(0, 90));
|
|
564
564
|
console.log('页面上有凭据库键说明:', text(page).includes('JIRA_API_TOKEN'), '| 有 Atlassian 链接:', collect(page, (row) => row.type === 'a' && String(row.props.href).includes('api-tokens')).length === 1);
|
|
565
565
|
|
|
566
566
|
const input = field(page, 'jmw-cred-input');
|
|
@@ -662,6 +662,35 @@ if (resultsInput) {
|
|
|
662
662
|
console.log('输入 0 → 自动写入:', settingsWrites.length > beforeZero, '| maxResults:', zeroWrite?.ops.find((op) => op.path[0] === 'maxResults')?.value, '(期望 0 = 不限制)');
|
|
663
663
|
credPage = renderCred('page');
|
|
664
664
|
}
|
|
665
|
+
// 站点地址:可编辑输入框,placeholder 显示当前生效地址;填了就写进 profile 的 Cordis patch
|
|
666
|
+
const baseUrlInput = () => collect(credPage, (row) => row.type === 'input' && row.props?.id === 'jmw-base-url')[0];
|
|
667
|
+
console.log('站点地址输入框:', baseUrlInput() !== undefined, '| 初始值:', JSON.stringify(baseUrlInput()?.props?.value ?? null),
|
|
668
|
+
'| placeholder = 当前地址:', baseUrlInput()?.props?.placeholder);
|
|
669
|
+
console.log('空输入时保存按钮禁用:', buttonByText(credPage, '保存地址')?.props?.disabled === true);
|
|
670
|
+
if (baseUrlInput()) {
|
|
671
|
+
baseUrlInput().props.onInput({ target: { value: 'https://new-site.atlassian.net/' } });
|
|
672
|
+
credPage = renderCred('page');
|
|
673
|
+
console.log('输入后保存按钮可用:', buttonByText(credPage, '保存地址')?.props?.disabled === false);
|
|
674
|
+
const beforeBaseUrl = settingsWrites.length;
|
|
675
|
+
buttonByText(credPage, '保存地址').props.onClick();
|
|
676
|
+
await wait(200);
|
|
677
|
+
credPage = renderCred('page');
|
|
678
|
+
const baseUrlWrite = settingsWrites[settingsWrites.length - 1];
|
|
679
|
+
console.log('保存地址 → 写入 profile patch:', settingsWrites.length > beforeBaseUrl,
|
|
680
|
+
'| baseUrl:', baseUrlWrite?.ops.find((op) => op.path[0] === 'baseUrl')?.value, '(尾斜杠应去掉)');
|
|
681
|
+
console.log(' placeholder 已更新为新地址:', baseUrlInput()?.props?.placeholder);
|
|
682
|
+
console.log(' 输入框已清空:', (baseUrlInput()?.props?.value ?? '') === '');
|
|
683
|
+
console.log(' 成功提示:', collect(credPage, (row) => classNameOf(row).includes('jmw-cred-msg') && classNameOf(row).includes('ok')).map((row) => text(row).trim()).join(' | ') || '(没有)');
|
|
684
|
+
// 非法地址:host 拒绝,界面报错且不写入
|
|
685
|
+
baseUrlInput().props.onInput({ target: { value: 'not a url' } });
|
|
686
|
+
credPage = renderCred('page');
|
|
687
|
+
const beforeBad = settingsWrites.length;
|
|
688
|
+
buttonByText(credPage, '保存地址').props.onClick();
|
|
689
|
+
await wait(200);
|
|
690
|
+
credPage = renderCred('page');
|
|
691
|
+
console.log('非法地址 → 被拒:', settingsWrites.length === beforeBad,
|
|
692
|
+
'| 错误文案:', collect(credPage, (row) => classNameOf(row).includes('jmw-cred-msg') && classNameOf(row).includes('err')).map((row) => text(row).trim()).join(' | '));
|
|
693
|
+
}
|
|
665
694
|
// 界面语言:三个 chip(自动 / 中文 / English),点了立刻写进 profile 的 Cordis patch
|
|
666
695
|
// 迷你 React 不保留 key,所以按「文本是三种语言名之一」来找(配置页里不会同时出现状态下拉的 chip)
|
|
667
696
|
const LANG_LABELS = ['自动', '中文', 'English'];
|
package/test/dsh-jira-visual.mjs
CHANGED
|
@@ -803,7 +803,9 @@ const failureNode = (name) => collect(panel, (row) => clsOf(row) === name)[0];
|
|
|
803
803
|
const failTitle = () => text(failureNode('jmw-failure-title')).trim();
|
|
804
804
|
const failHint = () => text(failureNode('jmw-failure-hint')).trim();
|
|
805
805
|
const failDetails = () => collect(panel, (row) => clsOf(row) === 'jmw-failure-detail');
|
|
806
|
-
|
|
806
|
+
// 失败态的按钮既可能是 .jmw-btn(重试),也可能是 .jmw-cred-btn(去配置,和配置页「保存并验证」同款)。
|
|
807
|
+
const isActionBtn = (row) => row.type === 'button' && /^jmw-(cred-)?btn(\s|$)/.test(clsOf(row));
|
|
808
|
+
const failButtons = () => collect(panel, isActionBtn).map((row) => text(row).trim());
|
|
807
809
|
const refreshBtn = () => collect(panel, (row) => row.type === 'button' && row.props?.['aria-label'] === '刷新')[0];
|
|
808
810
|
|
|
809
811
|
activeFailure.current = { code: 'no_credential', message: 'Missing Jira credential: put JIRA_API_TOKEN into the DSH credential store…' };
|
|
@@ -820,7 +822,13 @@ check(
|
|
|
820
822
|
'I 无令牌 → 提示文字 + 去配置 / 重试,且不显示原始报错',
|
|
821
823
|
`${failTitle()} / ${failButtons().join(',')}`,
|
|
822
824
|
);
|
|
823
|
-
const openConfig = collect(panel, (row) =>
|
|
825
|
+
const openConfig = collect(panel, (row) => isActionBtn(row) && text(row).trim() === '去配置')[0];
|
|
826
|
+
check(
|
|
827
|
+
/\bprimary\b/.test(clsOf(openConfig)) && openConfig?.props?.style?.background === '#4d6bfe'
|
|
828
|
+
&& openConfig?.props?.style?.color === '#ffffff',
|
|
829
|
+
'I 「去配置」用和「保存并验证」一致的按钮样式(深底白字 + primary 类)',
|
|
830
|
+
`class=${clsOf(openConfig)} style=${JSON.stringify(openConfig?.props?.style)}`,
|
|
831
|
+
);
|
|
824
832
|
openConfig.props.onClick();
|
|
825
833
|
panel = renderPanel();
|
|
826
834
|
check(
|
|
@@ -842,7 +850,7 @@ check(
|
|
|
842
850
|
'I 401 → 「邮箱 / 令牌不被接受」+ 原始信息收在详情里',
|
|
843
851
|
failTitle(),
|
|
844
852
|
);
|
|
845
|
-
const retryBtn = collect(panel, (row) =>
|
|
853
|
+
const retryBtn = collect(panel, (row) => isActionBtn(row) && text(row).trim() === '重试')[0];
|
|
846
854
|
activeFailure.current = null;
|
|
847
855
|
retryBtn.props.onClick();
|
|
848
856
|
await settle();
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 离线回归:左侧栏「工作区」右键菜单里的「关联 Jira 项目…」。
|
|
3
|
+
*
|
|
4
|
+
* 浏览器侧的插件入口是**并发创建**的:本插件的 apply 只等 slots / remote,而 `contextMenus`
|
|
5
|
+
* 服务还要等 locale、shortcuts,所以 apply 时它常常还没就绪。0.16.1 及以前这里直接
|
|
6
|
+
* `ctx.get('contextMenus')` 拿一次,拿不到就整页都没有这条菜单 —— 表现就是「绑定选项消失了」。
|
|
7
|
+
* 现在改成 `ctx.inject(['contextMenus'], …)` 等它出现再注册;这个套件把「晚到」这件事真的模拟出来:
|
|
8
|
+
* 1. apply 时没有 contextMenus → 一个贡献都不注册,但已经在等这个服务;
|
|
9
|
+
* 2. 服务出现后 → 注册 target 'workspace' 的贡献;
|
|
10
|
+
* 3. 该贡献 resolve 出一个「关联 Jira 项目…」条目,点它会打开面板并去读/写映射;
|
|
11
|
+
* 4. 老基座没有 ctx.inject 时退回直接注册(服务当时在就注册)。
|
|
12
|
+
*/
|
|
13
|
+
import { dirname } from 'node:path';
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
15
|
+
|
|
16
|
+
const WS = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
17
|
+
|
|
18
|
+
let failed = 0;
|
|
19
|
+
const check = (ok, label, detail) => {
|
|
20
|
+
console.log(`${ok ? 'PASS' : 'FAIL'} ${label}${detail === undefined ? '' : ` | ${detail}`}`);
|
|
21
|
+
if (!ok) failed += 1;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/* ------------------------------------------------------- 浏览器最小环境 */
|
|
25
|
+
|
|
26
|
+
const loaded = [];
|
|
27
|
+
const styleTags = [];
|
|
28
|
+
const fakeDocument = {
|
|
29
|
+
querySelector: () => null,
|
|
30
|
+
createElement: () => ({ dataset: {}, style: {}, textContent: '', remove() {} }),
|
|
31
|
+
head: { appendChild: (tag) => styleTags.push(tag) },
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(globalThis, 'document', { value: fakeDocument, configurable: true });
|
|
34
|
+
Object.defineProperty(globalThis, 'navigator', { value: { language: 'zh-CN', languages: ['zh-CN'] }, configurable: true });
|
|
35
|
+
|
|
36
|
+
const fetchCalls = [];
|
|
37
|
+
const fakeWindow = {
|
|
38
|
+
__ModuleLoader__: { load: (spec) => { loaded.push(spec); } },
|
|
39
|
+
__DSH_TRANSPORT__: {
|
|
40
|
+
fetch: async (url, init) => {
|
|
41
|
+
const path = String(url).split('?')[0];
|
|
42
|
+
fetchCalls.push({ path, method: String(init?.method ?? 'GET').toUpperCase() });
|
|
43
|
+
const json = (payload) => ({ ok: true, status: 200, async json() { return payload; } });
|
|
44
|
+
if (path === '/api/jira-work-overview/project-workspace') {
|
|
45
|
+
return json({ ok: true, mapping: {}, workspaces: {}, items: [] });
|
|
46
|
+
}
|
|
47
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
48
|
+
return json({ ok: true, watch: { enabled: false, counts: { new: 0, status: 0, closed: 0, total: 0 }, changes: [] } });
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(globalThis, 'window', { value: fakeWindow, configurable: true });
|
|
53
|
+
|
|
54
|
+
const React = {
|
|
55
|
+
createElement: (type, props, ...children) => ({ type, props, children }),
|
|
56
|
+
useState: (value) => [typeof value === 'function' ? value() : value, () => {}],
|
|
57
|
+
useEffect: () => {}, useRef: (value) => ({ current: value }), useMemo: (fn) => fn(),
|
|
58
|
+
useCallback: (fn) => fn, useLayoutEffect: () => {},
|
|
59
|
+
};
|
|
60
|
+
const modules = {
|
|
61
|
+
react: React,
|
|
62
|
+
'react-dom': { createPortal: (node) => node },
|
|
63
|
+
'@tanstack/react-virtual': {
|
|
64
|
+
useVirtualizer: () => ({ getTotalSize: () => 0, getVirtualItems: () => [], measureElement() {}, scrollToIndex() {} }),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** 一个够 apply 跑完的上下文;`inject` 只记下回调,等测试手动放行。 */
|
|
69
|
+
function makeCtx(options = {}) {
|
|
70
|
+
const injected = [];
|
|
71
|
+
const ctx = {
|
|
72
|
+
injected,
|
|
73
|
+
get(name) {
|
|
74
|
+
if (name === 'sessions') {
|
|
75
|
+
return { list: { getSnapshot: () => ({ byId: { 'sess-1': { id: 'sess-1', retainedBy: { mainView: 1 } } } }) } };
|
|
76
|
+
}
|
|
77
|
+
if (name === 'workspaces') {
|
|
78
|
+
return { list: { getSnapshot: () => ({ items: [{ workspaceId: 'ws-1', sessionIds: ['sess-1'] }] }) } };
|
|
79
|
+
}
|
|
80
|
+
if (name === 'remote.commands') {
|
|
81
|
+
return {
|
|
82
|
+
async execute() {
|
|
83
|
+
return {
|
|
84
|
+
ok: true,
|
|
85
|
+
value: {
|
|
86
|
+
result: {
|
|
87
|
+
kind: 'success',
|
|
88
|
+
text: JSON.stringify({
|
|
89
|
+
ok: true, project: 'APP', counts: { new: 0, indeterminate: 0, done: 0, total: 0 },
|
|
90
|
+
total: 0, projectTotals: {}, statusOptions: [], items: [], sprints: [],
|
|
91
|
+
}),
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
},
|
|
100
|
+
on() { return () => {}; },
|
|
101
|
+
effect(fn) { const off = fn(); return () => { if (typeof off === 'function') off(); }; },
|
|
102
|
+
slots: { inject(name, factory) { factory(); }, register() { return () => {}; } },
|
|
103
|
+
};
|
|
104
|
+
if (options.inject !== false) {
|
|
105
|
+
ctx.inject = (deps, callback) => { injected.push({ deps: [...deps], callback }); };
|
|
106
|
+
}
|
|
107
|
+
if (options.contextMenus) ctx.get = ((base) => (name) => (name === 'contextMenus' ? options.contextMenus : base(name)))(ctx.get);
|
|
108
|
+
return ctx;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const menuService = () => {
|
|
112
|
+
const contributions = [];
|
|
113
|
+
return {
|
|
114
|
+
contributions,
|
|
115
|
+
register(contribution) { contributions.push(contribution); return () => {}; },
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** 一个只要求 get / effect 的子上下文(ctx.inject 回调拿到的就是这种上下文)。 */
|
|
120
|
+
const childOf = (ctx, service) => ({
|
|
121
|
+
get: (name) => (name === 'contextMenus' ? service : ctx.get(name)),
|
|
122
|
+
effect: ctx.effect,
|
|
123
|
+
slots: ctx.slots,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
await import(pathToFileURL(`${WS}/client.js`).href);
|
|
127
|
+
const spec = loaded[0];
|
|
128
|
+
check(Boolean(spec && spec.factory), 'client 半边的 bundle 能加载');
|
|
129
|
+
|
|
130
|
+
/* --------------------------------------------- 1) 服务晚到:等它出现再注册 */
|
|
131
|
+
|
|
132
|
+
const late = makeCtx();
|
|
133
|
+
spec.factory((name) => modules[name]).apply(late);
|
|
134
|
+
check(late.injected.length === 1 && late.injected[0].deps.includes('contextMenus'),
|
|
135
|
+
'apply 时先等 contextMenus 服务(不直接 ctx.get 一次就放弃)',
|
|
136
|
+
late.injected.map((row) => row.deps.join(',')).join(' | '));
|
|
137
|
+
|
|
138
|
+
const service = menuService();
|
|
139
|
+
check(service.contributions.length === 0, '服务还没出现时一个菜单贡献都不注册');
|
|
140
|
+
late.injected[0].callback(childOf(late, service));
|
|
141
|
+
check(service.contributions.length === 1, '服务晚到后补注册了菜单贡献', String(service.contributions.length));
|
|
142
|
+
|
|
143
|
+
const contribution = service.contributions[0];
|
|
144
|
+
check(contribution.target === 'workspace' && contribution.id.endsWith('.workspace-project'),
|
|
145
|
+
'注册的是「工作区」这一族的菜单贡献', `${contribution.target} / ${contribution.id}`);
|
|
146
|
+
check(Array.isArray(contribution.observe({ workspaceId: 'ws-1' })) && contribution.observe({ workspaceId: 'ws-1' }).length === 1,
|
|
147
|
+
'observe 把工作区列表作为响应式输入');
|
|
148
|
+
|
|
149
|
+
/* --------------------------------------------- 2) resolve / 点击后的行为 */
|
|
150
|
+
|
|
151
|
+
const before = fetchCalls.length;
|
|
152
|
+
const actions = contribution.resolve({ workspaceId: 'ws-1', path: '/tmp/ws', displayTitle: 'ws' });
|
|
153
|
+
check(Array.isArray(actions) && actions.length >= 1, 'resolve 至少返回一条菜单项', String(actions?.length));
|
|
154
|
+
check(actions?.some((action) => action.label === '关联 Jira 项目…'),
|
|
155
|
+
'菜单里有「关联 Jira 项目…」', actions?.map((action) => action.label).join(' | '));
|
|
156
|
+
|
|
157
|
+
await actions[0].run();
|
|
158
|
+
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
159
|
+
check(fetchCalls.slice(before).some((call) => call.path === '/api/jira-work-overview/project-workspace' && call.method === 'GET'),
|
|
160
|
+
'点「关联 Jira 项目…」会去读一次映射并打开面板');
|
|
161
|
+
|
|
162
|
+
/* --------------------------------------------- 3) 老基座:没有 ctx.inject 时直接注册 */
|
|
163
|
+
|
|
164
|
+
const early = makeCtx({ inject: false, contextMenus: menuService() });
|
|
165
|
+
spec.factory((name) => modules[name]).apply(early);
|
|
166
|
+
check(early.get('contextMenus')?.contributions?.length === 1,
|
|
167
|
+
'没有 ctx.inject 的老基座:服务当时就在时直接注册');
|
|
168
|
+
|
|
169
|
+
console.log(failed === 0 ? '\n全部通过' : `\n失败 ${failed} 项`);
|
|
170
|
+
process.exit(failed === 0 ? 0 : 1);
|
package/test/run-offline.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const RELEASE = process.argv.includes('--release');
|
|
|
13
13
|
|
|
14
14
|
// 真站点套件(status / transition / sprint / smoke*)在没凭据时会自己 SKIP 并 exit 0。
|
|
15
15
|
const SUITES = [
|
|
16
|
-
'bundle-id', 'release', 'platform', 'visual', 'credential', 'plan', 'i18n',
|
|
16
|
+
'bundle-id', 'release', 'platform', 'visual', 'credential', 'plan', 'workspace-menu', 'i18n',
|
|
17
17
|
'search', 'epic', 'selfwatch', 'json', 'smoke', 'smoke3', 'due', 'sprint', 'status', 'transition',
|
|
18
18
|
];
|
|
19
19
|
|