@electerm/electerm-react 1.39.31 → 1.39.46

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.
Files changed (28) hide show
  1. package/client/common/create-title.jsx +1 -1
  2. package/client/common/default-setting.js +2 -1
  3. package/client/components/bookmark-form/bookmark-group-tree-format.js +25 -24
  4. package/client/components/bookmark-form/form-ssh-common.jsx +10 -0
  5. package/client/components/bookmark-form/render-connection-hopping.jsx +21 -20
  6. package/client/components/bookmark-form/render-ssh-tunnel.jsx +4 -3
  7. package/client/components/bookmark-form/ssh-form.jsx +2 -1
  8. package/client/components/bookmark-form/vnc-form-ui.jsx +42 -3
  9. package/client/components/main/main.jsx +1 -1
  10. package/client/components/profile/profile-form-elem.jsx +0 -1
  11. package/client/components/quick-commands/quick-command-transport-mod.jsx +1 -1
  12. package/client/components/setting-panel/bookmark-tree-list.jsx +1 -1
  13. package/client/components/setting-panel/setting-common.jsx +1 -0
  14. package/client/components/setting-panel/setting-modal.jsx +1 -1
  15. package/client/components/setting-panel/start-session-select.jsx +4 -3
  16. package/client/components/sftp/file-item.jsx +3 -3
  17. package/client/components/sidebar/bookmark-select.jsx +1 -1
  18. package/client/components/tabs/index.jsx +1 -1
  19. package/client/components/tabs/tabs.styl +2 -2
  20. package/client/components/terminal/index.jsx +1 -1
  21. package/client/components/tree-list/tree-expander.jsx +36 -0
  22. package/client/components/tree-list/tree-list-item.jsx +263 -0
  23. package/client/components/{setting-panel → tree-list}/tree-list.jsx +397 -324
  24. package/client/components/{setting-panel → tree-list}/tree-list.styl +26 -6
  25. package/client/store/common.js +15 -1
  26. package/client/store/index.js +24 -0
  27. package/package.json +1 -1
  28. /package/client/components/{setting-panel → tree-list}/bookmark-transport.jsx +0 -0
@@ -0,0 +1,263 @@
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
+ renderEditBtn(),
167
+ renderOpenAll()
168
+ ]
169
+ }
170
+
171
+ const onDragOver = e => {
172
+ props.onDragOver(e)
173
+ }
174
+
175
+ const onDragStart = e => {
176
+ props.onDragStart(e)
177
+ }
178
+
179
+ const onDragLeave = e => {
180
+ props.onDragLeave(e)
181
+ }
182
+
183
+ // 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
184
+ const onDrop = e => {
185
+ props.onDrop(e)
186
+ }
187
+
188
+ const {
189
+ item,
190
+ isGroup,
191
+ selectedItemId
192
+ } = props
193
+ const cls = classnames(
194
+ {
195
+ selected: selectedItemId === item.id
196
+ },
197
+ 'tree-item elli',
198
+ {
199
+ 'is-category': isGroup,
200
+ level2: item.level === 2
201
+ }
202
+ )
203
+ const tag = isGroup ? '' : createTitleTag(item)
204
+ const title = isGroup
205
+ ? item.title
206
+ : createName(item)
207
+ const titleAll = title + (item.description ? ' - ' + item.description : '')
208
+ const titleHighlight = isGroup
209
+ ? item.title || 'no title'
210
+ : highlight(
211
+ title,
212
+ props.keyword
213
+ )
214
+ const propsAll = {
215
+ className: cls,
216
+ title: titleAll,
217
+ onContextMenu: handleContextMenu,
218
+ draggable: true,
219
+ 'data-item-id': item.id,
220
+ 'data-parent-id': props.parentId,
221
+ 'data-is-group': isGroup ? 'true' : 'false',
222
+ onDragOver,
223
+ onDragStart,
224
+ onDragLeave,
225
+ onDrop
226
+ }
227
+ const titleProps = {
228
+ className: 'tree-item-title elli',
229
+ onClick: onSelect,
230
+ 'data-item-id': item.id,
231
+ 'data-is-group': isGroup ? 'true' : 'false',
232
+ 'data-parent-id': props.parentId,
233
+ style: props.staticList
234
+ ? { maxWidth: (props.leftSidebarWidth - 110) + 'px' }
235
+ : undefined
236
+ }
237
+ const key = item.id || uid()
238
+ return (
239
+ <div
240
+ {...propsAll}
241
+ key={key}
242
+ >
243
+ <div
244
+ {...titleProps}
245
+ >
246
+ {tag}{titleHighlight}
247
+ </div>
248
+ {
249
+ isGroup
250
+ ? renderGroupBtns()
251
+ : null
252
+ }
253
+ {
254
+ !isGroup
255
+ ? renderDuplicateBtn()
256
+ : null
257
+ }
258
+ {renderOperationBtn()}
259
+ {renderDelBtn()}
260
+ {renderEditBtn()}
261
+ </div>
262
+ )
263
+ })