dsh-jira-work-overview 0.16.3 → 0.16.5
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 +25 -0
- package/README.md +17 -8
- package/README.zh.md +22 -7
- package/client.js +247 -20
- package/docs/images/panel-connect.png +0 -0
- package/docs/images/panel-connect.zh.png +0 -0
- package/index.js +39 -5
- package/package.json +1 -1
- package/test/dsh-jira-credential.mjs +39 -0
- package/test/dsh-jira-shot.mjs +22 -0
- package/test/dsh-jira-visual.mjs +140 -26
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,31 @@ 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
|
+
## [0.16.5] - 2026-11-24
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **第一次用不再只看到一句失败。** 没配站点地址 / 邮箱 / 令牌时,面板在**原来显示登录失败的位置**
|
|
12
|
+
直接渲染「连接 Jira」表单(站点地址 + 邮箱 + API token):缺什么填什么,已保存的字段留空沿用;
|
|
13
|
+
点「保存并连接」会先拿 `/myself` 验一次再写凭据库 / 设置,成功后自动重拉列表,令牌输入框只给
|
|
14
|
+
掩码提示、永远不回显。旁边保留「去配置」,直达条数 / 监视 / 通知 / 语言这些高级项。
|
|
15
|
+
只有「配了但连不上」(401 / 网络 / 站点返回异常 / 凭据读不出)才继续走原来的失败提示 + 原始信息。
|
|
16
|
+
|
|
17
|
+
- **README 补了「第一次用」的截图与小节**:图由 `test/dsh-jira-shot.mjs --only panel-connect` 生成
|
|
18
|
+
(`docs/images/panel-connect.png` / `panel-connect.zh.png`),不讲新行为,只把「第一次打开看到什么」画出来;
|
|
19
|
+
中英两份 README 都加了入口(英文在 `First-run configuration`,中文独立一节「第一次用:面板里直接填」)。
|
|
20
|
+
|
|
21
|
+
## [0.16.4] - 2026-11-23
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- **第一次配置时只点「保存并验证」,站点地址没跟着保存,列表一直是空的。** 全新安装(或换了 profile)
|
|
26
|
+
时 `baseUrl` 还没写过:用户在配置页把邮箱、令牌、站点地址一起填好、只点了「保存并验证」这条通道
|
|
27
|
+
当时只提交 `token` + `email`,地址留在输入框里没落盘,于是面板一直报「还没有配置 Jira 站点地址」。
|
|
28
|
+
现在令牌保存会带上输入框里的站点地址、先拿它做 `/myself` 验证再一起写进 profile(地址非法整条拒绝、
|
|
29
|
+
不写入);配置保存成功后还会让面板自动重拉一次列表(以前配置完关掉弹窗,看到的仍是旧错误页,
|
|
30
|
+
得手动点「重试」);profile 没有 settings 服务、只能本次运行生效时也会明确提示。
|
|
31
|
+
|
|
7
32
|
## [0.16.3] - 2026-11-23
|
|
8
33
|
|
|
9
34
|
### Added
|
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Show **your** Jira work items — with their real workflow status — inside [De
|
|
|
21
21
|
- **Live watch** — the host polls "assigned to me and not done" in the background; new assignments / status changes show a **system notification**, an **unread badge** on the sidebar entry, and a "what changed" banner with *mark as read*. The panel refreshes itself when a change arrives.
|
|
22
22
|
- **Three agent tools** — `jira_my_work`, `jira_issue`, `jira_transition` (preview by default, writes only with `apply: true`).
|
|
23
23
|
- **One slash command** — `/jira [--json] [--limit=<n>|0] [--lang=<tag>] [--search=<text>] [open|sprint|all | <issue key> | <JQL>]`; it renders in the command surface, so it costs no model tokens.
|
|
24
|
+
- **First run is the form** — with no Jira site, email or token the panel body *is* a **Connect Jira** form (site URL, email, API token) in the exact spot the failure message used to take; fill what is missing and press **Save and connect**. Already-saved fields can be left empty, and **Configure** is still one click away for fetch size, watch, notifications and language.
|
|
24
25
|
- **Configure dialog** — Jira site / email / API token (token goes to the DSH credential store), fetch size, watch switch + interval, notification switch, UI language, and one-click **open `cordis.patch.yml`** (default app / system "open with" chooser / detected editors / custom app).
|
|
25
26
|
- **Bilingual UI** — follows the DSH language setting (`设置 → 通用 → 语言`), live; Jira-returned text (summaries, status names, labels) is always shown verbatim.
|
|
26
27
|
|
|
@@ -37,7 +38,7 @@ Show **your** Jira work items — with their real workflow status — inside [De
|
|
|
37
38
|
DSH installs plugins from an **installation spec** — anything `pnpm add` accepts (registry package name, git URL, tarball, absolute path). Pick one:
|
|
38
39
|
|
|
39
40
|
```bash
|
|
40
|
-
# 1) from the npm registry (published since 0.14.0; pin a version with @0.16.
|
|
41
|
+
# 1) from the npm registry (published since 0.14.0; pin a version with @0.16.5)
|
|
41
42
|
plugin_manager install_bundle(target="dsh-jira-work-overview")
|
|
42
43
|
|
|
43
44
|
# 2) straight from GitHub (no npm publishing needed)
|
|
@@ -55,7 +56,13 @@ Installing adds `dsh-jira-work-overview` to your profile's bundle list and inser
|
|
|
55
56
|
|
|
56
57
|
## First-run configuration
|
|
57
58
|
|
|
58
|
-
The bundled `cordis.patch.yml` deliberately contains **no site-specific values**, so nothing of the author's Jira account is shipped.
|
|
59
|
+
The bundled `cordis.patch.yml` deliberately contains **no site-specific values**, so nothing of the author's Jira account is shipped.
|
|
60
|
+
|
|
61
|
+
**Nothing configured yet? The panel body *is* the login form.** Site URL, account email and API token show up in the exact spot where a failure hint used to be — fill what is missing and press **Save and connect**. Fields that are already saved may stay empty (the plugin submits only what you changed), and the list loads as soon as Jira accepts the pair.
|
|
62
|
+
|
|
63
|
+
<img src="docs/images/panel-connect.png" width="1040" alt="First run: the panel shows a 'Connect Jira' form with site URL, account email and API token fields plus 'Save and connect' and 'Configure' buttons">
|
|
64
|
+
|
|
65
|
+
Everything else lives in the configure dialog — click **配置 / Configure** in the panel header and fill in:
|
|
59
66
|
|
|
60
67
|
| Field | Example | Required |
|
|
61
68
|
| --- | --- | --- |
|
|
@@ -234,7 +241,7 @@ The plugin's own copy follows the DSH language setting; English and Chinese ship
|
|
|
234
241
|
| configure dialog says "Reading the token state failed: HTTP 404" | the plugin's `/api` routes were not registered (the host loaded the plugin before its connection service existed) — reload the plugin; a fixed build registers them once the service is up |
|
|
235
242
|
| footer says "live watch disconnected" | transient transport error; it retries with backoff |
|
|
236
243
|
| token rejected when saving | the email + token pair is wrong, or the token has no Jira access |
|
|
237
|
-
| panel
|
|
244
|
+
| panel body is a **Connect Jira** form | nothing is configured yet: fill site URL / email / API token and press **Save and connect** (a saved field can stay empty); the form sits where the failure hint used to be, and the token still goes straight to the DSH credential store |
|
|
238
245
|
| panel says "Jira rejected this email / token pair" | 401/403 from Jira: regenerate the token; the raw response is under the hint |
|
|
239
246
|
| panel says "Could not read the stored token" | the credential store returned an error rather than a value: save the token again from **Configure** |
|
|
240
247
|
|
|
@@ -242,7 +249,7 @@ Behind a corporate proxy on Windows, DSH needs the proxy env vars it was started
|
|
|
242
249
|
|
|
243
250
|
## Versions and upgrades
|
|
244
251
|
|
|
245
|
-
The current version is **0.16.
|
|
252
|
+
The current version is **0.16.5** (2026-11-24). The changelog records 39 versions (from 0.1.0); GitHub carries **14 tags / releases** (0.13.0 → 0.16.5), and **0.13.4 was the first public release** — the earlier 0.1.0–0.12.0 exist only in `CHANGELOG.md` and the project notes, with no commit or tag behind them, so "an older version" means **0.13.0 or later**. Every release is described in [CHANGELOG.md](CHANGELOG.md).
|
|
246
253
|
|
|
247
254
|
### Why people still install older versions
|
|
248
255
|
|
|
@@ -277,10 +284,12 @@ The current version is **0.16.0** (2026-11-20). The changelog records 30 version
|
|
|
277
284
|
| 0.14.0 | 2026-11-19 | feature | highlight follows **Jira's own priority order**; **first npm release** |
|
|
278
285
|
| 0.15.0 | 2026-11-19 | feature | transitions update **in place**, your own changes no longer notify you, typed failure hints |
|
|
279
286
|
| 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 |
|
|
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 |
|
|
283
287
|
| 0.16.0 | 2026-11-20 | feature | **site-wide search**, **group by epic**, the **计划** (plan) button on every row |
|
|
288
|
+
| 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 |
|
|
289
|
+
| 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 |
|
|
290
|
+
| 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** |
|
|
291
|
+
| 0.16.4 | 2026-11-23 | **fix** | on a fresh profile, filling email + token + site URL and clicking only **Save & verify** left the URL unsaved, so the panel always said there was no site URL; the panel now also reloads automatically after a successful save |
|
|
292
|
+
| 0.16.5 | 2026-11-24 | feature | **nothing configured shows a form, not an error**: the panel body is the Connect Jira form (site URL / email / API token) in the old failure slot, saved fields can stay empty, and the list reloads once Jira accepts the pair |
|
|
284
293
|
|
|
285
294
|
> 0.1.0–0.12.0 all happened on 2026-11-18; tags and GitHub Releases start at 0.13.0.
|
|
286
295
|
> To install an older version: `plugin_manager install_bundle(target="github:EagleSoap/dsh-jira-work-overview#v0.13.2")`, or pin the npm version with `target="dsh-jira-work-overview@0.14.0"` (the earliest version on npm is 0.14.0).
|
|
@@ -338,7 +347,7 @@ Every user-visible defect, newest first (implementation detail is in the matchin
|
|
|
338
347
|
|
|
339
348
|
1. **No sidebar entry**, or `plugin_manager` says `active` while the UI is empty → upgrade to **0.13.2 or later** and refresh.
|
|
340
349
|
2. The configure dialog reports **HTTP 404** / the badge never updates → upgrade to **0.15.1 or later**.
|
|
341
|
-
3.
|
|
350
|
+
3. **Nothing is configured yet** → the panel body is a **Connect Jira** form (site URL, email, API token); fill what is missing and press **Save and connect**. A rejected token / unreadable credential keeps the failure hint: use **Configure** there (or at the right of the panel title); you never have to edit the profile file.
|
|
342
351
|
4. A raw error from `/jira` in text mode is **on purpose** — the command surface should show the real reason; the panel uses the typed `--json` hints instead.
|
|
343
352
|
|
|
344
353
|
## Security and privacy
|
package/README.zh.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
DSH 用**安装 spec** 装插件 —— 凡是 `pnpm add` 能吃的写法都行(registry 包名、git 地址、tarball、绝对路径)。选一个:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
# 1) 从 npm 装(0.14.0 起已发布;要钉版本就在后面写 @0.16.
|
|
24
|
+
# 1) 从 npm 装(0.14.0 起已发布;要钉版本就在后面写 @0.16.5)
|
|
25
25
|
plugin_manager install_bundle(target="dsh-jira-work-overview")
|
|
26
26
|
|
|
27
27
|
# 2) 直接从 GitHub 装(不需要 npm 发布)
|
|
@@ -186,7 +186,11 @@ profile 里装了 `deepseek-ai/dsh-plan-mode` 就用它的 `section` 当规划
|
|
|
186
186
|
组头的未完成数与筛选菜单都在本地重算,不再为改一个状态把几百条 issue 重新拉一遍;只有在当前列表里找不到这条时才回退整表刷新);
|
|
187
187
|
失败(例如某个流转要求必填字段)把 Jira 的报错原样显示在下拉里,不静默吞掉。
|
|
188
188
|
|
|
189
|
-
-
|
|
189
|
+
- **第一次用就是那张表单**:没配站点地址 / 邮箱 / 令牌时,面板在**原来显示失败提示的位置**直接给出
|
|
190
|
+
「连接 Jira」表单(站点地址 + 邮箱 + API token),缺什么填什么,点「保存并连接」当场拉列表;
|
|
191
|
+
已经保存过的字段可以留空沿用,令牌照旧只进 DSH 凭据库、提交前先用 `/myself` 验一次。
|
|
192
|
+
旁边的「去配置」仍然直达完整配置弹窗(条数 / 监视 / 通知 / 语言)。
|
|
193
|
+
- **失败会说人话**:凭据读不出来、令牌过期(401)、网络不通、站点返回非 JSON,
|
|
190
194
|
面板不再把 Host 的原始报错糊在列表位置,而是标题 + 一句「怎么办」:`去配置` 直接打开令牌弹窗、
|
|
191
195
|
`重试` 重新查询;只有需要看原文的那几类(认证失败 / 网络 / 站点错误)才把原始信息以小字附在下面。
|
|
192
196
|
错误类型来自 `--json` 载荷里的 `error.code`(`no_credential` / `credential_unreadable` / `no_email` /
|
|
@@ -282,6 +286,15 @@ Jira Cloud **没有**给第三方 issue 事件的 websocket / SSE 长连接(
|
|
|
282
286
|
> 如果你更希望“毫秒级实时”,正路只有两条:让 Jira 管理员配 webhook + 内网穿透(需要公网地址),
|
|
283
287
|
> 或者用 DSH 的定时任务让 agent 定时来问(每次都要跑模型,比本机轮询贵得多)。
|
|
284
288
|
|
|
289
|
+
## 第一次用:面板里直接填(连接表单)
|
|
290
|
+
|
|
291
|
+
还没配站点地址 / 邮箱 / 令牌时,打开面板看到的不是一句失败提示,而是**直接可填的「连接 Jira」表单**
|
|
292
|
+
(服务地址 + 账号邮箱 + API token),就占在原来失败提示的位置:缺什么填什么,点「保存并连接」当场拉列表。
|
|
293
|
+
已经保存过的字段可以留空沿用(只提交你改过的值);令牌只进 DSH 凭据库,提交前先用 `/myself` 验一次,
|
|
294
|
+
不然不写入。旁边的「去配置」直达完整配置弹窗(条数 / 监视 / 通知 / 语言这些高级项)。
|
|
295
|
+
|
|
296
|
+
<img src="docs/images/panel-connect.zh.png" width="1040" alt="第一次用:面板里直接是「连接 Jira」表单,含服务地址 / 账号邮箱 / API token 三个输入框与「保存并连接」「去配置」按钮">
|
|
297
|
+
|
|
285
298
|
## 换令牌(插件配置页)
|
|
286
299
|
|
|
287
300
|
**入口(三个,内容一样)**:
|
|
@@ -496,7 +509,7 @@ Zed(`zed`)、Sublime Text(`subl`)、gedit(`gedit`)——**找到可
|
|
|
496
509
|
|
|
497
510
|
## 版本与升级
|
|
498
511
|
|
|
499
|
-
当前版本 **0.16.
|
|
512
|
+
当前版本 **0.16.5**(2026-11-24)。`CHANGELOG.md` 记了 39 个版本(0.1.0 起),GitHub 上有 **14 个 tag / Release**(0.13.0 → 0.16.5),**0.13.4 是第一个公开版本**——更早的 0.1.0–0.12.0 只存在于 `CHANGELOG.md` 与项目记录里,没有对应的提交与 tag,所以「以前的版本」= **0.13.0 及以后**。逐版的完整说明见 [CHANGELOG.md](CHANGELOG.md)。
|
|
500
513
|
|
|
501
514
|
### 为什么有人还在装以前的版本
|
|
502
515
|
|
|
@@ -531,10 +544,12 @@ Zed(`zed`)、Sublime Text(`subl`)、gedit(`gedit`)——**找到可
|
|
|
531
544
|
| 0.14.0 | 2026-11-19 | 功能 | 高亮挂到 **Jira 自己的优先级名次**;**首次发布到 npm** |
|
|
532
545
|
| 0.15.0 | 2026-11-19 | 功能 | 改状态**不再全量重拉**、自己改的状态不再通知自己、失败提示按类型 |
|
|
533
546
|
| 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 项目…」会整页消失(客户端启动竞态);新增离线套件守住 |
|
|
536
|
-
| 0.16.1 | 2026-11-22 | 修复 | Windows 通知与「在文件管理器中显示」、Linux 编辑器直选、UNC 路径;三平台 CI 与发版预检;README 补计划会话图解 |
|
|
537
547
|
| 0.16.0 | 2026-11-20 | 功能 | **整站搜索**、**按 epic 分组**、任务行**「计划」**(plan 模式会话) |
|
|
548
|
+
| 0.16.1 | 2026-11-22 | 修复 | Windows 通知与「在文件管理器中显示」、Linux 编辑器直选、UNC 路径;三平台 CI 与发版预检;README 补计划会话图解 |
|
|
549
|
+
| 0.16.2 | 2026-11-23 | **修复** | 左栏工作区右键菜单的「关联 Jira 项目…」会整页消失(客户端启动竞态);新增离线套件守住 |
|
|
550
|
+
| 0.16.3 | 2026-11-23 | **修复** | 配置页「Jira 连接」的服务地址改成可编辑输入框(placeholder = 当前地址,写进 profile 的 Cordis patch);失败提示里的「去配置」按钮和「保存并验证」同款样式 |
|
|
551
|
+
| 0.16.4 | 2026-11-23 | **修复** | 全新 profile 上把邮箱、令牌、站点地址一起填好、只点「保存并验证」时地址没落盘,面板一直说没配站点地址;配置保存成功后还会自动重拉列表 |
|
|
552
|
+
| 0.16.5 | 2026-11-24 | 功能 | **没配置时给的是表单而不是报错**:面板直接把「连接 Jira」表单(服务地址 / 邮箱 / API token)放在原来的失败位置,已保存的字段可留空,连接成功即重拉列表 |
|
|
538
553
|
|
|
539
554
|
> 0.1.0–0.12.0 这 15 个版本都发生在 2026-11-18 同一天;0.13.0 起才有 tag 与 Release。
|
|
540
555
|
> 想装某个旧版本:`plugin_manager install_bundle(target="github:EagleSoap/dsh-jira-work-overview#v0.13.2")`,或从 npm 钉版本 `target="dsh-jira-work-overview@0.14.0"`(npm 上最早的版本是 0.14.0)。
|
|
@@ -593,7 +608,7 @@ plugin_manager install_bundle(target="dsh-jira-work-overview") # 已装过则
|
|
|
593
608
|
|
|
594
609
|
1. 左侧栏**没有入口**、或 `plugin_manager` 显示 `active` 但界面是空的 → 先升级到 **0.13.2 以上**并刷新页面。
|
|
595
610
|
2. 配置页报 **HTTP 404**、角标不更新 → 升到 **0.15.1 以上**。
|
|
596
|
-
3.
|
|
611
|
+
3. **什么都还没配** → 面板里就是「连接 Jira」表单(站点地址 / 邮箱 / API token),缺什么填什么、点「保存并连接」。令牌被拒 / 读不出令牌仍是失败提示:点提示里的「去配置」(或面板标题右侧「配置」)重填;**不用改 profile 文件**。
|
|
597
612
|
4. `/jira` 文本模式返回 `kind:'error'` 的原始报错是**故意的**——命令面本来就该看到真实原因;面板专用的是 `--json` 的分类型提示。
|
|
598
613
|
|
|
599
614
|
## 测试(`test/`)
|
package/client.js
CHANGED
|
@@ -93,6 +93,13 @@ window.__ModuleLoader__.load({
|
|
|
93
93
|
return Object.prototype.hasOwnProperty.call(FAILURES, code) ? FAILURES[code] : FAILURES.unknown;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* 这几个 code 说的是「还没配好」,不是「配了但连不上」:面板把同一块位置直接换成
|
|
98
|
+
* 「连接 Jira」表单(站点地址 + 邮箱 + 令牌),用户当场填完就拉列表,不用先看一句失败提示
|
|
99
|
+
* 再自己去找配置入口。其它 code(auth / network / http…)仍走 FAILURES 的提示。
|
|
100
|
+
*/
|
|
101
|
+
const CONNECT_CODES = new Set(['no_base_url', 'no_email', 'no_credential']);
|
|
102
|
+
|
|
96
103
|
/** 条数语义的客户端归一化(与 host 侧 index.js 的 normalizeLimit 同步):
|
|
97
104
|
* **0 = 不限制**,正数 clamp 到 10–5000,其它(非法 / 负数)回落到 fallback。 */
|
|
98
105
|
function normalizeLimit(value, fallback = LIMIT_DEFAULT) {
|
|
@@ -189,6 +196,15 @@ window.__ModuleLoader__.load({
|
|
|
189
196
|
failUnknownHint: '这次失败没有可归类的类型,原始信息见下方。',
|
|
190
197
|
failOpenConfig: '去配置',
|
|
191
198
|
failDetail: '原始信息:{message}',
|
|
199
|
+
// 没配站点 / 邮箱 / 令牌时,失败位置直接换成这张连接表单(三个字段都能留空沿用已保存值)。
|
|
200
|
+
connectTitle: '连接 Jira',
|
|
201
|
+
connectHint: '填上 Jira 服务地址、账号邮箱和 API token 就能拉取任务列表;已经保存过的字段可以留空沿用。',
|
|
202
|
+
connectTokenLabel: 'API token',
|
|
203
|
+
connectTokenPlaceholder: '粘贴 Jira API token',
|
|
204
|
+
connectTokenKeep: '已保存 {masked},留空沿用',
|
|
205
|
+
connectSubmit: '保存并连接',
|
|
206
|
+
connectSaving: '连接中…',
|
|
207
|
+
connectFailed: '连接失败:{message}',
|
|
192
208
|
untitled: '(无摘要)',
|
|
193
209
|
parent: '父 {key}',
|
|
194
210
|
watch: '实时监视中',
|
|
@@ -267,6 +283,8 @@ window.__ModuleLoader__.load({
|
|
|
267
283
|
credConfirmClear: '确认清除?',
|
|
268
284
|
credSaved: '已保存到 DSH 凭据库({key}),立即生效',
|
|
269
285
|
credSavedEmail: '账号邮箱已更新为 {email}',
|
|
286
|
+
credSavedBaseUrl: '站点地址已更新为 {baseUrl}',
|
|
287
|
+
baseUrlSavedLocal: '站点地址已应用({baseUrl}),但没能写进 profile 的 Cordis patch({reason}),重启后会丢',
|
|
270
288
|
credSavedOffline: '已保存到 DSH 凭据库({key});这次没能验证成功({message})',
|
|
271
289
|
credSavedAs: '已验证账号:{account}',
|
|
272
290
|
credCleared: '已从凭据库删除 {key}',
|
|
@@ -423,6 +441,16 @@ window.__ModuleLoader__.load({
|
|
|
423
441
|
failUnknownHint: 'This failure has no known type; the raw message is below.',
|
|
424
442
|
failOpenConfig: 'Configure',
|
|
425
443
|
failDetail: 'Raw message: {message}',
|
|
444
|
+
// Unconfigured site / email / token: the failure slot renders this connect form instead
|
|
445
|
+
// (all three fields can be left empty to keep the saved value).
|
|
446
|
+
connectTitle: 'Connect Jira',
|
|
447
|
+
connectHint: 'Enter your Jira base URL, account email and API token to load your work; leave a saved field empty to keep it.',
|
|
448
|
+
connectTokenLabel: 'API token',
|
|
449
|
+
connectTokenPlaceholder: 'Paste a Jira API token',
|
|
450
|
+
connectTokenKeep: 'Saved {masked} — leave empty to keep it',
|
|
451
|
+
connectSubmit: 'Save and connect',
|
|
452
|
+
connectSaving: 'Connecting…',
|
|
453
|
+
connectFailed: 'Connection failed: {message}',
|
|
426
454
|
untitled: '(no summary)',
|
|
427
455
|
parent: 'parent {key}',
|
|
428
456
|
watch: 'Live watch on',
|
|
@@ -501,6 +529,8 @@ window.__ModuleLoader__.load({
|
|
|
501
529
|
credConfirmClear: 'Clear it?',
|
|
502
530
|
credSaved: 'Saved to the DSH credential store ({key}); effective immediately',
|
|
503
531
|
credSavedEmail: 'Account email updated to {email}',
|
|
532
|
+
credSavedBaseUrl: 'Site URL updated to {baseUrl}',
|
|
533
|
+
baseUrlSavedLocal: 'Site URL applied ({baseUrl}) but could not be written into this profile\'s Cordis patch ({reason}); it is lost after a restart',
|
|
504
534
|
credSavedOffline: 'Saved to the DSH credential store ({key}); verification failed this time ({message})',
|
|
505
535
|
credSavedAs: 'Verified account: {account}',
|
|
506
536
|
credCleared: 'Removed {key} from the credential store',
|
|
@@ -1889,6 +1919,13 @@ window.__ModuleLoader__.load({
|
|
|
1889
1919
|
.jmw-failure-actions{display:flex;justify-content:center;gap:8px}
|
|
1890
1920
|
.jmw-failure-detail{max-width:360px;margin:14px auto 0;font-size:11px;line-height:1.5;
|
|
1891
1921
|
color:var(--dsw-alias-label-tertiary,#8a8f99);white-space:pre-wrap;word-break:break-word}
|
|
1922
|
+
/* 还没配置时的内联「连接 Jira」表单:占的正是原来失败提示的位置,左对齐、字段竖排。 */
|
|
1923
|
+
.jmw-connect{max-width:420px;margin:0 auto;padding:26px 18px;text-align:left}
|
|
1924
|
+
.jmw-connect-title{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#1b1d22);margin-bottom:4px}
|
|
1925
|
+
.jmw-connect-hint{margin:0 0 12px;font-size:11.5px;line-height:1.6;color:var(--dsw-alias-label-secondary,#5c6270)}
|
|
1926
|
+
.jmw-connect-form{gap:4px}
|
|
1927
|
+
.jmw-connect-actions{justify-content:flex-start}
|
|
1928
|
+
.jmw-connect-note{margin-top:10px;font-size:11px;line-height:1.6;color:var(--dsw-alias-label-tertiary,#8a90a0)}
|
|
1892
1929
|
.jmw-btn{padding:5px 14px;font:inherit;font-size:12px;color:var(--dsw-alias-label-primary,#1b1d22);cursor:pointer;
|
|
1893
1930
|
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));
|
|
1894
1931
|
border-radius:var(--dsw-radius-sm,8px)}
|
|
@@ -2508,6 +2545,165 @@ window.__ModuleLoader__.load({
|
|
|
2508
2545
|
return String(value).replace(/["\\\]]/g, (ch) => `\\${ch}`);
|
|
2509
2546
|
}
|
|
2510
2547
|
|
|
2548
|
+
/* ------------------------------------------------- 未配置时的内联连接表单 */
|
|
2549
|
+
//
|
|
2550
|
+
// 第一次用时(没站点 / 没邮箱 / 没令牌),host 把失败按 code 分类送回来。这几种「还没配」
|
|
2551
|
+
// 不该只给一句失败提示:面板在**原来显示失败的位置**直接渲染这张表单,填完就拉列表。
|
|
2552
|
+
// 三个字段都能留空沿用已保存值,提交走配置页同一个 /credential 路由 —— host 会先拿
|
|
2553
|
+
// 邮箱 + 令牌打一次 /myself,通过了才写凭据库 / 设置(401/403 直接拒绝并把原因回给这里)。
|
|
2554
|
+
function ConnectForm(props) {
|
|
2555
|
+
const [form, setForm] = React.useState({
|
|
2556
|
+
// 已保存的连接信息(GET /credential):用来回填 + 判断哪一项还缺。
|
|
2557
|
+
origin: null,
|
|
2558
|
+
baseUrl: '',
|
|
2559
|
+
email: '',
|
|
2560
|
+
token: '',
|
|
2561
|
+
busy: false,
|
|
2562
|
+
error: '',
|
|
2563
|
+
});
|
|
2564
|
+
|
|
2565
|
+
// 进面板先读一次已保存的连接信息:只缺令牌时,用户只需要粘贴令牌再点保存。
|
|
2566
|
+
React.useEffect(() => {
|
|
2567
|
+
let alive = true;
|
|
2568
|
+
(async () => {
|
|
2569
|
+
try {
|
|
2570
|
+
const response = await watchFetch(CREDENTIAL_PATH, { method: 'GET', headers: { accept: 'application/json' } });
|
|
2571
|
+
const payload = await response.json().catch(() => null);
|
|
2572
|
+
if (!alive) return;
|
|
2573
|
+
if (payload?.ok !== true) return;
|
|
2574
|
+
const baseUrl = String(payload?.settings?.baseUrl ?? '');
|
|
2575
|
+
const email = String(payload?.email ?? '');
|
|
2576
|
+
setForm((prev) => ({
|
|
2577
|
+
...prev,
|
|
2578
|
+
origin: { baseUrl, email, configured: payload?.configured === true, masked: String(payload?.masked ?? '') },
|
|
2579
|
+
// 状态读回来得比首屏慢:用户已经手动改过的字段不回填。
|
|
2580
|
+
baseUrl: prev.baseUrl || baseUrl,
|
|
2581
|
+
email: prev.email || email,
|
|
2582
|
+
}));
|
|
2583
|
+
} catch {
|
|
2584
|
+
// 读不到状态不影响手动填写(提交时 host 会给出真正的错误)。
|
|
2585
|
+
}
|
|
2586
|
+
})();
|
|
2587
|
+
return () => { alive = false; };
|
|
2588
|
+
}, []);
|
|
2589
|
+
|
|
2590
|
+
const baseUrl = form.baseUrl.trim();
|
|
2591
|
+
const email = form.email.trim();
|
|
2592
|
+
const token = form.token.trim();
|
|
2593
|
+
const origin = form.origin;
|
|
2594
|
+
// 已保存过的字段不必再填;提交时只送改过的值,空的让 host 用当前值。
|
|
2595
|
+
const needBaseUrl = !origin || !origin.baseUrl;
|
|
2596
|
+
const needEmail = !origin || !origin.email;
|
|
2597
|
+
const needToken = !origin || !origin.configured;
|
|
2598
|
+
const canSubmit = !form.busy
|
|
2599
|
+
&& (!needBaseUrl || baseUrl !== '')
|
|
2600
|
+
&& (!needEmail || email !== '')
|
|
2601
|
+
&& (!needToken || token !== '');
|
|
2602
|
+
|
|
2603
|
+
const update = (field, value) => setForm((prev) => ({ ...prev, [field]: value, error: '' }));
|
|
2604
|
+
const onEnter = (event) => { if (event?.key === 'Enter') void submit(); };
|
|
2605
|
+
|
|
2606
|
+
async function submit() {
|
|
2607
|
+
if (!canSubmit) return;
|
|
2608
|
+
const body = {};
|
|
2609
|
+
if (!origin || baseUrl !== origin.baseUrl) body.baseUrl = baseUrl;
|
|
2610
|
+
if (!origin || email !== origin.email) body.email = email;
|
|
2611
|
+
if (token) body.token = token;
|
|
2612
|
+
setForm((prev) => ({ ...prev, busy: true, error: '' }));
|
|
2613
|
+
try {
|
|
2614
|
+
const response = await watchFetch(CREDENTIAL_PATH, {
|
|
2615
|
+
method: 'POST',
|
|
2616
|
+
headers: { accept: 'application/json', 'content-type': 'application/json' },
|
|
2617
|
+
body: JSON.stringify(body),
|
|
2618
|
+
});
|
|
2619
|
+
const payload = await response.json().catch(() => null);
|
|
2620
|
+
// host 把「邮箱 / 令牌不被接受」也回成 ok:false + error:原样显示在表单下面。
|
|
2621
|
+
if (payload?.ok !== true) throw new Error(payload?.error || `HTTP ${response.status}`);
|
|
2622
|
+
setForm((prev) => ({ ...prev, busy: false, token: '' }));
|
|
2623
|
+
// 保存成功 → 回到列表加载;新凭据立刻生效,不用再点「重试」。
|
|
2624
|
+
props?.onConnected?.();
|
|
2625
|
+
} catch (error) {
|
|
2626
|
+
setForm((prev) => ({
|
|
2627
|
+
...prev,
|
|
2628
|
+
busy: false,
|
|
2629
|
+
error: t('connectFailed', { message: String(error?.message ?? error) }),
|
|
2630
|
+
}));
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
return h('div', { className: 'jmw-state jmw-connect' }, [
|
|
2635
|
+
h('div', { key: 'title', className: 'jmw-connect-title' }, t('connectTitle')),
|
|
2636
|
+
h('div', { key: 'hint', className: 'jmw-connect-hint' }, t('connectHint')),
|
|
2637
|
+
h('div', { key: 'form', className: 'jmw-cred-form jmw-connect-form' }, [
|
|
2638
|
+
h('label', { key: 'bu-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-base-url' }, t('fBaseUrl')),
|
|
2639
|
+
h('input', {
|
|
2640
|
+
key: 'bu-input',
|
|
2641
|
+
id: 'jmw-connect-base-url',
|
|
2642
|
+
className: 'jmw-cred-input',
|
|
2643
|
+
type: 'url',
|
|
2644
|
+
inputMode: 'url',
|
|
2645
|
+
autoComplete: 'off',
|
|
2646
|
+
spellCheck: false,
|
|
2647
|
+
placeholder: t('baseUrlPlaceholderFallback'),
|
|
2648
|
+
value: form.baseUrl,
|
|
2649
|
+
onInput: (event) => update('baseUrl', event?.target?.value ?? ''),
|
|
2650
|
+
onKeyDown: onEnter,
|
|
2651
|
+
}),
|
|
2652
|
+
h('label', { key: 'em-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-email' }, t('credEmailLabel')),
|
|
2653
|
+
h('input', {
|
|
2654
|
+
key: 'em-input',
|
|
2655
|
+
id: 'jmw-connect-email',
|
|
2656
|
+
className: 'jmw-cred-input',
|
|
2657
|
+
type: 'text',
|
|
2658
|
+
inputMode: 'email',
|
|
2659
|
+
autoComplete: 'off',
|
|
2660
|
+
spellCheck: false,
|
|
2661
|
+
placeholder: 'name@company.com',
|
|
2662
|
+
value: form.email,
|
|
2663
|
+
onInput: (event) => update('email', event?.target?.value ?? ''),
|
|
2664
|
+
onKeyDown: onEnter,
|
|
2665
|
+
}),
|
|
2666
|
+
h('label', { key: 'tk-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-token' }, t('connectTokenLabel')),
|
|
2667
|
+
h('input', {
|
|
2668
|
+
key: 'tk-input',
|
|
2669
|
+
id: 'jmw-connect-token',
|
|
2670
|
+
className: 'jmw-cred-input',
|
|
2671
|
+
type: 'password',
|
|
2672
|
+
autoComplete: 'off',
|
|
2673
|
+
spellCheck: false,
|
|
2674
|
+
placeholder: origin?.configured
|
|
2675
|
+
? t('connectTokenKeep', { masked: origin.masked })
|
|
2676
|
+
: t('connectTokenPlaceholder'),
|
|
2677
|
+
value: form.token,
|
|
2678
|
+
onInput: (event) => update('token', event?.target?.value ?? ''),
|
|
2679
|
+
onKeyDown: onEnter,
|
|
2680
|
+
}),
|
|
2681
|
+
]),
|
|
2682
|
+
h('div', { key: 'actions', className: 'jmw-cred-actions jmw-connect-actions' }, [
|
|
2683
|
+
h('button', {
|
|
2684
|
+
key: 'submit',
|
|
2685
|
+
type: 'button',
|
|
2686
|
+
// 和配置页「保存并验证」同一套按钮样式(类 + 内联兜底色)。
|
|
2687
|
+
className: 'jmw-cred-btn primary',
|
|
2688
|
+
style: BTN_PRIMARY,
|
|
2689
|
+
disabled: !canSubmit,
|
|
2690
|
+
onClick: () => { void submit(); },
|
|
2691
|
+
}, form.busy ? t('connectSaving') : t('connectSubmit')),
|
|
2692
|
+
h('button', {
|
|
2693
|
+
key: 'config',
|
|
2694
|
+
type: 'button',
|
|
2695
|
+
className: 'jmw-cred-btn',
|
|
2696
|
+
style: BTN_PLAIN,
|
|
2697
|
+
onClick: () => props?.onOpenConfig?.(),
|
|
2698
|
+
}, t('failOpenConfig')),
|
|
2699
|
+
]),
|
|
2700
|
+
form.error ? h('div', { key: 'error', className: 'jmw-cred-msg err' }, form.error) : null,
|
|
2701
|
+
h('div', { key: 'note', className: 'jmw-connect-note' }, [
|
|
2702
|
+
h('a', { key: 'tokens', className: 'jmw-cred-link', href: TOKENS_URL, target: '_blank', rel: 'noreferrer' }, t('credTokensLink')),
|
|
2703
|
+
]),
|
|
2704
|
+
]);
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2511
2707
|
function Panel() {
|
|
2512
2708
|
const state = useSnapshot();
|
|
2513
2709
|
const cardRef = React.useRef(null);
|
|
@@ -2710,9 +2906,11 @@ window.__ModuleLoader__.load({
|
|
|
2710
2906
|
let body;
|
|
2711
2907
|
if (state.failure) {
|
|
2712
2908
|
// 可分类的失败:标题 + 一句「怎么办」+ 按钮;原始报错只在 detail 类里以小字附在下面。
|
|
2909
|
+
// 「还没配置」这一类(站点 / 邮箱 / 令牌)不给失败提示:同一块位置直接换成连接表单。
|
|
2713
2910
|
const meta = failureMeta(state.failure.code);
|
|
2911
|
+
const setup = CONNECT_CODES.has(state.failure.code);
|
|
2714
2912
|
const actions = [];
|
|
2715
|
-
if (meta.config) {
|
|
2913
|
+
if (!setup && meta.config) {
|
|
2716
2914
|
actions.push(h('button', {
|
|
2717
2915
|
key: 'config',
|
|
2718
2916
|
type: 'button',
|
|
@@ -2723,20 +2921,28 @@ window.__ModuleLoader__.load({
|
|
|
2723
2921
|
onClick: () => setCredOpen(true),
|
|
2724
2922
|
}, t('failOpenConfig')));
|
|
2725
2923
|
}
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
h(
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
:
|
|
2739
|
-
|
|
2924
|
+
if (!setup) {
|
|
2925
|
+
actions.push(h('button', {
|
|
2926
|
+
key: 'retry',
|
|
2927
|
+
type: 'button',
|
|
2928
|
+
className: 'jmw-btn',
|
|
2929
|
+
onClick: () => load(snapshot.scope),
|
|
2930
|
+
}, t('retry')));
|
|
2931
|
+
}
|
|
2932
|
+
body = setup
|
|
2933
|
+
? h(ConnectForm, {
|
|
2934
|
+
key: 'connect',
|
|
2935
|
+
onConnected: () => { void load(snapshot.scope); },
|
|
2936
|
+
onOpenConfig: () => setCredOpen(true),
|
|
2937
|
+
})
|
|
2938
|
+
: h('div', { className: 'jmw-state err jmw-failure' }, [
|
|
2939
|
+
h('div', { key: 'title', className: 'jmw-failure-title' }, t(meta.title)),
|
|
2940
|
+
h('div', { key: 'hint', className: 'jmw-failure-hint' }, t(meta.hint)),
|
|
2941
|
+
h('div', { key: 'actions', className: 'jmw-failure-actions' }, actions),
|
|
2942
|
+
meta.detail && state.failure.message
|
|
2943
|
+
? h('div', { key: 'detail', className: 'jmw-failure-detail' }, t('failDetail', { message: state.failure.message }))
|
|
2944
|
+
: null,
|
|
2945
|
+
]);
|
|
2740
2946
|
} else if (state.error) {
|
|
2741
2947
|
body = h('div', { className: 'jmw-state err' }, [
|
|
2742
2948
|
h('div', { key: 'msg', className: 'msg' }, state.error),
|
|
@@ -3049,7 +3255,13 @@ window.__ModuleLoader__.load({
|
|
|
3049
3255
|
onClick: () => setCredOpen(false),
|
|
3050
3256
|
}, h(CloseGlyph)),
|
|
3051
3257
|
]),
|
|
3052
|
-
|
|
3258
|
+
// 保存成功就让面板重拉一次列表:否则配置完关掉弹窗,后面还是那张
|
|
3259
|
+
// 「没有配置 / 加载失败」的旧错误页,用户以为没生效。
|
|
3260
|
+
h(CredentialSettings, {
|
|
3261
|
+
key: 'body',
|
|
3262
|
+
view: 'page',
|
|
3263
|
+
onChanged: () => { if (state.open) void load(snapshot.scope); },
|
|
3264
|
+
}),
|
|
3053
3265
|
]))
|
|
3054
3266
|
: null;
|
|
3055
3267
|
|
|
@@ -3212,34 +3424,45 @@ window.__ModuleLoader__.load({
|
|
|
3212
3424
|
|
|
3213
3425
|
async function save() {
|
|
3214
3426
|
// 令牌与邮箱是一对:有令牌就用新令牌,没令牌时用当前生效的那把(只改邮箱的场景)。
|
|
3427
|
+
// 站点地址也一并带上:用户在同一张表单里刚填的地址不该要求他先单独点一次「保存地址」,
|
|
3428
|
+
// 否则他只点「保存并验证」时地址根本没落盘,列表照样报 no_base_url。
|
|
3215
3429
|
const token = state.input.trim();
|
|
3216
3430
|
const email = state.email.trim();
|
|
3217
|
-
|
|
3431
|
+
const baseUrl = state.baseUrlDraft.trim();
|
|
3432
|
+
if (!token && !emailChanged() && !baseUrl) return;
|
|
3218
3433
|
setState((prev) => ({ ...prev, busy: 'save', message: '', error: '' }));
|
|
3219
3434
|
try {
|
|
3220
3435
|
const response = await watchFetch(CREDENTIAL_PATH, {
|
|
3221
3436
|
method: 'POST',
|
|
3222
3437
|
headers: { accept: 'application/json', 'content-type': 'application/json' },
|
|
3223
|
-
body: JSON.stringify({ token, email }),
|
|
3438
|
+
body: JSON.stringify(baseUrl ? { token, email, baseUrl } : { token, email }),
|
|
3224
3439
|
});
|
|
3225
3440
|
const payload = await response.json().catch(() => null);
|
|
3226
3441
|
if (payload?.ok !== true) throw new Error(payload?.error || `HTTP ${response.status}`);
|
|
3227
3442
|
const offline = payload.verification && payload.verification.ok === false;
|
|
3228
3443
|
const account = payload.verification?.account ? ` ${t('credSavedAs', { account: payload.verification.account })}` : '';
|
|
3229
3444
|
const emailNote = payload.emailSaved ? ` ${t('credSavedEmail', { email: payload.email ?? email })}` : '';
|
|
3445
|
+
const baseUrlNote = payload.baseUrlSaved
|
|
3446
|
+
? ` ${payload.baseUrlPersisted === false
|
|
3447
|
+
? t('baseUrlSavedLocal', { baseUrl: String(payload.baseUrl ?? baseUrl), reason: String(payload.baseUrlReason ?? '') })
|
|
3448
|
+
: t('credSavedBaseUrl', { baseUrl: String(payload.baseUrl ?? baseUrl) })}`
|
|
3449
|
+
: '';
|
|
3230
3450
|
setState((prev) => ({
|
|
3231
3451
|
...prev,
|
|
3232
3452
|
busy: '',
|
|
3233
3453
|
input: '',
|
|
3234
3454
|
email: String(payload.email ?? prev.email),
|
|
3235
3455
|
emailTouched: false,
|
|
3456
|
+
// 地址已经落盘:清空草稿,placeholder 变成新地址。
|
|
3457
|
+
baseUrlDraft: payload.baseUrlSaved ? '' : prev.baseUrlDraft,
|
|
3236
3458
|
status: payload,
|
|
3237
3459
|
error: '',
|
|
3238
3460
|
// 账号只跟着这次保存的消息显示;不要把验证结果留在 state 里,否则下一条消息也会挂上它。
|
|
3239
3461
|
message: (offline
|
|
3240
3462
|
? t('credSavedOffline', { key: payload.credentialKey, message: payload.verification.message ?? '' })
|
|
3241
|
-
: t('credSaved', { key: payload.credentialKey })) + emailNote + account,
|
|
3463
|
+
: t('credSaved', { key: payload.credentialKey })) + emailNote + baseUrlNote + account,
|
|
3242
3464
|
}));
|
|
3465
|
+
props?.onChanged?.();
|
|
3243
3466
|
} catch (error) {
|
|
3244
3467
|
setState((prev) => ({ ...prev, busy: '', error: t('credSaveFailed', { message: String(error?.message ?? error) }) }));
|
|
3245
3468
|
}
|
|
@@ -3271,12 +3494,15 @@ window.__ModuleLoader__.load({
|
|
|
3271
3494
|
baseUrlBusy: false,
|
|
3272
3495
|
baseUrlDraft: '',
|
|
3273
3496
|
baseUrlError: '',
|
|
3274
|
-
baseUrlMessage:
|
|
3497
|
+
baseUrlMessage: payload?.persisted === false
|
|
3498
|
+
? t('baseUrlSavedLocal', { baseUrl: String(payload?.applied?.baseUrl ?? value), reason: String(payload?.reason ?? '') })
|
|
3499
|
+
: t('baseUrlSaved', { baseUrl: String(payload?.applied?.baseUrl ?? value) }),
|
|
3275
3500
|
// 保存成功顺带刷新一遍状态:placeholder 立刻显示新的生效地址。
|
|
3276
3501
|
...readWatch(payload, prev),
|
|
3277
3502
|
}));
|
|
3278
3503
|
baseUrlFlashTimer = setTimeout(() => setState((prev) => ({ ...prev, baseUrlMessage: '' })), 2600);
|
|
3279
3504
|
if (typeof baseUrlFlashTimer?.unref === 'function') baseUrlFlashTimer.unref();
|
|
3505
|
+
props?.onChanged?.();
|
|
3280
3506
|
void refresh();
|
|
3281
3507
|
} catch (error) {
|
|
3282
3508
|
setState((prev) => ({ ...prev, baseUrlBusy: false, baseUrlError: t('baseUrlSaveFailed', { message: String(error?.message ?? error) }) }));
|
|
@@ -3468,6 +3694,7 @@ window.__ModuleLoader__.load({
|
|
|
3468
3694
|
const payload = await response.json().catch(() => null);
|
|
3469
3695
|
if (payload?.ok !== true) throw new Error(payload?.error || `HTTP ${response.status}`);
|
|
3470
3696
|
setState((prev) => ({ ...prev, busy: '', status: payload, error: '', message: t('credCleared', { key: payload.credentialKey }) }));
|
|
3697
|
+
props?.onChanged?.();
|
|
3471
3698
|
} catch (error) {
|
|
3472
3699
|
setState((prev) => ({ ...prev, busy: '', error: t('credClearFailed', { message: String(error?.message ?? error) }) }));
|
|
3473
3700
|
}
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -2309,12 +2309,13 @@ async function resolveToken(ctx, settings) {
|
|
|
2309
2309
|
|
|
2310
2310
|
/**
|
|
2311
2311
|
* 拿候选「邮箱 + 令牌」试一次 /myself:能分清「这个组合不对」(401/403)与「网络不通」。
|
|
2312
|
-
* email
|
|
2312
|
+
* email / site 省略时用当前生效值;site 允许传「还没落盘的候选地址」,免得用户
|
|
2313
|
+
* 在同一张表单里刚填的站点地址要先保存一次才能验证。
|
|
2313
2314
|
*/
|
|
2314
|
-
async function verifyCredential(settings, token, signal, email) {
|
|
2315
|
+
async function verifyCredential(settings, token, signal, email, site) {
|
|
2315
2316
|
const account = typeof email === 'string' && email ? email : liveSetting(settings, 'email', '');
|
|
2316
2317
|
const auth = Buffer.from(`${account}:${token}`, 'utf8').toString('base64');
|
|
2317
|
-
const response = await fetch(`${baseUrlOf(settings)}/rest/api/3/myself`, {
|
|
2318
|
+
const response = await fetch(`${site || baseUrlOf(settings)}/rest/api/3/myself`, {
|
|
2318
2319
|
headers: { Authorization: `Basic ${auth}`, Accept: 'application/json' },
|
|
2319
2320
|
signal,
|
|
2320
2321
|
});
|
|
@@ -2377,9 +2378,21 @@ function registerCredentialRoute(ctx, jira, settings) {
|
|
|
2377
2378
|
// 令牌与邮箱是一对:都从 payload 里取,缺的那一半用当前生效值。
|
|
2378
2379
|
const token = typeof payload?.token === 'string' ? payload.token.trim() : '';
|
|
2379
2380
|
const rawEmail = typeof payload?.email === 'string' ? payload.email.trim() : '';
|
|
2381
|
+
const rawBaseUrl = typeof payload?.baseUrl === 'string' ? payload.baseUrl.trim() : '';
|
|
2380
2382
|
const current = await resolveToken(ctx, settings);
|
|
2381
2383
|
const currentEmail = String(liveSetting(settings, 'email', '') ?? '').trim();
|
|
2382
2384
|
const nextEmail = rawEmail || currentEmail;
|
|
2385
|
+
// 站点地址也能和令牌一起提交:同一张表单里刚填的地址不必先单独保存一次,
|
|
2386
|
+
// 否则用户只点「保存并验证」时地址根本没落盘,列表照样是 no_base_url。
|
|
2387
|
+
let nextBaseUrl = baseUrlOf(settings);
|
|
2388
|
+
if (rawBaseUrl) {
|
|
2389
|
+
try {
|
|
2390
|
+
nextBaseUrl = normalizeBaseUrl(rawBaseUrl);
|
|
2391
|
+
} catch (error) {
|
|
2392
|
+
return jsonResponse({ ok: false, error: String(error?.message ?? error) }, 400);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
if (!nextBaseUrl) return jsonResponse({ ok: false, error: t('err.noBaseUrl') }, 400);
|
|
2383
2396
|
|
|
2384
2397
|
if (!nextEmail) return jsonResponse({ ok: false, error: t('err.needEmail') }, 400);
|
|
2385
2398
|
if (rawEmail && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(rawEmail)) {
|
|
@@ -2393,7 +2406,7 @@ function registerCredentialRoute(ctx, jira, settings) {
|
|
|
2393
2406
|
// 网络层失败照存但提示(同令牌单独保存时的策略)。
|
|
2394
2407
|
let verification = { skipped: true, reason: t('verify.skipped') };
|
|
2395
2408
|
try {
|
|
2396
|
-
const probe = await verifyCredential(settings, candidate, request.signal, nextEmail);
|
|
2409
|
+
const probe = await verifyCredential(settings, candidate, request.signal, nextEmail, nextBaseUrl);
|
|
2397
2410
|
verification = probe;
|
|
2398
2411
|
if (probe.ok === false && (probe.status === 401 || probe.status === 403)) {
|
|
2399
2412
|
return jsonResponse({
|
|
@@ -2417,8 +2430,29 @@ function registerCredentialRoute(ctx, jira, settings) {
|
|
|
2417
2430
|
await writeSettings(ctx, settings, { email: nextEmail });
|
|
2418
2431
|
emailSaved = true;
|
|
2419
2432
|
}
|
|
2433
|
+
let baseUrlSaved = false;
|
|
2434
|
+
let baseUrlPersisted = true;
|
|
2435
|
+
let baseUrlReason;
|
|
2436
|
+
if (rawBaseUrl) {
|
|
2437
|
+
// 验证已经用的是这个地址;这里只负责落盘,失败要把原因回给界面。
|
|
2438
|
+
const written = await writeSettings(ctx, settings, { baseUrl: nextBaseUrl });
|
|
2439
|
+
baseUrlSaved = true;
|
|
2440
|
+
baseUrlPersisted = written?.persisted !== false;
|
|
2441
|
+
baseUrlReason = written?.reason;
|
|
2442
|
+
}
|
|
2420
2443
|
const status = await credentialStatus(ctx, settings);
|
|
2421
|
-
return jsonResponse({
|
|
2444
|
+
return jsonResponse({
|
|
2445
|
+
ok: true,
|
|
2446
|
+
saved: true,
|
|
2447
|
+
tokenSaved: Boolean(token),
|
|
2448
|
+
emailSaved,
|
|
2449
|
+
baseUrlSaved,
|
|
2450
|
+
baseUrlPersisted,
|
|
2451
|
+
baseUrlReason,
|
|
2452
|
+
baseUrl: baseUrlOf(settings),
|
|
2453
|
+
verification,
|
|
2454
|
+
...status,
|
|
2455
|
+
});
|
|
2422
2456
|
} catch (error) {
|
|
2423
2457
|
return jsonResponse({ ok: false, error: String(error?.message ?? error) }, 400);
|
|
2424
2458
|
}
|
package/package.json
CHANGED
|
@@ -691,6 +691,45 @@ if (baseUrlInput()) {
|
|
|
691
691
|
console.log('非法地址 → 被拒:', settingsWrites.length === beforeBad,
|
|
692
692
|
'| 错误文案:', collect(credPage, (row) => classNameOf(row).includes('jmw-cred-msg') && classNameOf(row).includes('err')).map((row) => text(row).trim()).join(' | '));
|
|
693
693
|
}
|
|
694
|
+
// 站点地址与令牌一起提交:同一张表单里填的地址要跟着「保存并验证」一起落盘,
|
|
695
|
+
// 否则用户只点那个按钮时地址根本没保存,列表还是 no_base_url。
|
|
696
|
+
{
|
|
697
|
+
const beforeWrites = settingsWrites.length;
|
|
698
|
+
const beforeCalls = myselfCalls.length;
|
|
699
|
+
const response = await credentialFetch(CRED_PATH, {
|
|
700
|
+
method: 'POST',
|
|
701
|
+
headers: { 'content-type': 'application/json' },
|
|
702
|
+
body: JSON.stringify({ token: GOOD, email: 'someone@example.com', baseUrl: 'https://saved-with-token.atlassian.net/' }),
|
|
703
|
+
});
|
|
704
|
+
const body = await response.json().catch(() => ({}));
|
|
705
|
+
const write = settingsWrites[settingsWrites.length - 1];
|
|
706
|
+
const baseOp = write?.ops?.find((op) => op.path[0] === 'baseUrl');
|
|
707
|
+
const probe = myselfCalls[myselfCalls.length - 1];
|
|
708
|
+
const okSave = body.ok === true && body.baseUrlSaved === true && body.baseUrl === 'https://saved-with-token.atlassian.net';
|
|
709
|
+
const okWrite = settingsWrites.length > beforeWrites && baseOp?.value === 'https://saved-with-token.atlassian.net';
|
|
710
|
+
const okProbe = myselfCalls.length > beforeCalls && String(probe?.url ?? '').startsWith('https://saved-with-token.atlassian.net/rest/api/3/myself');
|
|
711
|
+
console.log('\n令牌 + 站点地址一次保存: ok:', body.ok === true, '| baseUrlSaved:', body.baseUrlSaved, '| baseUrl:', body.baseUrl);
|
|
712
|
+
console.log(' profile patch 写入:', okWrite, '| /myself 用新地址验证:', okProbe, '(', probe?.url, ')');
|
|
713
|
+
if (!okSave || !okWrite || !okProbe) process.exitCode = 1;
|
|
714
|
+
|
|
715
|
+
const beforeBad = settingsWrites.length;
|
|
716
|
+
const bad = await credentialFetch(CRED_PATH, {
|
|
717
|
+
method: 'POST',
|
|
718
|
+
headers: { 'content-type': 'application/json' },
|
|
719
|
+
body: JSON.stringify({ token: GOOD, email: 'someone@example.com', baseUrl: 'not a url' }),
|
|
720
|
+
});
|
|
721
|
+
const badBody = await bad.json().catch(() => ({}));
|
|
722
|
+
console.log(' 非法站点地址一起提交 → 被拒:', badBody.ok === false, '| 未写入:', settingsWrites.length === beforeBad,
|
|
723
|
+
'| 文案:', badBody.error);
|
|
724
|
+
if (badBody.ok !== false || settingsWrites.length !== beforeBad) process.exitCode = 1;
|
|
725
|
+
|
|
726
|
+
// 还原:后面的用例还要用配置里的站点地址。
|
|
727
|
+
await settingsFetch(SETTINGS_PATH, {
|
|
728
|
+
method: 'POST',
|
|
729
|
+
headers: { 'content-type': 'application/json' },
|
|
730
|
+
body: JSON.stringify({ baseUrl: env.JIRA_BASE_URL }),
|
|
731
|
+
});
|
|
732
|
+
}
|
|
694
733
|
// 界面语言:三个 chip(自动 / 中文 / English),点了立刻写进 profile 的 Cordis patch
|
|
695
734
|
// 迷你 React 不保留 key,所以按「文本是三种语言名之一」来找(配置页里不会同时出现状态下拉的 chip)
|
|
696
735
|
const LANG_LABELS = ['自动', '中文', 'English'];
|
package/test/dsh-jira-shot.mjs
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* panel-watch.png 实时监视横幅 + 某一行展开的状态流转下拉
|
|
20
20
|
* plan-flow.png 绑定工作区 → 点「计划」的四步图解(示意图,不是真截图)
|
|
21
21
|
* sidebar-entry.png 左侧栏入口 + 未读角标
|
|
22
|
+
* panel-connect.png 第一次用(什么都没配):失败位置就是「连接 Jira」表单
|
|
22
23
|
* zh 版本加 `.zh` 后缀
|
|
23
24
|
*/
|
|
24
25
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
@@ -572,6 +573,7 @@ const effects = [];
|
|
|
572
573
|
* `options.search` —— 搜索框里的关键词(非空时命令面收到 `--search=`,回搜索命中载荷)
|
|
573
574
|
* `options.workspace` —— 当前会话所在的工作区 id(面板按它自动选项目 tab)
|
|
574
575
|
* `options.plans` —— 已绑定的计划对话 `{ ISSUE: sessionId }`(任务行「计划」标成 on + 多个「×」)
|
|
576
|
+
* `options.failCode` —— 让 `--json` 回 `ok:false` + `error.code`(面板据此渲染失败提示 / 连接表单)
|
|
575
577
|
*/
|
|
576
578
|
async function loadClient(lang, options = {}) {
|
|
577
579
|
hookStore.clear();
|
|
@@ -589,6 +591,7 @@ async function loadClient(lang, options = {}) {
|
|
|
589
591
|
const payload = demoPayload(lang);
|
|
590
592
|
const searchPayloadData = searchPayload(lang);
|
|
591
593
|
const commandCalls = [];
|
|
594
|
+
const failCode = options.failCode ?? '';
|
|
592
595
|
const plans = { sessions: { ...(options.plans ?? {}) } };
|
|
593
596
|
|
|
594
597
|
const clientCtx = {
|
|
@@ -599,6 +602,11 @@ async function loadClient(lang, options = {}) {
|
|
|
599
602
|
async execute(sessionId, line) {
|
|
600
603
|
await new Promise((done) => setTimeout(done, 20));
|
|
601
604
|
commandCalls.push(String(line));
|
|
605
|
+
// 失败载荷与真 host 同形:`--json` 不 throw,回 `ok:false` + `error:{code,message}`。
|
|
606
|
+
if (failCode) {
|
|
607
|
+
const fail = { ok: false, items: [], total: null, error: { code: failCode, message: 'Missing Jira credential: put JIRA_API_TOKEN into the DSH credential store.' } };
|
|
608
|
+
return { ok: true, value: { commandId: 'jira', result: { kind: 'success', text: JSON.stringify(fail) } } };
|
|
609
|
+
}
|
|
602
610
|
// 带 `--search=` 的那次查询回搜索命中(与真 host 一样:同一份载荷形状,集合换了)。
|
|
603
611
|
const searched = /--search=(.+)$/.exec(String(line));
|
|
604
612
|
const data = searched && searched[1].trim() ? searchPayloadData : payload;
|
|
@@ -622,6 +630,10 @@ async function loadClient(lang, options = {}) {
|
|
|
622
630
|
__DSH_TRANSPORT__: {
|
|
623
631
|
async fetch(url, init = {}) {
|
|
624
632
|
const path = String(url).split('?')[0];
|
|
633
|
+
// 连接表单进面板先 GET 一次已保存的连接信息;截图里是全新安装,三项都空。
|
|
634
|
+
if (path === '/api/jira-work-overview/credential') {
|
|
635
|
+
return { ok: true, status: 200, async json() { return { ok: true, configured: false, masked: '', settings: { baseUrl: '' }, email: '' }; } };
|
|
636
|
+
}
|
|
625
637
|
if (path === '/api/jira-work-overview/transition') {
|
|
626
638
|
const key = new URL(url, 'http://shot.invalid').searchParams.get('key') ?? '';
|
|
627
639
|
const current = payload.items.find((row) => row.key === key)?.status ?? 'To Do';
|
|
@@ -958,6 +970,16 @@ for (const lang of LANGS) {
|
|
|
958
970
|
shot(`panel${suffix}`, panelHtml('panel', panel), PANEL_W, PANEL_H);
|
|
959
971
|
}
|
|
960
972
|
|
|
973
|
+
/* --- 1b) 第一次用:面板 body 就是「连接 Jira」表单(没站点 / 邮箱 / 令牌) --- */
|
|
974
|
+
if (WANTED('panel-connect')) {
|
|
975
|
+
currentEntries = {};
|
|
976
|
+
transport.watchState.payload = CLEAN_WATCH;
|
|
977
|
+
await openPanel(lang, { failCode: 'no_credential' });
|
|
978
|
+
await settle(160);
|
|
979
|
+
const panel = renderPanel();
|
|
980
|
+
shot(`panel-connect${suffix}`, panelHtml('panel-connect', panel), PANEL_W, PANEL_H);
|
|
981
|
+
}
|
|
982
|
+
|
|
961
983
|
/* --- 2) 实时监视横幅 + 某一行的状态流转下拉 --- */
|
|
962
984
|
if (WANTED('panel-watch')) {
|
|
963
985
|
// 打开 APP-412 那一行的下拉:真库量到那行变高后会把后面的行整体下移,截图里同样让位。
|
package/test/dsh-jira-visual.mjs
CHANGED
|
@@ -183,6 +183,9 @@ Object.defineProperty(globalThis, 'window', {
|
|
|
183
183
|
__DSH_TRANSPORT__: {
|
|
184
184
|
async fetch(url, init) {
|
|
185
185
|
const method = String(init?.method ?? 'GET').toUpperCase();
|
|
186
|
+
if (String(url).split('?')[0] === '/api/jira-work-overview/credential') {
|
|
187
|
+
return credentialFetch(String(url), init ?? {});
|
|
188
|
+
}
|
|
186
189
|
if (String(url).split('?')[0] === '/api/jira-work-overview/transition') {
|
|
187
190
|
return transitionFetch(String(url), init ?? {});
|
|
188
191
|
}
|
|
@@ -230,6 +233,41 @@ async function transitionFetch(url, init) {
|
|
|
230
233
|
return OK({ ok: true, key, current: transitionState.current, currentCategory: 'new', transitions: TRANSITIONS });
|
|
231
234
|
}
|
|
232
235
|
|
|
236
|
+
/* --------------------------------------- 连接表单的 credential 通道 stub ----
|
|
237
|
+
真校验(打 /myself、401 拒绝、写凭据库)在 dsh-jira-credential 套件里跑;这里只关心面板:
|
|
238
|
+
表单回填已保存值、只提交改过的字段、保存成功后回到列表。 */
|
|
239
|
+
const credentialState = { configured: false, baseUrl: '', email: '', masked: '', token: '', posts: [] };
|
|
240
|
+
async function credentialFetch(url, init) {
|
|
241
|
+
const method = String(init.method ?? 'GET').toUpperCase();
|
|
242
|
+
await new Promise((resolve) => setTimeout(resolve, 5));
|
|
243
|
+
if (method === 'POST') {
|
|
244
|
+
const body = init.body ? JSON.parse(init.body) : {};
|
|
245
|
+
credentialState.posts.push(body);
|
|
246
|
+
if (body.baseUrl !== undefined) credentialState.baseUrl = body.baseUrl;
|
|
247
|
+
if (body.email !== undefined) credentialState.email = body.email;
|
|
248
|
+
if (body.token) {
|
|
249
|
+
credentialState.token = body.token;
|
|
250
|
+
credentialState.configured = true;
|
|
251
|
+
}
|
|
252
|
+
return OK({
|
|
253
|
+
ok: true,
|
|
254
|
+
saved: true,
|
|
255
|
+
configured: credentialState.configured,
|
|
256
|
+
masked: 'ATATT…F000',
|
|
257
|
+
settings: { baseUrl: credentialState.baseUrl },
|
|
258
|
+
email: credentialState.email,
|
|
259
|
+
verification: { ok: true, account: '张三' },
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return OK({
|
|
263
|
+
ok: true,
|
|
264
|
+
configured: credentialState.configured,
|
|
265
|
+
masked: credentialState.masked,
|
|
266
|
+
settings: { baseUrl: credentialState.baseUrl },
|
|
267
|
+
email: credentialState.email,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
233
271
|
|
|
234
272
|
/* 站点优先级名次(GET /rest/api/3/priority 的数组下标,0 = 最高级)——host 发下来的就是这个。
|
|
235
273
|
fixture 里带上它,走的就是「按 Jira 名次上底色」的主路径;H 段再单独验没有名次时的名字兜底。 */
|
|
@@ -795,59 +833,135 @@ check(
|
|
|
795
833
|
activeFixture.current = FIXTURE;
|
|
796
834
|
await pickStatus('全部状态');
|
|
797
835
|
|
|
798
|
-
/* ---------------- I
|
|
799
|
-
host 在 --json 失败时回 ok:false + error.code
|
|
800
|
-
|
|
836
|
+
/* ---------------- I:没配置时 → 失败位置直接换成「连接 Jira」表单 ----------------
|
|
837
|
+
host 在 --json 失败时回 ok:false + error.code。no_base_url / no_email / no_credential
|
|
838
|
+
都是「还没配好」:面板要在同一块位置渲染登录表单(站点 + 邮箱 + 令牌),填完保存就拉列表;
|
|
839
|
+
其它 code(auth / network…)仍走「提示 + 去配置 / 重试」。 */
|
|
801
840
|
const clsOf = (row) => String(row.props?.className ?? '');
|
|
802
|
-
const
|
|
803
|
-
const failTitle = () => text(
|
|
804
|
-
const failHint = () => text(
|
|
841
|
+
const nodeOf = (name) => collect(panel, (row) => clsOf(row) === name)[0];
|
|
842
|
+
const failTitle = () => text(nodeOf('jmw-failure-title')).trim();
|
|
843
|
+
const failHint = () => text(nodeOf('jmw-failure-hint')).trim();
|
|
805
844
|
const failDetails = () => collect(panel, (row) => clsOf(row) === 'jmw-failure-detail');
|
|
806
|
-
|
|
845
|
+
const connectTitle = () => text(nodeOf('jmw-connect-title')).trim();
|
|
846
|
+
const connectHint = () => text(nodeOf('jmw-connect-hint')).trim();
|
|
847
|
+
const connectInput = (field) => collect(panel, (row) => row.type === 'input' && row.props?.id === `jmw-connect-${field}`)[0];
|
|
807
848
|
const isActionBtn = (row) => row.type === 'button' && /^jmw-(cred-)?btn(\s|$)/.test(clsOf(row));
|
|
808
|
-
const
|
|
849
|
+
const buttonOf = (label) => collect(panel, (row) => isActionBtn(row) && text(row).trim() === label)[0];
|
|
809
850
|
const refreshBtn = () => collect(panel, (row) => row.type === 'button' && row.props?.['aria-label'] === '刷新')[0];
|
|
851
|
+
// 迷你 React 不模拟卸载:新的失败场景要清掉上个表单的 hook 状态(真 React 由 key / 位置决定)。
|
|
852
|
+
const resetConnectForm = () => hookStore.delete('ConnectForm');
|
|
853
|
+
const flush = async (ms = 40) => { await new Promise((resolve) => setTimeout(resolve, ms)); };
|
|
810
854
|
|
|
855
|
+
/* 场景 1:只缺令牌(站点 / 邮箱已保存)→ 回填这两项,令牌空着不给提交。 */
|
|
811
856
|
activeFailure.current = { code: 'no_credential', message: 'Missing Jira credential: put JIRA_API_TOKEN into the DSH credential store…' };
|
|
857
|
+
credentialState.configured = false;
|
|
858
|
+
credentialState.baseUrl = 'https://example.atlassian.net';
|
|
859
|
+
credentialState.email = 'dev@example.com';
|
|
860
|
+
resetConnectForm();
|
|
812
861
|
refreshBtn().props.onClick();
|
|
813
862
|
await settle();
|
|
814
863
|
panel = renderPanel();
|
|
815
|
-
|
|
864
|
+
await flush();
|
|
865
|
+
panel = renderPanel();
|
|
866
|
+
console.log('\nI 没配令牌:标题 =', JSON.stringify(connectTitle()), '| 提示 =', JSON.stringify(connectHint()), '| 失败提示可见 =', failTitle() !== '');
|
|
867
|
+
check(
|
|
868
|
+
connectTitle() === '连接 Jira'
|
|
869
|
+
&& connectHint().includes('API token')
|
|
870
|
+
&& failTitle() === '' && failHint() === '' && failDetails().length === 0
|
|
871
|
+
&& collect(panel, (row) => clsOf(row) === 'jmw-state err jmw-failure').length === 0,
|
|
872
|
+
'I 没配令牌 → 失败位置换成「连接 Jira」表单(不再显示失败标题 / 原始报错)',
|
|
873
|
+
`${connectTitle()} / failure=${failTitle()}`,
|
|
874
|
+
);
|
|
875
|
+
check(
|
|
876
|
+
Boolean(connectInput('base-url')) && Boolean(connectInput('email')) && Boolean(connectInput('token')),
|
|
877
|
+
'I 表单有站点地址 / 邮箱 / API token 三个输入框',
|
|
878
|
+
['base-url', 'email', 'token'].map((field) => `${field}=${Boolean(connectInput(field))}`).join(' '),
|
|
879
|
+
);
|
|
880
|
+
check(
|
|
881
|
+
connectInput('base-url').props.value === 'https://example.atlassian.net'
|
|
882
|
+
&& connectInput('email').props.value === 'dev@example.com'
|
|
883
|
+
&& connectInput('token').props.value === '',
|
|
884
|
+
'I 只缺令牌时回填已保存的站点与邮箱(令牌永远是空输入框)',
|
|
885
|
+
`${connectInput('base-url').props.value} / ${connectInput('email').props.value}`,
|
|
886
|
+
);
|
|
816
887
|
check(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
&& failButtons().includes('重试')
|
|
821
|
-
&& failDetails().length === 0,
|
|
822
|
-
'I 无令牌 → 提示文字 + 去配置 / 重试,且不显示原始报错',
|
|
823
|
-
`${failTitle()} / ${failButtons().join(',')}`,
|
|
888
|
+
connectInput('token').props.placeholder === '粘贴 Jira API token' && buttonOf('保存并连接')?.props.disabled === true,
|
|
889
|
+
'I 令牌为空时「保存并连接」不可点(缺什么填什么)',
|
|
890
|
+
`placeholder=${JSON.stringify(connectInput('token').props.placeholder)} disabled=${buttonOf('保存并连接')?.props.disabled}`,
|
|
824
891
|
);
|
|
825
|
-
const openConfig = collect(panel, (row) => isActionBtn(row) && text(row).trim() === '去配置')[0];
|
|
826
892
|
check(
|
|
827
|
-
/\bprimary\b/.test(clsOf(
|
|
828
|
-
|
|
829
|
-
'
|
|
830
|
-
`class=${clsOf(openConfig)} style=${JSON.stringify(openConfig?.props?.style)}`,
|
|
893
|
+
/\bprimary\b/.test(clsOf(buttonOf('保存并连接'))) && buttonOf('保存并连接')?.props?.style?.background === '#4d6bfe',
|
|
894
|
+
'I 「保存并连接」用和配置页「保存并验证」一致的深底白字样式',
|
|
895
|
+
`class=${clsOf(buttonOf('保存并连接'))}`,
|
|
831
896
|
);
|
|
832
|
-
|
|
897
|
+
|
|
898
|
+
/* 去配置仍然在(轮询 / 通知 / 语言这些高级项),点开还是令牌弹窗。 */
|
|
899
|
+
buttonOf('去配置').props.onClick();
|
|
833
900
|
panel = renderPanel();
|
|
834
901
|
check(
|
|
835
902
|
collect(panel, (row) => clsOf(row) === 'jmw-credmodal').length === 1,
|
|
836
|
-
'I
|
|
903
|
+
'I 表单里的「去配置」照旧直达令牌弹窗',
|
|
837
904
|
`jmw-credmodal=${collect(panel, (row) => clsOf(row) === 'jmw-credmodal').length}`,
|
|
838
905
|
);
|
|
839
906
|
keyHandlers[keyHandlers.length - 1]({ key: 'Escape', preventDefault() {} });
|
|
840
907
|
panel = renderPanel();
|
|
841
908
|
|
|
842
|
-
/*
|
|
909
|
+
/* 场景 2:填令牌 → 保存并连接 → 只提交改过的字段,列表立刻回来。 */
|
|
910
|
+
connectInput('token').props.onInput({ target: { value: 'ATATT3xFfGF0TOKENTOKENTOKEN' } });
|
|
911
|
+
panel = renderPanel();
|
|
912
|
+
check(buttonOf('保存并连接')?.props.disabled === false, 'I 填上令牌后按钮可点(已保存的站点 / 邮箱不必重填)');
|
|
913
|
+
activeFailure.current = null;
|
|
914
|
+
const postsBefore = credentialState.posts.length;
|
|
915
|
+
const commandsBeforeConnect = calls.length;
|
|
916
|
+
buttonOf('保存并连接').props.onClick();
|
|
917
|
+
// 保存是异步的(POST → 成功 → 才触发列表重拉):先等 POST 回来,再等命令跑完。
|
|
918
|
+
await flush(80);
|
|
919
|
+
await settle();
|
|
920
|
+
panel = renderPanel();
|
|
921
|
+
const posted = credentialState.posts[postsBefore];
|
|
922
|
+
console.log('I 提交的连接信息:', JSON.stringify({ ...posted, token: posted?.token ? `${posted.token.slice(0, 6)}…` : undefined }));
|
|
923
|
+
check(
|
|
924
|
+
posted?.token === 'ATATT3xFfGF0TOKENTOKENTOKEN' && posted?.email === undefined && posted?.baseUrl === undefined,
|
|
925
|
+
'I POST 只带改过的令牌(已保存的站点 / 邮箱留空沿用)',
|
|
926
|
+
JSON.stringify({ ...posted, token: posted?.token ? '***' : undefined }),
|
|
927
|
+
);
|
|
928
|
+
check(
|
|
929
|
+
calls.length > commandsBeforeConnect && rows(panel).length === FIXTURE.items.length && !connectTitle(),
|
|
930
|
+
'I 保存成功后自动重拉列表(表单消失、任务行回来)',
|
|
931
|
+
`rows=${rows(panel).length} commands=${calls.length - commandsBeforeConnect}`,
|
|
932
|
+
);
|
|
933
|
+
|
|
934
|
+
/* 场景 3:首次什么都还没配(no_base_url / no_email)→ 同样是表单,不是失败提示。 */
|
|
935
|
+
credentialState.configured = false;
|
|
936
|
+
credentialState.baseUrl = '';
|
|
937
|
+
credentialState.email = '';
|
|
938
|
+
for (const code of ['no_base_url', 'no_email']) {
|
|
939
|
+
activeFailure.current = { code, message: `setup needed: ${code}` };
|
|
940
|
+
resetConnectForm();
|
|
941
|
+
refreshBtn().props.onClick();
|
|
942
|
+
await settle();
|
|
943
|
+
panel = renderPanel();
|
|
944
|
+
await flush();
|
|
945
|
+
panel = renderPanel();
|
|
946
|
+
check(
|
|
947
|
+
connectTitle() === '连接 Jira' && failTitle() === '' && failDetails().length === 0
|
|
948
|
+
&& connectInput('base-url').props.value === '' && connectInput('email').props.value === '',
|
|
949
|
+
`I ${code} → 同一张连接表单(站点 / 邮箱都空着,等用户填)`,
|
|
950
|
+
`${code}: ${connectTitle()} / failure=${failTitle()}`,
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/* 场景 4:凭据存在但被拒(auth)→ 仍是失败提示 + 详情;「重试」能回到列表。 */
|
|
843
955
|
activeFailure.current = { code: 'auth', message: 'Jira 401 Unauthorized (/rest/api/3/search/jql):Check your email and API token' };
|
|
956
|
+
resetConnectForm();
|
|
844
957
|
refreshBtn().props.onClick();
|
|
845
958
|
await settle();
|
|
846
959
|
panel = renderPanel();
|
|
847
960
|
console.log('I 401:标题 =', JSON.stringify(failTitle()), '| 详情小字 =', JSON.stringify(text(failDetails()[0]).trim().slice(0, 40)));
|
|
848
961
|
check(
|
|
849
|
-
failTitle() === 'Jira 不认这组邮箱 / 令牌' && failDetails().length === 1 && text(failDetails()[0]).includes('401')
|
|
850
|
-
|
|
962
|
+
failTitle() === 'Jira 不认这组邮箱 / 令牌' && failDetails().length === 1 && text(failDetails()[0]).includes('401')
|
|
963
|
+
&& !connectTitle(),
|
|
964
|
+
'I 401 → 不换成表单(凭据已配,是被拒);原始信息收在详情里',
|
|
851
965
|
failTitle(),
|
|
852
966
|
);
|
|
853
967
|
const retryBtn = collect(panel, (row) => isActionBtn(row) && text(row).trim() === '重试')[0];
|