@electerm/electerm-react 2.3.176 → 2.3.181
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import StartSessionSelect from '../setting-panel/start-session-select'
|
|
2
1
|
import {
|
|
3
2
|
Tree,
|
|
4
3
|
Button,
|
|
@@ -6,67 +5,126 @@ import {
|
|
|
6
5
|
} from 'antd'
|
|
7
6
|
import { defaultBookmarkGroupId, settingMap } from '../../common/constants'
|
|
8
7
|
import deepCopy from 'json-deep-copy'
|
|
8
|
+
import { createTitleWithTag } from '../../common/create-title'
|
|
9
9
|
|
|
10
10
|
const e = window.translate
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
function buildData (bookmarks, bookmarkGroups) {
|
|
13
|
+
const cats = bookmarkGroups
|
|
14
|
+
const tree = bookmarks
|
|
15
|
+
.reduce((p, k) => {
|
|
16
|
+
return {
|
|
17
|
+
...p,
|
|
18
|
+
[k.id]: k
|
|
19
|
+
}
|
|
20
|
+
}, {})
|
|
21
|
+
const btree = cats
|
|
22
|
+
.reduce((p, k) => {
|
|
23
|
+
return {
|
|
24
|
+
...p,
|
|
25
|
+
[k.id]: k
|
|
26
|
+
}
|
|
27
|
+
}, {})
|
|
28
|
+
function buildSubCats (id) {
|
|
29
|
+
const x = btree[id]
|
|
30
|
+
if (!x) {
|
|
31
|
+
return ''
|
|
32
|
+
}
|
|
33
|
+
const y = {
|
|
34
|
+
key: x.id,
|
|
35
|
+
value: x.id,
|
|
36
|
+
title: x.title
|
|
37
|
+
}
|
|
38
|
+
y.children = [
|
|
39
|
+
...(x.bookmarkGroupIds || []).map(buildSubCats),
|
|
40
|
+
...(x.bookmarkIds || []).map(buildLeaf)
|
|
41
|
+
].filter(d => d)
|
|
42
|
+
if (y.children && !y.children.length) {
|
|
43
|
+
delete y.children
|
|
44
|
+
}
|
|
45
|
+
return y
|
|
46
|
+
}
|
|
47
|
+
function buildLeaf (id) {
|
|
48
|
+
const x = tree[id]
|
|
49
|
+
if (!x) {
|
|
50
|
+
return ''
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
value: x.id,
|
|
54
|
+
key: x.id,
|
|
55
|
+
title: createTitleWithTag(x)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const level1 = cats.filter(d => d.level !== 2)
|
|
59
|
+
.map(d => {
|
|
60
|
+
const r = {
|
|
61
|
+
title: d.title,
|
|
62
|
+
value: d.id,
|
|
63
|
+
key: d.id,
|
|
64
|
+
children: [
|
|
65
|
+
...(d.bookmarkGroupIds || []).map(buildSubCats),
|
|
66
|
+
...(d.bookmarkIds || []).map(buildLeaf)
|
|
67
|
+
].filter(d => d)
|
|
68
|
+
}
|
|
69
|
+
return r
|
|
70
|
+
}).filter(d => d)
|
|
71
|
+
return level1
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default function BookmarkTreeDelete (props) {
|
|
75
|
+
const { expandedKeys, checkedKeys, bookmarks, bookmarkGroups } = props
|
|
76
|
+
|
|
77
|
+
const onExpand = (expandedKeys) => {
|
|
14
78
|
window.store.expandedKeys = deepCopy(expandedKeys)
|
|
15
79
|
}
|
|
16
80
|
|
|
17
|
-
onCheck = (checkedKeys) => {
|
|
81
|
+
const onCheck = (checkedKeys) => {
|
|
18
82
|
window.store.checkedKeys = deepCopy(checkedKeys)
|
|
19
83
|
}
|
|
20
84
|
|
|
21
|
-
handleDel = () => {
|
|
85
|
+
const handleDel = () => {
|
|
22
86
|
const { store } = window
|
|
23
|
-
const {
|
|
24
|
-
checkedKeys
|
|
25
|
-
} = this.props
|
|
26
87
|
const arr = checkedKeys.filter(d => d !== defaultBookmarkGroupId)
|
|
27
88
|
store.delItems(arr, settingMap.bookmarks)
|
|
28
89
|
store.delItems(arr, settingMap.bookmarkGroups)
|
|
29
90
|
store.checkedKeys = []
|
|
30
91
|
}
|
|
31
92
|
|
|
32
|
-
handleCancel = () => {
|
|
93
|
+
const handleCancel = () => {
|
|
33
94
|
const { store } = window
|
|
34
95
|
store.bookmarkSelectMode = false
|
|
35
96
|
store.checkedKeys = []
|
|
36
97
|
}
|
|
37
98
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
onExpand: this.onExpand,
|
|
47
|
-
treeData: this.buildData()
|
|
48
|
-
}
|
|
49
|
-
const len = checkedKeys.length
|
|
50
|
-
return (
|
|
51
|
-
<div>
|
|
52
|
-
<div className='pd2'>
|
|
53
|
-
<Space.Compact>
|
|
54
|
-
<Button
|
|
55
|
-
type='primary'
|
|
56
|
-
disabled={!len}
|
|
57
|
-
onClick={this.handleDel}
|
|
58
|
-
>
|
|
59
|
-
{e('delSelected')} ({len})
|
|
60
|
-
</Button>
|
|
61
|
-
<Button
|
|
62
|
-
onClick={this.handleCancel}
|
|
63
|
-
>
|
|
64
|
-
{e('cancel')}
|
|
65
|
-
</Button>
|
|
66
|
-
</Space.Compact>
|
|
67
|
-
<Tree {...rProps} />
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
70
|
-
)
|
|
99
|
+
const rProps = {
|
|
100
|
+
checkable: true,
|
|
101
|
+
autoExpandParent: true,
|
|
102
|
+
onCheck,
|
|
103
|
+
expandedKeys,
|
|
104
|
+
checkedKeys,
|
|
105
|
+
onExpand,
|
|
106
|
+
treeData: buildData(bookmarks, bookmarkGroups)
|
|
71
107
|
}
|
|
108
|
+
const len = checkedKeys.length
|
|
109
|
+
return (
|
|
110
|
+
<div>
|
|
111
|
+
<div className='pd2'>
|
|
112
|
+
<Space.Compact>
|
|
113
|
+
<Button
|
|
114
|
+
type='primary'
|
|
115
|
+
disabled={!len}
|
|
116
|
+
onClick={handleDel}
|
|
117
|
+
>
|
|
118
|
+
{e('delSelected')} ({len})
|
|
119
|
+
</Button>
|
|
120
|
+
<Button
|
|
121
|
+
onClick={handleCancel}
|
|
122
|
+
>
|
|
123
|
+
{e('cancel')}
|
|
124
|
+
</Button>
|
|
125
|
+
</Space.Compact>
|
|
126
|
+
<Tree {...rProps} />
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
)
|
|
72
130
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import { Form, Input, InputNumber, Switch, Select, Button, Tooltip } from 'antd'
|
|
6
6
|
import { formItemLayout, tailFormItemLayout } from '../../common/form-layout'
|
|
7
|
+
import HelpIcon from '../common/help-icon'
|
|
7
8
|
|
|
8
9
|
export default function WidgetForm ({ widget, onSubmit, loading, hasRunningInstance }) {
|
|
9
10
|
const [form] = Form.useForm()
|
|
@@ -83,7 +84,12 @@ export default function WidgetForm ({ widget, onSubmit, loading, hasRunningInsta
|
|
|
83
84
|
return (
|
|
84
85
|
<div className='widget-form'>
|
|
85
86
|
<div className='pd1b alignright'>
|
|
86
|
-
<h4>
|
|
87
|
+
<h4>
|
|
88
|
+
{info.name}
|
|
89
|
+
{info.name === 'MCP Server' && (
|
|
90
|
+
<HelpIcon link='https://github.com/electerm/electerm/wiki/MCP-Widget-Usage-Guide' />
|
|
91
|
+
)}
|
|
92
|
+
</h4>
|
|
87
93
|
<p>{info.description}</p>
|
|
88
94
|
</div>
|
|
89
95
|
<Form
|