@electerm/electerm-react 1.39.35 → 1.39.47
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/client/components/bookmark-form/bookmark-group-tree-format.js +25 -24
- package/client/components/bookmark-form/form-ssh-common.jsx +10 -0
- package/client/components/bookmark-form/render-connection-hopping.jsx +21 -20
- package/client/components/bookmark-form/render-ssh-tunnel.jsx +4 -3
- package/client/components/bookmark-form/ssh-form.jsx +2 -1
- package/client/components/bookmark-form/vnc-form-ui.jsx +42 -3
- package/client/components/main/main.jsx +1 -1
- package/client/components/profile/profile-form-elem.jsx +0 -1
- package/client/components/quick-commands/quick-command-transport-mod.jsx +1 -1
- package/client/components/setting-panel/bookmark-tree-list.jsx +1 -1
- package/client/components/setting-panel/list.styl +3 -0
- package/client/components/setting-panel/start-session-select.jsx +4 -3
- package/client/components/sftp/file-item.jsx +3 -3
- package/client/components/sidebar/bookmark-select.jsx +1 -1
- package/client/components/tabs/index.jsx +1 -1
- package/client/components/tabs/tabs.styl +2 -2
- package/client/components/terminal/index.jsx +3 -2
- package/client/components/terminal-theme/theme-list.jsx +2 -2
- package/client/components/tree-list/tree-expander.jsx +36 -0
- package/client/components/tree-list/tree-list-item.jsx +262 -0
- package/client/components/{setting-panel → tree-list}/tree-list.jsx +397 -324
- package/client/components/{setting-panel → tree-list}/tree-list.styl +26 -6
- package/client/store/common.js +15 -1
- package/client/store/index.js +24 -0
- package/package.json +1 -1
- /package/client/components/{setting-panel → tree-list}/bookmark-transport.jsx +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tree list for bookmarks
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
CloseOutlined,
|
|
7
|
+
CopyOutlined,
|
|
8
|
+
EditOutlined,
|
|
9
|
+
FolderAddOutlined,
|
|
10
|
+
FolderOpenOutlined,
|
|
11
|
+
SettingOutlined
|
|
12
|
+
} from '@ant-design/icons'
|
|
13
|
+
import {
|
|
14
|
+
Popconfirm,
|
|
15
|
+
Tooltip
|
|
16
|
+
} from 'antd'
|
|
17
|
+
import createName, { createTitleTag } from '../../common/create-title'
|
|
18
|
+
import classnames from 'classnames'
|
|
19
|
+
import {
|
|
20
|
+
defaultBookmarkGroupId
|
|
21
|
+
} from '../../common/constants'
|
|
22
|
+
import highlight from '../common/highlight'
|
|
23
|
+
import uid from '../../common/uid'
|
|
24
|
+
import { memo } from 'react'
|
|
25
|
+
import './tree-list.styl'
|
|
26
|
+
|
|
27
|
+
const { prefix } = window
|
|
28
|
+
const e = prefix('menu')
|
|
29
|
+
const c = prefix('common')
|
|
30
|
+
const s = prefix('setting')
|
|
31
|
+
|
|
32
|
+
export default memo(function TreeListItem (props) {
|
|
33
|
+
const handleDel = (e) => {
|
|
34
|
+
props.del(props.item, e)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const renderDelBtn = (item) => {
|
|
38
|
+
if (props.item.id === defaultBookmarkGroupId || props.staticList) {
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
return (
|
|
42
|
+
<Popconfirm
|
|
43
|
+
title={e('del') + '?'}
|
|
44
|
+
onConfirm={handleDel}
|
|
45
|
+
okText={e('del')}
|
|
46
|
+
cancelText={c('cancel')}
|
|
47
|
+
placement='top'
|
|
48
|
+
>
|
|
49
|
+
<CloseOutlined title={e('del')} className='pointer tree-control-btn' />
|
|
50
|
+
</Popconfirm>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const renderOperationBtn = (item, isGroup) => {
|
|
55
|
+
if (props.staticList) {
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
return (
|
|
59
|
+
<SettingOutlined
|
|
60
|
+
className='pointer tree-control-btn'
|
|
61
|
+
onClick={handleContextMenu}
|
|
62
|
+
/>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handleOpenAll = () => {
|
|
67
|
+
props.openAll(props.item)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const handleContextMenu = (e) => {
|
|
71
|
+
props.onContextMenu(e, props.item, props.isGroup)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const handleEditItem = (e) => {
|
|
75
|
+
props.editItem(e, props.item, props.isGroup)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const handleAddSubCat = (e) => {
|
|
79
|
+
props.addSubCat(e, props.item)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const renderAddNewSubGroupBtn = () => {
|
|
83
|
+
if (props.staticList) {
|
|
84
|
+
return null
|
|
85
|
+
}
|
|
86
|
+
return (
|
|
87
|
+
<FolderAddOutlined
|
|
88
|
+
key='new-tree'
|
|
89
|
+
title={`${s('new')} ${c('bookmarkCategory')}`}
|
|
90
|
+
onClick={handleAddSubCat}
|
|
91
|
+
className='pointer tree-control-btn'
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const renderEditBtn = () => {
|
|
97
|
+
const {
|
|
98
|
+
isGroup, staticList
|
|
99
|
+
} = props
|
|
100
|
+
if (
|
|
101
|
+
(staticList && isGroup) ||
|
|
102
|
+
(!staticList && !isGroup)
|
|
103
|
+
) {
|
|
104
|
+
return null
|
|
105
|
+
}
|
|
106
|
+
return (
|
|
107
|
+
<EditOutlined
|
|
108
|
+
title={e('edit')}
|
|
109
|
+
key='edit-tree'
|
|
110
|
+
onClick={handleEditItem}
|
|
111
|
+
className='pointer edit-icon tree-control-btn'
|
|
112
|
+
/>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const onSelect = (e) => {
|
|
117
|
+
props.onSelect(e)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const renderOpenAll = () => {
|
|
121
|
+
const {
|
|
122
|
+
staticList,
|
|
123
|
+
isGroup
|
|
124
|
+
} = props
|
|
125
|
+
if (
|
|
126
|
+
(staticList && !isGroup) ||
|
|
127
|
+
!staticList
|
|
128
|
+
) {
|
|
129
|
+
return null
|
|
130
|
+
}
|
|
131
|
+
return (
|
|
132
|
+
<Tooltip title={s('openAll')}>
|
|
133
|
+
<FolderOpenOutlined
|
|
134
|
+
key='open-all-tree'
|
|
135
|
+
onClick={handleOpenAll}
|
|
136
|
+
className='pointer open-all-icon tree-control-btn'
|
|
137
|
+
/>
|
|
138
|
+
</Tooltip>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const handleDuplicateItem = (e) => {
|
|
143
|
+
props.duplicateItem(e, props.item)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const renderDuplicateBtn = () => {
|
|
147
|
+
const {
|
|
148
|
+
item,
|
|
149
|
+
staticList
|
|
150
|
+
} = props
|
|
151
|
+
if (!item.id || staticList) {
|
|
152
|
+
return null
|
|
153
|
+
}
|
|
154
|
+
return (
|
|
155
|
+
<CopyOutlined
|
|
156
|
+
title={e('duplicate')}
|
|
157
|
+
className='pointer tree-control-btn'
|
|
158
|
+
onClick={handleDuplicateItem}
|
|
159
|
+
/>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const renderGroupBtns = () => {
|
|
164
|
+
return [
|
|
165
|
+
renderAddNewSubGroupBtn(),
|
|
166
|
+
renderOpenAll()
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const onDragOver = e => {
|
|
171
|
+
props.onDragOver(e)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const onDragStart = e => {
|
|
175
|
+
props.onDragStart(e)
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const onDragLeave = e => {
|
|
179
|
+
props.onDragLeave(e)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// sort quick commands array when drop, so that the dragged item will be placed at the right position, e.target.getAttribute('data-id') would target item id, e.dataTransfer.getData('idDragged') would target dragged item id, then set window.store.quickCommands use window.store.setItems
|
|
183
|
+
const onDrop = e => {
|
|
184
|
+
props.onDrop(e)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const {
|
|
188
|
+
item,
|
|
189
|
+
isGroup,
|
|
190
|
+
selectedItemId
|
|
191
|
+
} = props
|
|
192
|
+
const cls = classnames(
|
|
193
|
+
{
|
|
194
|
+
selected: selectedItemId === item.id
|
|
195
|
+
},
|
|
196
|
+
'tree-item elli',
|
|
197
|
+
{
|
|
198
|
+
'is-category': isGroup,
|
|
199
|
+
level2: item.level === 2
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
const tag = isGroup ? '' : createTitleTag(item)
|
|
203
|
+
const title = isGroup
|
|
204
|
+
? item.title
|
|
205
|
+
: createName(item)
|
|
206
|
+
const titleAll = title + (item.description ? ' - ' + item.description : '')
|
|
207
|
+
const titleHighlight = isGroup
|
|
208
|
+
? item.title || 'no title'
|
|
209
|
+
: highlight(
|
|
210
|
+
title,
|
|
211
|
+
props.keyword
|
|
212
|
+
)
|
|
213
|
+
const propsAll = {
|
|
214
|
+
className: cls,
|
|
215
|
+
title: titleAll,
|
|
216
|
+
onContextMenu: handleContextMenu,
|
|
217
|
+
draggable: true,
|
|
218
|
+
'data-item-id': item.id,
|
|
219
|
+
'data-parent-id': props.parentId,
|
|
220
|
+
'data-is-group': isGroup ? 'true' : 'false',
|
|
221
|
+
onDragOver,
|
|
222
|
+
onDragStart,
|
|
223
|
+
onDragLeave,
|
|
224
|
+
onDrop
|
|
225
|
+
}
|
|
226
|
+
const titleProps = {
|
|
227
|
+
className: 'tree-item-title elli',
|
|
228
|
+
onClick: onSelect,
|
|
229
|
+
'data-item-id': item.id,
|
|
230
|
+
'data-is-group': isGroup ? 'true' : 'false',
|
|
231
|
+
'data-parent-id': props.parentId,
|
|
232
|
+
style: props.staticList
|
|
233
|
+
? { maxWidth: (props.leftSidebarWidth - 110) + 'px' }
|
|
234
|
+
: undefined
|
|
235
|
+
}
|
|
236
|
+
const key = item.id || uid()
|
|
237
|
+
return (
|
|
238
|
+
<div
|
|
239
|
+
{...propsAll}
|
|
240
|
+
key={key}
|
|
241
|
+
>
|
|
242
|
+
<div
|
|
243
|
+
{...titleProps}
|
|
244
|
+
>
|
|
245
|
+
{tag}{titleHighlight}
|
|
246
|
+
</div>
|
|
247
|
+
{
|
|
248
|
+
isGroup
|
|
249
|
+
? renderGroupBtns()
|
|
250
|
+
: null
|
|
251
|
+
}
|
|
252
|
+
{
|
|
253
|
+
!isGroup
|
|
254
|
+
? renderDuplicateBtn()
|
|
255
|
+
: null
|
|
256
|
+
}
|
|
257
|
+
{renderOperationBtn()}
|
|
258
|
+
{renderDelBtn()}
|
|
259
|
+
{renderEditBtn()}
|
|
260
|
+
</div>
|
|
261
|
+
)
|
|
262
|
+
})
|