dsh-delete-session 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +11 -0
- package/cordis.patch.yml +7 -7
- package/package.json +1 -1
- package/src/client.js +217 -25
- package/src/index.js +2168 -2037
- package/test/artifacts.host.test.js +165 -3
- package/test/checkbox.dom.test.js +289 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 DDDMUC
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DDDMUC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -72,6 +72,8 @@ dsh plugin --profile web add github:DDDMUC/dsh-delete-session
|
|
|
72
72
|
| **同时删除子会话** | **关** | 开:删对话时把它派生的子代理会话一起删掉。关:弹窗列出子会话,由你勾选 |
|
|
73
73
|
| 隔离夹保存位置 | 空(= `$DSH_HOME`) | 可手输、可点「选择文件夹…」调系统对话框、可点「打开」在资源管理器里定位 |
|
|
74
74
|
|
|
75
|
+
产出文件的每一行右侧有两个按钮:**打开所在文件夹**(在资源管理器里定位)和**删除这个文件**(去向跟随「删除至回收站」开关,开则进回收站,关则直接删除)。删除只对本次扫描列出的路径有效,请求里写别的路径会被宿主拒绝。
|
|
76
|
+
|
|
75
77
|
> 「选择文件夹…」用的是宿主自己的 `ctx.directoryPicker`:本地桌面弹系统对话框,远程/浏览式宿主自动退回页面内的目录列表。插件不再自带任何自绘或自编译的选择器。
|
|
76
78
|
|
|
77
79
|
### 删除之后文件在哪
|
|
@@ -158,6 +160,15 @@ MIT
|
|
|
158
160
|
|
|
159
161
|
---
|
|
160
162
|
|
|
163
|
+
## 修复记录
|
|
164
|
+
|
|
165
|
+
**(v0.2.6)** —— 会话 id 校验放宽 + 空会话按空状态处理。
|
|
166
|
+
|
|
167
|
+
- **会话 id 不再只认 UUID**:命名会话(例如 `bili-whale`,`~/.dsh/storages/<profile>/sessions/bili-whale.json`)是完全合法的会话,但这里的校验只接受 UUID 形式,于是对它的每个请求都被 400 拒掉 —— 面板上就是「状态加载失败,稍后重试。」。现在按 DSH 自己的语法(宿主侧 schema 就是 `z.string().min(1)`)放宽为 `/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/`,仍然挡住 `/`、`\`、`..`、空白与控制字符。
|
|
168
|
+
- **查不到会话按空状态处理**:没有日志的会话(刚建的命名会话)返回空状态而不是 404 —— 面板正常加载、显示"没有可操作的内容",日志一出现下一次刷新就接上。
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
161
172
|
## English
|
|
162
173
|
|
|
163
174
|
### Why you need it
|
package/cordis.patch.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# dsh-delete-session bundle patch: inserts the plugin row into the profile
|
|
2
|
-
# roster. The node half serves the /dsh-delete-session/* JSON routes; the
|
|
3
|
-
# browser half (exports "./client") injects the sidebar session-row menu item
|
|
4
|
-
# and the confirmation dialog.
|
|
5
|
-
- insert:
|
|
6
|
-
- id: dsh-delete-session
|
|
7
|
-
name: 'dsh-delete-session'
|
|
1
|
+
# dsh-delete-session bundle patch: inserts the plugin row into the profile
|
|
2
|
+
# roster. The node half serves the /dsh-delete-session/* JSON routes; the
|
|
3
|
+
# browser half (exports "./client") injects the sidebar session-row menu item
|
|
4
|
+
# and the confirmation dialog.
|
|
5
|
+
- insert:
|
|
6
|
+
- id: dsh-delete-session
|
|
7
|
+
name: 'dsh-delete-session'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-delete-session",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Delete sessions from the DSH Web sidebar: adds a Delete action to the session row menu with a risk-consent dialog, sends the session log, workspace accounting and live session state to the system trash (or removes them outright), and, when opted in, quarantines the files the conversation produced.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/client.js
CHANGED
|
@@ -113,6 +113,12 @@ window.__ModuleLoader__.load({
|
|
|
113
113
|
pickerDefault: (path) => `默认路径:${path}`,
|
|
114
114
|
rootSet: '保存位置已更新',
|
|
115
115
|
artifactSection: '本对话产出的文件',
|
|
116
|
+
artifactOpenFolder: '打开所在文件夹',
|
|
117
|
+
artifactDeleteFile: '删除这个文件',
|
|
118
|
+
fileDeleted: '文件已删除',
|
|
119
|
+
fileRecycled: '文件已移入回收站',
|
|
120
|
+
fileDeleteFailed: '删除文件失败:',
|
|
121
|
+
revealFailed: '打开文件夹失败:',
|
|
116
122
|
artifactLoading: '正在扫描…',
|
|
117
123
|
artifactFailed: '扫描失败:',
|
|
118
124
|
artifactNone: '没有需要处理的文件。',
|
|
@@ -209,6 +215,12 @@ window.__ModuleLoader__.load({
|
|
|
209
215
|
pickerDefault: (path) => `Default path: ${path}`,
|
|
210
216
|
rootSet: 'Location updated',
|
|
211
217
|
artifactSection: 'Files this conversation produced',
|
|
218
|
+
artifactOpenFolder: 'Open containing folder',
|
|
219
|
+
artifactDeleteFile: 'Delete this file',
|
|
220
|
+
fileDeleted: 'File deleted',
|
|
221
|
+
fileRecycled: 'File moved to the recycle bin',
|
|
222
|
+
fileDeleteFailed: 'Could not delete the file: ',
|
|
223
|
+
revealFailed: 'Could not open the folder: ',
|
|
212
224
|
artifactLoading: 'Scanning...',
|
|
213
225
|
artifactFailed: 'Scan failed: ',
|
|
214
226
|
artifactNone: 'Nothing to handle.',
|
|
@@ -593,6 +605,65 @@ window.__ModuleLoader__.load({
|
|
|
593
605
|
})
|
|
594
606
|
}
|
|
595
607
|
|
|
608
|
+
/** Drop one row from the dialog after its file left the disk. */
|
|
609
|
+
function forgetFile(sessionId, target) {
|
|
610
|
+
const dialog = state.dialog
|
|
611
|
+
if (dialog === null || dialog.sessionId !== sessionId) return
|
|
612
|
+
const artifacts = dialog.artifacts
|
|
613
|
+
if (artifacts === null || artifacts.plan === null) return
|
|
614
|
+
artifacts.selected.delete(target)
|
|
615
|
+
const keep = (row) => row.path !== target
|
|
616
|
+
artifacts.plan = {
|
|
617
|
+
...artifacts.plan,
|
|
618
|
+
created: (artifacts.plan.created || []).filter(keep),
|
|
619
|
+
modified: (artifacts.plan.modified || []).filter(keep),
|
|
620
|
+
}
|
|
621
|
+
publish()
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/** Delete one produced file, then drop its row. */
|
|
625
|
+
function deleteOneFile(sessionId, target) {
|
|
626
|
+
const recycle = recycleSession()
|
|
627
|
+
postDeleteFile(sessionId, target, recycle).then((data) => {
|
|
628
|
+
forgetFile(sessionId, target)
|
|
629
|
+
toast(t(data && data.recycled === true ? 'fileRecycled' : 'fileDeleted'))
|
|
630
|
+
}).catch((reason) => {
|
|
631
|
+
toast(t('fileDeleteFailed') + String((reason && reason.message) || reason), true)
|
|
632
|
+
})
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Delete one produced file. The recycle choice is the same preference that
|
|
637
|
+
* governs a conversation delete, so the two never disagree.
|
|
638
|
+
*/
|
|
639
|
+
function postDeleteFile(sessionId, target, recycle) {
|
|
640
|
+
return fetch('/dsh-delete-session/delete-file', {
|
|
641
|
+
method: 'POST',
|
|
642
|
+
headers: { 'content-type': 'application/json' },
|
|
643
|
+
body: JSON.stringify({ sessionId, path: target, recycle }),
|
|
644
|
+
}).then(async (res) => {
|
|
645
|
+
let data = {}
|
|
646
|
+
try { data = await res.json() } catch { /* keep {} */ }
|
|
647
|
+
if (!res.ok || !data.ok) throw new Error((data && data.error) || `HTTP ${res.status}`)
|
|
648
|
+
return data
|
|
649
|
+
})
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Show one produced file's folder. The host validates that the path is a
|
|
654
|
+
* directory; the browser has no path module, so the parent is taken with a
|
|
655
|
+
* plain last-separator split — Windows separators included.
|
|
656
|
+
*/
|
|
657
|
+
function revealParent(filePath) {
|
|
658
|
+
const text = String(filePath === null || filePath === undefined ? '' : filePath).replace(/[\\/]+$/, '')
|
|
659
|
+
const cut = Math.max(text.lastIndexOf('/'), text.lastIndexOf('\\'))
|
|
660
|
+
const parent = cut > 0 ? text.slice(0, cut) : text
|
|
661
|
+
if (parent === '') return
|
|
662
|
+
postReveal(parent).catch((reason) => {
|
|
663
|
+
toast(t('revealFailed') + String((reason && reason.message) || reason), true)
|
|
664
|
+
})
|
|
665
|
+
}
|
|
666
|
+
|
|
596
667
|
/** Show the quarantine folder the current settings would write to. */
|
|
597
668
|
function openQuarantineRoot(target) {
|
|
598
669
|
if (typeof target !== 'string' || target === '') return
|
|
@@ -686,7 +757,9 @@ window.__ModuleLoader__.load({
|
|
|
686
757
|
// host's `Modal`, so it brings no backdrop CSS of its own.
|
|
687
758
|
|
|
688
759
|
const CSS = [
|
|
689
|
-
'.dsdel-toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);z-index:2147483601;background:
|
|
760
|
+
'.dsdel-toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);z-index:2147483601;background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-1,#2b2b2b));color:var(--dsw-alias-label-primary,#fff);border:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.3));padding:9px 16px;border-radius:10px;font-size:12.5px;line-height:18px;box-shadow:0 10px 28px rgba(0,0,0,.24);max-width:min(92vw,460px);cursor:pointer;animation:dsdel-toast-in .16s cubic-bezier(.2,.8,.3,1)}',
|
|
761
|
+
'@keyframes dsdel-toast-in{from{opacity:0;transform:translate(-50%,6px)}to{opacity:1;transform:translate(-50%,0)}}',
|
|
762
|
+
'@media (prefers-reduced-motion:reduce){.dsdel-toast{animation:none}.dsdel-field{transition:none}}',
|
|
690
763
|
'.dsdel-check{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;border:1.5px solid var(--dsw-alias-border-l3,rgba(128,128,128,.5));background:transparent;flex:none;margin-right:8px;box-sizing:border-box;cursor:pointer}',
|
|
691
764
|
'.dsdel-check-on{background:var(--dsw-alias-state-business-primary,#4c6ef5);border-color:var(--dsw-alias-state-business-primary,#4c6ef5)}',
|
|
692
765
|
'.dsdel-check-on::after{content:"";width:9px;height:5px;border-left:2px solid #fff;border-bottom:2px solid #fff;transform:rotate(-45deg) translateY(-1px)}',
|
|
@@ -709,10 +782,32 @@ window.__ModuleLoader__.load({
|
|
|
709
782
|
'.dsdel-drop-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
710
783
|
'.dsdel-bar-count{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dsw-alias-label-secondary,inherit)}',
|
|
711
784
|
'.dsdel-bar-btn{flex:0 0 auto;white-space:nowrap;appearance:none;min-height:30px;padding:0 12px;border:1px solid var(--dsw-alias-border-l2,rgba(128,128,128,.4));background:var(--dsw-alias-fill-elevated,rgba(128,128,128,.08));color:var(--dsw-alias-label-primary,inherit);border-radius:8px;font-size:13px;cursor:pointer}',
|
|
785
|
+
'.dsdel-bar-btn:focus-visible{outline:2px solid var(--dsdel-ring);outline-offset:1px}',
|
|
712
786
|
'.dsdel-bar-btn:disabled{opacity:.5;cursor:default}',
|
|
713
787
|
'.dsdel-bar-danger{border-color:var(--dsw-alias-state-error-primary,#e5484d);background:var(--dsw-alias-state-error-primary,#e5484d);color:#fff}',
|
|
788
|
+
// One token layer for every surface this plugin draws. Everything below
|
|
789
|
+
// reads these rather than repeating a fallback per rule: the host theme then
|
|
790
|
+
// reaches the whole plugin through one block, which is the point of exposing
|
|
791
|
+
// tokens at all.
|
|
792
|
+
'.dsdel-page,.dsdel-modal,.dsdel-bar{--dsdel-bg:var(--dsw-alias-fill-elevated,rgba(127,127,127,.06));--dsdel-bg-hover:var(--dsw-alias-fill-hover,rgba(127,127,127,.10));--dsdel-border:var(--dsw-alias-border-l2,rgba(127,127,127,.28));--dsdel-label:var(--dsw-alias-label-primary,inherit);--dsdel-label-dim:var(--dsw-alias-label-secondary,#666);--dsdel-label-faint:var(--dsw-alias-label-tertiary,#888);--dsdel-danger:var(--dsw-alias-state-error-primary,#e5484d);--dsdel-radius:10px;--dsdel-radius-sm:8px;--dsdel-ring:color-mix(in srgb,var(--dsw-alias-brand-primary,#4c8dff) 45%,transparent);--dsdel-shadow:0 1px 2px rgba(0,0,0,.04)}',
|
|
714
793
|
'.dsdel-page{display:flex;flex-direction:column;gap:8px}',
|
|
715
|
-
|
|
794
|
+
// Each switch and its explanation read as one block, so a card with eight
|
|
795
|
+
// controls stops looking like one long column of tick boxes.
|
|
796
|
+
'.dsdel-field{display:flex;flex-direction:column;gap:2px;padding:10px 12px;border:1px solid var(--dsdel-border);border-radius:var(--dsdel-radius);background:var(--dsdel-bg);box-shadow:var(--dsdel-shadow);transition:background .12s ease,border-color .12s ease}',
|
|
797
|
+
'.dsdel-field:hover{background:var(--dsdel-bg-hover)}',
|
|
798
|
+
'.dsdel-field:focus-within{outline:2px solid var(--dsdel-ring);outline-offset:1px}',
|
|
799
|
+
'.dsdel-page-hint{margin:0;color:var(--dsdel-label-faint);font-size:12.5px;line-height:19px;letter-spacing:.01em}',
|
|
800
|
+
// One produced file per row: tick on the left, path in the middle, a folder
|
|
801
|
+
// button on the right. The button sits outside the label so a click opens
|
|
802
|
+
// the folder instead of toggling the tick.
|
|
803
|
+
'.dsdel-file-row{display:flex;align-items:center;gap:8px;padding:4px 6px;border-radius:var(--dsdel-radius-sm);transition:background .12s ease}',
|
|
804
|
+
'.dsdel-file-row:hover{background:var(--dsdel-bg-hover)}',
|
|
805
|
+
'.dsdel-file-label{display:flex;align-items:center;gap:8px;flex:1;min-width:0;cursor:pointer}',
|
|
806
|
+
'.dsdel-file-path{flex:1;min-width:0;word-break:break-all;font-size:13px;line-height:20px;color:var(--dsdel-label)}',
|
|
807
|
+
'.dsdel-file-open{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;width:26px;height:26px;padding:0;border:1px solid transparent;border-radius:var(--dsdel-radius-sm);background:transparent;color:var(--dsdel-label-dim);cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}',
|
|
808
|
+
'.dsdel-file-open:hover{background:var(--dsdel-bg);border-color:var(--dsdel-border);color:var(--dsdel-label)}',
|
|
809
|
+
'.dsdel-file-open:focus-visible{outline:2px solid var(--dsdel-ring);outline-offset:1px}',
|
|
810
|
+
'.dsdel-file-remove:hover{background:color-mix(in srgb,var(--dsdel-danger) 12%,transparent);border-color:color-mix(in srgb,var(--dsdel-danger) 40%,transparent);color:var(--dsdel-danger)}',
|
|
716
811
|
'.dsdel-star{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap;font-size:12px;color:var(--dsw-alias-label-tertiary,#8b93a1);padding:2px 2px 0;}',
|
|
717
812
|
'.dsdel-star-link{color:var(--dsw-alias-brand-primary,#4d76e6);text-decoration:underline;}',
|
|
718
813
|
'.dsdel-root-input{flex:1 1 220px;min-width:160px;min-height:30px;padding:0 10px;border:1px solid var(--dsw-alias-border-secondary,#d0d0d0);border-radius:6px;background:transparent;color:inherit;font:inherit;font-size:13px}',
|
|
@@ -720,8 +815,11 @@ window.__ModuleLoader__.load({
|
|
|
720
815
|
// A wider confirmation dialog: the class reaches it when `Modal` forwards
|
|
721
816
|
// `className`, and the `:has()` rule catches the host-owned container when
|
|
722
817
|
// it does not. Both are harmless if the other one is the one that applies.
|
|
723
|
-
'.dsdel-dialog-wide{width:min(
|
|
724
|
-
'
|
|
818
|
+
'.dsdel-dialog-wide{width:min(46vw,860px)!important;max-width:min(46vw,860px)!important;min-height:min(240px,88vh)!important;max-height:88vh!important;display:flex;flex-direction:column;overflow:hidden}',
|
|
819
|
+
'.dsdel-dialog-wide > :first-child{flex:1 1 auto;min-height:0;overflow:auto}',
|
|
820
|
+
'.dsdel-dialog-wide > :last-child{flex:0 0 auto;margin-top:auto}',
|
|
821
|
+
'.dsdel-artifacts{overflow:auto;overscroll-behavior:contain;padding-right:2px}',
|
|
822
|
+
'[role="dialog"]:has(.dsdel-file-row),[aria-modal="true"]:has(.dsdel-file-row){width:min(46vw,860px);max-width:min(46vw,860px);min-height:min(240px,88vh);max-height:88vh}',
|
|
725
823
|
'.dsdel-picker-list{display:flex;flex-direction:column;gap:2px;max-height:280px;overflow:auto;margin:0 0 8px}',
|
|
726
824
|
'.dsdel-picker-row{appearance:none;text-align:left;padding:6px 8px;border:0;border-radius:6px;background:transparent;color:inherit;font:inherit;font-size:13px;cursor:pointer}',
|
|
727
825
|
'.dsdel-picker-row:hover{background:var(--dsw-alias-fill-secondary,rgba(127,127,127,0.12))}',
|
|
@@ -1528,6 +1626,8 @@ window.__ModuleLoader__.load({
|
|
|
1528
1626
|
|
|
1529
1627
|
/** Inline glyphs for the two rows; the host exposes no matching pair. */
|
|
1530
1628
|
const TRASH_PATHS = ['M4 7h16', 'M10 11v6', 'M14 11v6', 'M6 7l1 13a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1l1-13', 'M9 7V4h6v3']
|
|
1629
|
+
/** A folder, for "show this file where it lives". */
|
|
1630
|
+
const FOLDER_PATHS = ['M3 6a1 1 0 0 1 1-1h4l2 2h8a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z']
|
|
1531
1631
|
const SELECT_PATHS = ['M5 7m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M5 17m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0', 'M11 7h9', 'M11 17h9']
|
|
1532
1632
|
|
|
1533
1633
|
function glyph(paths) {
|
|
@@ -1661,21 +1761,55 @@ window.__ModuleLoader__.load({
|
|
|
1661
1761
|
elements.push(h('p', { key: 'selected', className: 'dsdel-modal-meta' },
|
|
1662
1762
|
translate('artifactSelected', artifacts.selected.size)))
|
|
1663
1763
|
for (const row of rows.slice(0, ARTIFACT_ROWS_SHOWN)) {
|
|
1664
|
-
elements.push(h('
|
|
1764
|
+
elements.push(h('div', {
|
|
1665
1765
|
key: `row:${row.path}`,
|
|
1666
|
-
|
|
1667
|
-
|
|
1766
|
+
'data-file-row': row.path,
|
|
1767
|
+
className: 'dsdel-file-row',
|
|
1668
1768
|
},
|
|
1669
|
-
h('
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1769
|
+
h('label', {
|
|
1770
|
+
key: 'label',
|
|
1771
|
+
className: 'dsdel-file-label',
|
|
1772
|
+
},
|
|
1773
|
+
h('input', {
|
|
1774
|
+
type: 'checkbox',
|
|
1775
|
+
checked: artifacts.selected.has(row.path),
|
|
1776
|
+
onChange: (e) => {
|
|
1777
|
+
if (e && e.target && e.target.checked) artifacts.selected.add(row.path)
|
|
1778
|
+
else artifacts.selected.delete(row.path)
|
|
1779
|
+
publish()
|
|
1780
|
+
},
|
|
1781
|
+
}),
|
|
1782
|
+
h('span', { key: 'path', className: 'dsdel-file-path' }, row.displayPath || row.path),
|
|
1783
|
+
),
|
|
1784
|
+
// Delete just this file. Same destination rule as the conversation
|
|
1785
|
+
// switch: the system trash when recycling is on, gone when it is not.
|
|
1786
|
+
h('button', {
|
|
1787
|
+
key: 'remove',
|
|
1788
|
+
type: 'button',
|
|
1789
|
+
className: 'dsdel-file-open dsdel-file-remove',
|
|
1790
|
+
title: translate('artifactDeleteFile'),
|
|
1791
|
+
'aria-label': translate('artifactDeleteFile'),
|
|
1792
|
+
onClick: (event) => {
|
|
1793
|
+
if (event && typeof event.preventDefault === 'function') event.preventDefault()
|
|
1794
|
+
if (event && typeof event.stopPropagation === 'function') event.stopPropagation()
|
|
1795
|
+
deleteOneFile(state.dialog === null ? '' : state.dialog.sessionId, row.path)
|
|
1676
1796
|
},
|
|
1677
|
-
}),
|
|
1678
|
-
|
|
1797
|
+
}, glyph(TRASH_PATHS)),
|
|
1798
|
+
// One folder per row. What moves is the file, so the thing worth
|
|
1799
|
+
// looking at before deciding is where it lives. The button is a
|
|
1800
|
+
// SIBLING of the label: inside it, a click would toggle the tick box.
|
|
1801
|
+
h('button', {
|
|
1802
|
+
key: 'open',
|
|
1803
|
+
type: 'button',
|
|
1804
|
+
className: 'dsdel-file-open',
|
|
1805
|
+
title: translate('artifactOpenFolder'),
|
|
1806
|
+
'aria-label': translate('artifactOpenFolder'),
|
|
1807
|
+
onClick: (event) => {
|
|
1808
|
+
if (event && typeof event.preventDefault === 'function') event.preventDefault()
|
|
1809
|
+
if (event && typeof event.stopPropagation === 'function') event.stopPropagation()
|
|
1810
|
+
revealParent(row.path)
|
|
1811
|
+
},
|
|
1812
|
+
}, glyph(FOLDER_PATHS)),
|
|
1679
1813
|
))
|
|
1680
1814
|
}
|
|
1681
1815
|
if (rows.length > ARTIFACT_ROWS_SHOWN) {
|
|
@@ -1691,7 +1825,7 @@ window.__ModuleLoader__.load({
|
|
|
1691
1825
|
if (plan.truncated) {
|
|
1692
1826
|
elements.push(h('p', { key: 'truncated', className: 'dsdel-modal-meta' }, translate('artifactTruncated')))
|
|
1693
1827
|
}
|
|
1694
|
-
return h('div', { key: 'artifacts' }, elements)
|
|
1828
|
+
return h('div', { key: 'artifacts', className: 'dsdel-artifacts' }, elements)
|
|
1695
1829
|
}
|
|
1696
1830
|
|
|
1697
1831
|
/** Folder picker overlay: walk directories, then commit one. */
|
|
@@ -1775,6 +1909,17 @@ window.__ModuleLoader__.load({
|
|
|
1775
1909
|
const dialog = view.dialog
|
|
1776
1910
|
if (dialog === null) return null
|
|
1777
1911
|
|
|
1912
|
+
// The file list sizes its own frame: a short list gets a short dialog, a
|
|
1913
|
+
// long one grows until the viewport cap and then scrolls. A forced ratio
|
|
1914
|
+
// cannot do that — it pins the height, so the empty band under two lines
|
|
1915
|
+
// of text simply moves around.
|
|
1916
|
+
const plan = dialog.artifacts !== null && dialog.artifacts !== undefined
|
|
1917
|
+
? dialog.artifacts.plan
|
|
1918
|
+
: null
|
|
1919
|
+
const listed = plan === null || plan === undefined
|
|
1920
|
+
? 0
|
|
1921
|
+
: (plan.created || []).length + (plan.modified || []).length
|
|
1922
|
+
const needsFrame = listed > 0 && dialog.artifacts.auto !== true
|
|
1778
1923
|
const footer = h(
|
|
1779
1924
|
Fragment,
|
|
1780
1925
|
null,
|
|
@@ -1795,12 +1940,20 @@ window.__ModuleLoader__.load({
|
|
|
1795
1940
|
|
|
1796
1941
|
return h(primitives.Modal, {
|
|
1797
1942
|
open: true,
|
|
1798
|
-
//
|
|
1799
|
-
// `
|
|
1800
|
-
//
|
|
1801
|
-
//
|
|
1802
|
-
|
|
1803
|
-
|
|
1943
|
+
// `Modal` documents no width prop, so the class, the inline style and the
|
|
1944
|
+
// `:has()` rule in the stylesheet all try; whichever the host honours wins.
|
|
1945
|
+
// 9:16: the file list reads as a column, so the shell is a phone-shaped
|
|
1946
|
+
// card. Width is derived from the height budget (94vh tall at most), which
|
|
1947
|
+
// keeps the ratio on every window size; the list scrolls inside it.
|
|
1948
|
+
...(needsFrame ? { className: 'dsdel-dialog-wide' } : {}),
|
|
1949
|
+
...(needsFrame ? {
|
|
1950
|
+
style: {
|
|
1951
|
+
width: 'min(46vw, 860px)',
|
|
1952
|
+
maxWidth: 'min(46vw, 860px)',
|
|
1953
|
+
minHeight: 'min(240px, 88vh)',
|
|
1954
|
+
maxHeight: '88vh',
|
|
1955
|
+
},
|
|
1956
|
+
} : {}),
|
|
1804
1957
|
onClose: () => closeDeleteDialog(),
|
|
1805
1958
|
closeLabel: translate('cancel'),
|
|
1806
1959
|
title: translate('title'),
|
|
@@ -2041,7 +2194,36 @@ window.__ModuleLoader__.load({
|
|
|
2041
2194
|
rel: 'noreferrer',
|
|
2042
2195
|
}, translate('starCta'))))
|
|
2043
2196
|
|
|
2044
|
-
|
|
2197
|
+
// Each control owns the nodes that explain it. Grouping them here keeps the
|
|
2198
|
+
// markup above flat (a switch and its hint are still two pushes) while the
|
|
2199
|
+
// page draws them as one block.
|
|
2200
|
+
const FIELD_KEYS = new Set(['ask', 'recycle', 'syncChildren', 'off', 'auto', 'scope', 'skipGit', 'root'])
|
|
2201
|
+
function groupFields(nodes) {
|
|
2202
|
+
const groups = []
|
|
2203
|
+
let current = null
|
|
2204
|
+
for (const node of nodes) {
|
|
2205
|
+
const key = node !== null && node !== undefined && node.props ? node.props.key : undefined
|
|
2206
|
+
if (FIELD_KEYS.has(key)) {
|
|
2207
|
+
current = { control: key, nodes: [node] }
|
|
2208
|
+
groups.push(current)
|
|
2209
|
+
continue
|
|
2210
|
+
}
|
|
2211
|
+
// The hint of a control is keyed `<control>Hint`; the root row keeps its
|
|
2212
|
+
// input, buttons and hint under the same prefix.
|
|
2213
|
+
if (current !== null && typeof key === 'string' && key !== 'star' && key !== 'cta'
|
|
2214
|
+
&& key.startsWith(current.control)) {
|
|
2215
|
+
current.nodes.push(node)
|
|
2216
|
+
continue
|
|
2217
|
+
}
|
|
2218
|
+
current = null
|
|
2219
|
+
groups.push({ control: null, nodes: [node] })
|
|
2220
|
+
}
|
|
2221
|
+
return groups.map((group, index) => (group.control === null
|
|
2222
|
+
? group.nodes[0]
|
|
2223
|
+
: h('div', { key: `field:${group.control}`, className: 'dsdel-field' }, ...group.nodes)))
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
return h('div', { className: 'dsdel-page' }, groupFields(children))
|
|
2045
2227
|
}
|
|
2046
2228
|
|
|
2047
2229
|
// --- plugin ------------------------------------------------------------------
|
|
@@ -2118,7 +2300,17 @@ window.__ModuleLoader__.load({
|
|
|
2118
2300
|
{ name: 'shell.overlay', id: `${NS}-picker`, order: 1, locale: NS },
|
|
2119
2301
|
QuarantinePicker,
|
|
2120
2302
|
))
|
|
2121
|
-
// The plugin page card.
|
|
2303
|
+
// The plugin page card, on BOTH seats the manager offers.
|
|
2304
|
+
//
|
|
2305
|
+
// `plugins.bundle.config` renders on the package page, whose address is
|
|
2306
|
+
// `#/panel/plugins/<package>`. `plugins.row.config` renders on the row's
|
|
2307
|
+
// own page, `#/panel/plugins/<package>/<rowId>` — and this bundle's row id
|
|
2308
|
+
// is the package name, so that address repeated itself. The row seat keeps
|
|
2309
|
+
// only its `summary` face, which is the one line the rows list shows.
|
|
2310
|
+
slots.inject('plugins.bundle.config', () => slots.register(
|
|
2311
|
+
{ name: 'plugins.bundle.config', key: NS },
|
|
2312
|
+
AskBeforeDeleteOption,
|
|
2313
|
+
))
|
|
2122
2314
|
slots.inject('plugins.row.config', () => slots.register(
|
|
2123
2315
|
{ name: 'plugins.row.config', key: `${NS}#${NS}` },
|
|
2124
2316
|
AskBeforeDeleteOption,
|