@electerm/electerm-react 1.34.30

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 (273) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/client/common/auto-complete-data-mapper.js +6 -0
  4. package/client/common/byte-format.js +14 -0
  5. package/client/common/class.js +52 -0
  6. package/client/common/clipboard.js +49 -0
  7. package/client/common/constants.js +308 -0
  8. package/client/common/create-lang-edit-link.js +7 -0
  9. package/client/common/create-title.js +29 -0
  10. package/client/common/db-fix.js +24 -0
  11. package/client/common/db.js +155 -0
  12. package/client/common/download-mirrors.js +10 -0
  13. package/client/common/download.js +16 -0
  14. package/client/common/error-handler.jsx +27 -0
  15. package/client/common/fetch-from-server.js +47 -0
  16. package/client/common/fetch.jsx +71 -0
  17. package/client/common/find-bookmark-group-id.js +15 -0
  18. package/client/common/find-parent.js +30 -0
  19. package/client/common/form-layout.js +27 -0
  20. package/client/common/fs.js +21 -0
  21. package/client/common/get-proxy.js +8 -0
  22. package/client/common/id-with-stamp.js +10 -0
  23. package/client/common/index-sorter.js +4 -0
  24. package/client/common/init-setting-item.js +32 -0
  25. package/client/common/is-absolute-path.js +3 -0
  26. package/client/common/is-ip.js +16 -0
  27. package/client/common/is-valid-path.js +7 -0
  28. package/client/common/key-control-pressed.js +13 -0
  29. package/client/common/key-pressed.js +13 -0
  30. package/client/common/key-shift-pressed.js +7 -0
  31. package/client/common/mode2permission.js +81 -0
  32. package/client/common/new-terminal.js +31 -0
  33. package/client/common/parse-int10.js +3 -0
  34. package/client/common/parse-json-safe.js +11 -0
  35. package/client/common/pass-enc.js +25 -0
  36. package/client/common/post-msg.js +3 -0
  37. package/client/common/pre.js +156 -0
  38. package/client/common/promise-timeout.js +27 -0
  39. package/client/common/resolve.js +31 -0
  40. package/client/common/run-idle.js +1 -0
  41. package/client/common/safe-local-storage.js +35 -0
  42. package/client/common/safe-name.js +19 -0
  43. package/client/common/sftp.js +74 -0
  44. package/client/common/terminal-theme.js +158 -0
  45. package/client/common/test-connection.js +12 -0
  46. package/client/common/time.js +30 -0
  47. package/client/common/to-simple-obj.js +5 -0
  48. package/client/common/track.js +7 -0
  49. package/client/common/transfer.js +76 -0
  50. package/client/common/trzsz.js +62 -0
  51. package/client/common/ui-theme.js +44 -0
  52. package/client/common/uid.js +5 -0
  53. package/client/common/update-check.js +79 -0
  54. package/client/common/upgrade.js +68 -0
  55. package/client/common/wait.js +8 -0
  56. package/client/common/ws.js +161 -0
  57. package/client/components/batch-op/batch-op.jsx +650 -0
  58. package/client/components/bookmark-form/bookmark-form.styl +8 -0
  59. package/client/components/bookmark-form/bookmark-group-tree-format.js +39 -0
  60. package/client/components/bookmark-form/encodes.js +44 -0
  61. package/client/components/bookmark-form/form-ssh-common.jsx +208 -0
  62. package/client/components/bookmark-form/form-tabs.jsx +69 -0
  63. package/client/components/bookmark-form/index.jsx +159 -0
  64. package/client/components/bookmark-form/local-form-ui.jsx +152 -0
  65. package/client/components/bookmark-form/local-form.jsx +16 -0
  66. package/client/components/bookmark-form/proxy.jsx +49 -0
  67. package/client/components/bookmark-form/quick-command-list.jsx +31 -0
  68. package/client/components/bookmark-form/quick-command.jsx +228 -0
  69. package/client/components/bookmark-form/render-auth-ssh.jsx +104 -0
  70. package/client/components/bookmark-form/render-connection-hopping.jsx +229 -0
  71. package/client/components/bookmark-form/render-delayed-scripts.jsx +88 -0
  72. package/client/components/bookmark-form/render-ssh-tunnel.jsx +116 -0
  73. package/client/components/bookmark-form/serial-form-ui.jsx +311 -0
  74. package/client/components/bookmark-form/serial-form.jsx +20 -0
  75. package/client/components/bookmark-form/sftp-enable.jsx +33 -0
  76. package/client/components/bookmark-form/ssh-form-ui.jsx +100 -0
  77. package/client/components/bookmark-form/ssh-form.jsx +348 -0
  78. package/client/components/bookmark-form/telnet-form-ui.jsx +154 -0
  79. package/client/components/bookmark-form/telnet-form.jsx +16 -0
  80. package/client/components/bookmark-form/tree-delete.jsx +87 -0
  81. package/client/components/bookmark-form/use-form-funcs.jsx +50 -0
  82. package/client/components/bookmark-form/use-quick-commands.jsx +83 -0
  83. package/client/components/bookmark-form/use-submit.jsx +77 -0
  84. package/client/components/bookmark-form/use-ui.jsx +82 -0
  85. package/client/components/bookmark-form/x11.jsx +23 -0
  86. package/client/components/common/animate-text.jsx +37 -0
  87. package/client/components/common/animate-text.styl +54 -0
  88. package/client/components/common/external-link.jsx +28 -0
  89. package/client/components/common/help-icon.jsx +25 -0
  90. package/client/components/common/highlight.jsx +23 -0
  91. package/client/components/common/highlight.styl +3 -0
  92. package/client/components/common/input-auto-focus.jsx +68 -0
  93. package/client/components/common/input-confirm.jsx +66 -0
  94. package/client/components/common/logo-elem.jsx +22 -0
  95. package/client/components/common/markdown.jsx +27 -0
  96. package/client/components/common/react-subx.jsx +1 -0
  97. package/client/components/common/resize-wrap.jsx +222 -0
  98. package/client/components/common/resize-wrap.styl +9 -0
  99. package/client/components/common/search.jsx +9 -0
  100. package/client/components/common/show-item.jsx +27 -0
  101. package/client/components/context-menu/boomarks.jsx +15 -0
  102. package/client/components/context-menu/context-menu.jsx +340 -0
  103. package/client/components/context-menu/context-menu.styl +90 -0
  104. package/client/components/context-menu/history.jsx +27 -0
  105. package/client/components/context-menu/icon-holder.jsx +5 -0
  106. package/client/components/context-menu/menu-btn.jsx +224 -0
  107. package/client/components/context-menu/sub-tab-menu.jsx +23 -0
  108. package/client/components/context-menu/tabs.jsx +22 -0
  109. package/client/components/context-menu/zoom.jsx +40 -0
  110. package/client/components/footer/batch-input.jsx +177 -0
  111. package/client/components/footer/footer-entry.jsx +141 -0
  112. package/client/components/footer/footer.styl +47 -0
  113. package/client/components/icons/match-case.jsx +10 -0
  114. package/client/components/icons/match-whole-word.jsx +13 -0
  115. package/client/components/icons/regular-exp.jsx +10 -0
  116. package/client/components/main/css-overwrite.jsx +92 -0
  117. package/client/components/main/error-wrapper.jsx +59 -0
  118. package/client/components/main/index.jsx +11 -0
  119. package/client/components/main/loading.jsx +25 -0
  120. package/client/components/main/main.jsx +149 -0
  121. package/client/components/main/term-fullscreen-control.jsx +21 -0
  122. package/client/components/main/term-fullscreen.styl +27 -0
  123. package/client/components/main/ui-theme.jsx +31 -0
  124. package/client/components/main/upgrade.jsx +351 -0
  125. package/client/components/main/upgrade.styl +27 -0
  126. package/client/components/main/wrapper.styl +41 -0
  127. package/client/components/quick-commands/qm.styl +29 -0
  128. package/client/components/quick-commands/quick-command-item.jsx +36 -0
  129. package/client/components/quick-commands/quick-command-transport-mod.jsx +54 -0
  130. package/client/components/quick-commands/quick-command-transport.jsx +12 -0
  131. package/client/components/quick-commands/quick-commands-box.jsx +233 -0
  132. package/client/components/quick-commands/quick-commands-form-elem.jsx +119 -0
  133. package/client/components/quick-commands/quick-commands-form.jsx +33 -0
  134. package/client/components/quick-commands/quick-commands-list.jsx +128 -0
  135. package/client/components/quick-commands/quick-commands-select.jsx +38 -0
  136. package/client/components/session/session.jsx +533 -0
  137. package/client/components/session/session.styl +53 -0
  138. package/client/components/session/sessions.jsx +445 -0
  139. package/client/components/setting-panel/bookmark-transport.jsx +148 -0
  140. package/client/components/setting-panel/bookmark-tree-list.jsx +14 -0
  141. package/client/components/setting-panel/col.jsx +18 -0
  142. package/client/components/setting-panel/list.jsx +186 -0
  143. package/client/components/setting-panel/list.styl +33 -0
  144. package/client/components/setting-panel/on-tree-drop.js +222 -0
  145. package/client/components/setting-panel/setting-modal.jsx +163 -0
  146. package/client/components/setting-panel/setting-wrap.jsx +37 -0
  147. package/client/components/setting-panel/setting-wrap.styl +52 -0
  148. package/client/components/setting-panel/setting.jsx +858 -0
  149. package/client/components/setting-panel/setting.styl +4 -0
  150. package/client/components/setting-panel/start-session-select.jsx +91 -0
  151. package/client/components/setting-panel/tab-bookmarks.jsx +37 -0
  152. package/client/components/setting-panel/tab-history.jsx +44 -0
  153. package/client/components/setting-panel/tab-quick-commands.jsx +38 -0
  154. package/client/components/setting-panel/tab-settings.jsx +42 -0
  155. package/client/components/setting-panel/tab-themes.jsx +34 -0
  156. package/client/components/setting-panel/tree-list.jsx +978 -0
  157. package/client/components/setting-panel/tree-list.styl +57 -0
  158. package/client/components/setting-sync/data-import.jsx +65 -0
  159. package/client/components/setting-sync/setting-sync-form.jsx +271 -0
  160. package/client/components/setting-sync/setting-sync.jsx +81 -0
  161. package/client/components/setting-sync/sync.styl +7 -0
  162. package/client/components/sftp/address-bar.jsx +139 -0
  163. package/client/components/sftp/address-bookmark-item.jsx +47 -0
  164. package/client/components/sftp/address-bookmark.jsx +81 -0
  165. package/client/components/sftp/address-bookmark.styl +8 -0
  166. package/client/components/sftp/confirm-modal.jsx +184 -0
  167. package/client/components/sftp/file-icon.jsx +22 -0
  168. package/client/components/sftp/file-item.jsx +1226 -0
  169. package/client/components/sftp/file-mode-modal.jsx +205 -0
  170. package/client/components/sftp/file-props-modal.jsx +211 -0
  171. package/client/components/sftp/file-read.js +81 -0
  172. package/client/components/sftp/list-table-ui.jsx +547 -0
  173. package/client/components/sftp/owner-list.js +97 -0
  174. package/client/components/sftp/paged-list.jsx +60 -0
  175. package/client/components/sftp/permission-render.jsx +42 -0
  176. package/client/components/sftp/sftp-entry.jsx +1069 -0
  177. package/client/components/sftp/sftp.styl +217 -0
  178. package/client/components/sftp/transfer-common.js +9 -0
  179. package/client/components/sftp/transfer-conflict.jsx +315 -0
  180. package/client/components/sftp/transfer-speed-format.js +60 -0
  181. package/client/components/sftp/transfer-tag.jsx +40 -0
  182. package/client/components/sftp/transfer-tag.styl +11 -0
  183. package/client/components/sftp/transfer.styl +55 -0
  184. package/client/components/sftp/transport-action.jsx +410 -0
  185. package/client/components/sftp/transport-entry.jsx +108 -0
  186. package/client/components/sftp/transport-types.js +8 -0
  187. package/client/components/sftp/transports-action.jsx +111 -0
  188. package/client/components/sftp/transports-ui.jsx +93 -0
  189. package/client/components/sftp/zip.js +42 -0
  190. package/client/components/sidebar/bookmark-select.jsx +48 -0
  191. package/client/components/sidebar/bookmark.jsx +82 -0
  192. package/client/components/sidebar/history.jsx +66 -0
  193. package/client/components/sidebar/index.jsx +230 -0
  194. package/client/components/sidebar/info-modal.jsx +250 -0
  195. package/client/components/sidebar/info.styl +27 -0
  196. package/client/components/sidebar/side-icon.jsx +25 -0
  197. package/client/components/sidebar/sidebar.styl +128 -0
  198. package/client/components/sidebar/transfer-history-modal.jsx +110 -0
  199. package/client/components/sidebar/transfer-history.styl +3 -0
  200. package/client/components/sidebar/transfer-list-control.jsx +205 -0
  201. package/client/components/sidebar/transfer-list.jsx +55 -0
  202. package/client/components/sidebar/transfer-modal.jsx +76 -0
  203. package/client/components/sidebar/transfer.styl +8 -0
  204. package/client/components/sidebar/transport-ui.jsx +109 -0
  205. package/client/components/tabs/index.jsx +320 -0
  206. package/client/components/tabs/tab.jsx +427 -0
  207. package/client/components/tabs/tabs.styl +220 -0
  208. package/client/components/tabs/window-control.jsx +55 -0
  209. package/client/components/terminal/attach-addon-custom.js +70 -0
  210. package/client/components/terminal/build-ls-term-id.js +5 -0
  211. package/client/components/terminal/index.jsx +1358 -0
  212. package/client/components/terminal/normal-buffer.jsx +33 -0
  213. package/client/components/terminal/term-search.jsx +224 -0
  214. package/client/components/terminal/term-search.styl +15 -0
  215. package/client/components/terminal/terminal-apis.js +31 -0
  216. package/client/components/terminal/terminal-interactive.jsx +148 -0
  217. package/client/components/terminal/terminal.styl +96 -0
  218. package/client/components/terminal/xterm-zmodem.js +48 -0
  219. package/client/components/terminal/zmodem-transfer.jsx +98 -0
  220. package/client/components/terminal/zmodem.styl +14 -0
  221. package/client/components/terminal-info/activity.jsx +54 -0
  222. package/client/components/terminal-info/base.jsx +25 -0
  223. package/client/components/terminal-info/content.jsx +101 -0
  224. package/client/components/terminal-info/data-cols-parser.jsx +50 -0
  225. package/client/components/terminal-info/disk.jsx +29 -0
  226. package/client/components/terminal-info/index.jsx +25 -0
  227. package/client/components/terminal-info/network.jsx +114 -0
  228. package/client/components/terminal-info/resource.jsx +80 -0
  229. package/client/components/terminal-info/run-cmd.jsx +273 -0
  230. package/client/components/terminal-info/terminal-info.styl +29 -0
  231. package/client/components/terminal-info/up.jsx +15 -0
  232. package/client/components/terminal-theme/index.jsx +264 -0
  233. package/client/components/terminal-theme/terminal-theme-list.styl +3 -0
  234. package/client/components/terminal-theme/theme-list.jsx +146 -0
  235. package/client/components/text-editor/text-editor-form.jsx +97 -0
  236. package/client/components/text-editor/text-editor.jsx +182 -0
  237. package/client/css/antd-overwrite.styl +14 -0
  238. package/client/css/basic.styl +38 -0
  239. package/client/css/includes/box.styl +154 -0
  240. package/client/css/includes/font-size.styl +6 -0
  241. package/client/css/includes/index.styl +3 -0
  242. package/client/css/includes/text.styl +31 -0
  243. package/client/css/includes/theme-default.styl +20 -0
  244. package/client/entry/basic.js +58 -0
  245. package/client/entry/index.jsx +15 -0
  246. package/client/entry/worker.js +137 -0
  247. package/client/store/address-bookmark.js +25 -0
  248. package/client/store/app-upgrade.js +23 -0
  249. package/client/store/batch-input-history.js +26 -0
  250. package/client/store/bookmark-group.js +128 -0
  251. package/client/store/bookmark.js +22 -0
  252. package/client/store/common.js +140 -0
  253. package/client/store/context-menu.js +23 -0
  254. package/client/store/db-upgrade.js +43 -0
  255. package/client/store/event.js +70 -0
  256. package/client/store/index.js +335 -0
  257. package/client/store/init-state.js +191 -0
  258. package/client/store/item.js +120 -0
  259. package/client/store/load-data.js +198 -0
  260. package/client/store/quick-command.js +43 -0
  261. package/client/store/session.js +54 -0
  262. package/client/store/setting.js +208 -0
  263. package/client/store/sidebar.js +48 -0
  264. package/client/store/sync.js +390 -0
  265. package/client/store/system-menu.js +120 -0
  266. package/client/store/tab.js +74 -0
  267. package/client/store/terminal-theme.js +116 -0
  268. package/client/store/transfer-history.js +27 -0
  269. package/client/store/transfer-list.js +20 -0
  270. package/client/store/ui-theme.js +71 -0
  271. package/client/store/watch.js +116 -0
  272. package/client/views/index.pug +58 -0
  273. package/package.json +34 -0
@@ -0,0 +1,186 @@
1
+ /**
2
+ * history list
3
+ */
4
+ import React from 'react'
5
+ import { CloseOutlined, EditOutlined, LoadingOutlined } from '@ant-design/icons'
6
+ import { Popconfirm } from 'antd'
7
+ import Search from '../common/search'
8
+ import createName from '../../common/create-title'
9
+ import classnames from 'classnames'
10
+ import { noop } from 'lodash-es'
11
+ import highlight from '../common/highlight'
12
+ import { settingSyncId, settingCommonId } from '../../common/constants'
13
+ import './list.styl'
14
+
15
+ const { prefix } = window
16
+ const e = prefix('menu')
17
+ const c = prefix('common')
18
+ const s = prefix('setting')
19
+
20
+ export default class ItemList extends React.PureComponent {
21
+ state = {
22
+ keyword: '',
23
+ ready: false,
24
+ labels: [],
25
+ page: 1,
26
+ pageSize: 10
27
+ }
28
+
29
+ componentDidMount () {
30
+ this.timer = setTimeout(() => {
31
+ this.setState({
32
+ ready: true
33
+ })
34
+ }, 200)
35
+ }
36
+
37
+ componentWillUnmount () {
38
+ clearTimeout(this.timer)
39
+ }
40
+
41
+ handleChange = e => {
42
+ this.setState({
43
+ page: 1,
44
+ keyword: e.target.value
45
+ })
46
+ }
47
+
48
+ del = (item, e) => {
49
+ e.stopPropagation()
50
+ this.props.store.delItem(item, this.props.type)
51
+ }
52
+
53
+ editItem = (e, item, isGroup) => {
54
+ e.stopPropagation()
55
+ this.props.store.openBookmarkEdit(item)
56
+ }
57
+
58
+ renderSearch = () => {
59
+ return (
60
+ <div className='pd1y'>
61
+ <Search
62
+ onChange={this.handleChange}
63
+ value={this.state.keyword}
64
+ />
65
+ </div>
66
+ )
67
+ }
68
+
69
+ renderDelBtn = item => {
70
+ if (!item.id || [settingSyncId, settingCommonId].includes(item.id) || item.id.startsWith('default')) {
71
+ return null
72
+ }
73
+ const { shouldConfirmDel } = this.props
74
+ const icon = (
75
+ <CloseOutlined
76
+ title={e('del')}
77
+ className='pointer list-item-remove'
78
+ onClick={
79
+ shouldConfirmDel
80
+ ? noop
81
+ : e => this.del(item, e)
82
+ }
83
+ />
84
+ )
85
+ if (shouldConfirmDel) {
86
+ return (
87
+ <Popconfirm
88
+ title={e('del') + '?'}
89
+ onConfirm={e => this.del(item, e)}
90
+ okText={e('del')}
91
+ cancelText={c('cancel')}
92
+ placement='top'
93
+ >
94
+ {icon}
95
+ </Popconfirm>
96
+ )
97
+ }
98
+ return icon
99
+ }
100
+
101
+ renderItem = (item, i) => {
102
+ const { onClickItem, type, activeItemId } = this.props
103
+ const { id } = item
104
+ const title = createName(item)
105
+ const cls = classnames(
106
+ 'item-list-unit',
107
+ {
108
+ active: activeItemId === id
109
+ }
110
+ )
111
+ const titleHighlight = highlight(
112
+ title,
113
+ this.state.keyword
114
+ )
115
+ const isGroup = false
116
+ return (
117
+ <div
118
+ key={i + '__' + id}
119
+ className={cls}
120
+ onClick={() => onClickItem(item, type)}
121
+ >
122
+ <div
123
+ title={title}
124
+ className='elli pd1y pd2x list-item-title'
125
+ >{titleHighlight || s('new')}
126
+ </div>
127
+ {this.renderDelBtn(item)}
128
+ {this.renderEditBtn(item, isGroup)}
129
+ </div>
130
+ )
131
+ }
132
+
133
+ filter = list => {
134
+ const { keyword } = this.state
135
+ return keyword
136
+ ? list.filter(item => {
137
+ return createName(item).toLowerCase().includes(keyword.toLowerCase())
138
+ })
139
+ : list
140
+ }
141
+
142
+ renderEditBtn = (item, isGroup) => {
143
+ if (
144
+ (this.props.staticList && isGroup) ||
145
+ (!this.props.staticList && !isGroup)
146
+ ) {
147
+ return null
148
+ }
149
+ return (
150
+ <EditOutlined
151
+ title={e('edit')}
152
+ onClick={(e) => this.editItem(e, item, isGroup)}
153
+ className='pointer list-item-edit'
154
+ />
155
+ )
156
+ }
157
+
158
+ render () {
159
+ const { ready } = this.state
160
+ if (!ready) {
161
+ return (
162
+ <div className='pd3 aligncenter'>
163
+ <LoadingOutlined />
164
+ </div>
165
+ )
166
+ }
167
+ let {
168
+ list = [],
169
+ type,
170
+ listStyle = {}
171
+ } = this.props
172
+ list = this.filter(list)
173
+ return (
174
+ <div className={`item-list item-type-${type}`}>
175
+ {this.renderTransport ? this.renderTransport() : null}
176
+ {this.renderLabels ? this.renderLabels() : null}
177
+ {this.renderSearch()}
178
+ <div className='item-list-wrap' style={listStyle}>
179
+ {
180
+ list.map(this.renderItem)
181
+ }
182
+ </div>
183
+ </div>
184
+ )
185
+ }
186
+ }
@@ -0,0 +1,33 @@
1
+ @require '../../css/includes/theme-default'
2
+ .item-list-wrap
3
+ overflow-y scroll
4
+ &::-webkit-scrollbar
5
+ width 0
6
+ .list-item-edit
7
+ .list-item-apply
8
+ .list-item-remove
9
+ display none
10
+ width 24px
11
+ line-height 35px
12
+ text-align center
13
+ .list-item-title
14
+ flex-grow: 1
15
+ .item-list-unit
16
+ display flex
17
+ position relative
18
+ margin-bottom 1px
19
+ cursor pointer
20
+ line-height 1.8
21
+ cu
22
+ &.active
23
+ background primary
24
+ color contrastColor(primary)
25
+ &.current
26
+ font-weight bold
27
+ &:hover
28
+ background darken(primary, 30%)
29
+ color contrastColor(darken(primary, 30%))
30
+ .list-item-apply
31
+ .list-item-edit
32
+ .list-item-remove
33
+ display block
@@ -0,0 +1,222 @@
1
+ /**
2
+ * handle tree on drop event to support category drag/drop in any form
3
+ */
4
+
5
+ import {
6
+ defaultBookmarkGroupId
7
+ } from '../../common/constants'
8
+ import { isEqual, find, findIndex, last, remove } from 'lodash-es'
9
+ import copy from 'json-deep-copy'
10
+
11
+ export default (info, props) => {
12
+ const {
13
+ dropToGap,
14
+ dragNode,
15
+ node,
16
+ dropPosition
17
+ } = info
18
+ const fromId = dragNode.key
19
+ const toId = node.key
20
+ const fromPoses = dragNode.pos.split('-').map(Number)
21
+ const fromPosesLevel = fromPoses.slice(0, fromPoses.length - 1)
22
+ const toPoses = node.pos.split('-').map(Number)
23
+ const toPosesLevel = toPoses.slice(0, toPoses.length - 1)
24
+ const isSameLevel = fromPosesLevel.length === toPosesLevel.length
25
+ const isSameCat = isEqual(fromPosesLevel, toPosesLevel) && dropToGap
26
+ const bookmarks = copy(props.bookmarks)
27
+ const bookmarkGroups = copy(
28
+ props.bookmarkGroups
29
+ )
30
+ let from = find(
31
+ bookmarks,
32
+ d => d.id === fromId
33
+ ) || find(
34
+ bookmarkGroups,
35
+ d => d.id === fromId
36
+ )
37
+ const fromLeaf = !!from && !from.bookmarkIds
38
+ let to = find(
39
+ bookmarks,
40
+ d => d.id === toId
41
+ ) || find(
42
+ bookmarkGroups,
43
+ d => d.id === toId
44
+ )
45
+ const toLeaf = !!to && !to.bookmarkIds
46
+
47
+ // no match
48
+ if (!to || !from) {
49
+ return
50
+ }
51
+
52
+ // // drop to a leaf
53
+ // if (toLeaf && !dropToGap) {
54
+ // return
55
+ // }
56
+
57
+ // drag default cateogry to other level
58
+ if (fromId === defaultBookmarkGroupId && !isSameLevel) {
59
+ return
60
+ }
61
+
62
+ // drag default cateogry to nongap
63
+ if (fromId === defaultBookmarkGroupId && !dropToGap) {
64
+ return
65
+ }
66
+
67
+ // drag cateogry with subscategory to non gap
68
+ if (!fromLeaf && !dropToGap && from.bookmarkGroupIds && from.bookmarkGroupIds.length) {
69
+ return
70
+ }
71
+
72
+ // drag cat to level2 node
73
+ if (!fromLeaf && toPoses.length > 2) {
74
+ return
75
+ }
76
+
77
+ // drag node to first level
78
+ if (fromLeaf && toPoses.length <= 2 && dropToGap) {
79
+ return
80
+ }
81
+
82
+ // drag leaf node to cat gap
83
+ if (fromLeaf && toPoses.length > 2 && dropToGap && !toLeaf) {
84
+ return
85
+ }
86
+
87
+ // let's confirm the drop position
88
+ to = copy(to)
89
+ let fromGroup = null
90
+ if (fromPoses.length > 2) {
91
+ fromGroup = fromLeaf
92
+ ? find(
93
+ bookmarkGroups,
94
+ d => (d.bookmarkIds || []).includes(fromId)
95
+ )
96
+ : find(
97
+ bookmarkGroups,
98
+ d => (d.bookmarkGroupIds || []).includes(fromId)
99
+ )
100
+ }
101
+ let toGroup = null
102
+ const toFirstLevel = toPoses.length === 2 && dropToGap
103
+ if (!toFirstLevel) {
104
+ toGroup = dropToGap
105
+ ? find(
106
+ bookmarkGroups,
107
+ d => {
108
+ const arr = toLeaf
109
+ ? d.bookmarkIds
110
+ : d.bookmarkGroupIds
111
+ return (arr || []).includes(toId)
112
+ }
113
+ )
114
+ : (
115
+ toLeaf
116
+ ? find(
117
+ bookmarkGroups,
118
+ d => (d.bookmarkIds || []).includes(toId)
119
+ )
120
+ : find(
121
+ bookmarkGroups,
122
+ d => d.id === toId
123
+ )
124
+ )
125
+ }
126
+ let nodeIndex = 0
127
+ if (toGroup) {
128
+ const pool = toLeaf
129
+ ? toGroup.bookmarkIds || []
130
+ : toGroup.bookmarkGroupIds || []
131
+ nodeIndex = dropToGap
132
+ ? findIndex(pool, d => d === toId)
133
+ : pool.length
134
+ if (dropToGap) {
135
+ if (fromLeaf) {
136
+ nodeIndex = dropPosition < last(toPoses)
137
+ ? nodeIndex - 1
138
+ : nodeIndex + 1
139
+ } else {
140
+ nodeIndex = dropPosition < last(toPoses)
141
+ ? nodeIndex
142
+ : nodeIndex + 1
143
+ }
144
+ }
145
+ } else {
146
+ nodeIndex = findIndex(bookmarkGroups, d => {
147
+ return d.id === toId
148
+ })
149
+ if (fromLeaf) {
150
+ nodeIndex = dropPosition < last(toPoses)
151
+ ? nodeIndex - 1
152
+ : nodeIndex + 1
153
+ } else {
154
+ nodeIndex = dropPosition < last(toPoses)
155
+ ? nodeIndex
156
+ : nodeIndex + 1
157
+ }
158
+ }
159
+ if (nodeIndex < 0) {
160
+ nodeIndex = 0
161
+ }
162
+ let fromIndex = 0
163
+ if (!fromLeaf) {
164
+ from.level = toFirstLevel ? 1 : 2
165
+ }
166
+ const updates = []
167
+ if (toFirstLevel) {
168
+ fromIndex = findIndex(bookmarkGroups, d => d.id === fromId)
169
+ from = copy(from)
170
+ bookmarkGroups.splice(fromIndex, 1, 'tobedel')
171
+ bookmarkGroups.splice(nodeIndex, 0, from)
172
+ remove(bookmarkGroups, d => d === 'tobedel')
173
+ if (fromGroup) {
174
+ remove(fromGroup.bookmarkGroupIds, d => d === fromId)
175
+ }
176
+ } else if (fromGroup) {
177
+ const arr = fromLeaf
178
+ ? fromGroup.bookmarkIds
179
+ : fromGroup.bookmarkGroupIds
180
+ fromIndex = findIndex(arr, d => d === fromId)
181
+ isSameCat
182
+ ? arr.splice(fromIndex, 1, 'tobedel')
183
+ : remove(arr, d => d === fromId)
184
+ }
185
+ if (!toFirstLevel) {
186
+ const arr = !fromLeaf
187
+ ? toGroup.bookmarkGroupIds
188
+ : toGroup.bookmarkIds
189
+ arr.splice(nodeIndex, 0, fromId)
190
+ if (isSameCat) {
191
+ remove(arr, d => d === 'tobedel')
192
+ }
193
+ }
194
+ if (fromGroup) {
195
+ const { id, ...rest } = fromGroup
196
+ updates.push({
197
+ id,
198
+ db: 'bookmarkGroups',
199
+ update: rest,
200
+ upsert: false
201
+ })
202
+ }
203
+ if (toGroup) {
204
+ const { id, ...rest } = toGroup
205
+ updates.push({
206
+ id,
207
+ db: 'bookmarkGroups',
208
+ update: rest,
209
+ upsert: false
210
+ })
211
+ } else if (from) {
212
+ const { id, ...rest } = from
213
+ updates.push({
214
+ id,
215
+ db: 'bookmarkGroups',
216
+ update: rest,
217
+ upsert: false
218
+ })
219
+ }
220
+ props.store.setBookmarkGroups(bookmarkGroups)
221
+ props.store.batchDbUpdate(updates)
222
+ }
@@ -0,0 +1,163 @@
1
+ /**
2
+ * hisotry/bookmark/setting modal
3
+ */
4
+
5
+ import { Component } from '../common/react-subx'
6
+ import { pick } from 'lodash-es'
7
+ import { Tabs } from 'antd'
8
+ import SettingModal from './setting-wrap'
9
+ import {
10
+ settingMap,
11
+ modals
12
+ } from '../../common/constants'
13
+ import TabBookmarks from './tab-bookmarks'
14
+ import TabHistory from './tab-history'
15
+ import TabQuickCommands from './tab-quick-commands'
16
+ import TabSettings from './tab-settings'
17
+ import TabThemes from './tab-themes'
18
+
19
+ const { prefix } = window
20
+ const m = prefix('common')
21
+ const t = prefix('terminalThemes')
22
+ const q = prefix('quickCommands')
23
+
24
+ export default class SettingModalWrap extends Component {
25
+ selectItem = (item) => {
26
+ const { store } = this.props
27
+ store.setSettingItem(item)
28
+ }
29
+
30
+ renderTabs () {
31
+ const { store } = this.props
32
+ const tabsShouldConfirmDel = [
33
+ settingMap.bookmarks,
34
+ settingMap.terminalThemes
35
+ ]
36
+ const { settingTab, settingItem, settingSidebarList, bookmarkSelectMode } = store
37
+ const props0 = {
38
+ store,
39
+ activeItemId: settingItem.id,
40
+ type: settingTab,
41
+ onClickItem: this.selectItem,
42
+ shouldConfirmDel: tabsShouldConfirmDel.includes(settingTab),
43
+ list: settingSidebarList
44
+ }
45
+ const formProps = {
46
+ store,
47
+ formData: settingItem,
48
+ type: settingTab,
49
+ hide: store.hideSettingModal,
50
+ ...pick(store, [
51
+ 'currentBookmarkGroupId',
52
+ 'config'
53
+ ]),
54
+ bookmarkGroups: store.getBookmarkGroups(),
55
+ bookmarks: store.getBookmarks(),
56
+ serials: store.serials,
57
+ loaddingSerials: store.loaddingSerials
58
+ }
59
+ const treeProps = {
60
+ ...props0,
61
+ bookmarkSelectMode,
62
+ bookmarkGroups: store.getBookmarkGroups(),
63
+ bookmarks: store.getBookmarks(),
64
+ ...pick(store, [
65
+ 'currentBookmarkGroupId',
66
+ 'autofocustrigger',
67
+ 'config'
68
+ ])
69
+ }
70
+ const items = [
71
+ {
72
+ key: settingMap.history,
73
+ label: m(settingMap.history),
74
+ children: null
75
+ },
76
+ {
77
+ key: settingMap.bookmarks,
78
+ label: m(settingMap.bookmarks),
79
+ children: null
80
+ },
81
+ {
82
+ key: settingMap.setting,
83
+ label: m(settingMap.setting),
84
+ children: null
85
+ },
86
+ {
87
+ key: settingMap.terminalThemes,
88
+ label: t('uiThemes'),
89
+ children: null
90
+ },
91
+ {
92
+ key: settingMap.quickCommands,
93
+ label: q(settingMap.quickCommands),
94
+ children: null
95
+ }
96
+ ]
97
+ return (
98
+ <div>
99
+ <Tabs
100
+ activeKey={settingTab}
101
+ animated={false}
102
+ items={items}
103
+ onChange={store.handleChangeSettingTab}
104
+ destroyInactiveTabPane
105
+ className='setting-tabs'
106
+ />
107
+ <TabHistory
108
+ listProps={props0}
109
+ settingItem={settingItem}
110
+ formProps={formProps}
111
+ settingTab={settingTab}
112
+ />
113
+ <TabQuickCommands
114
+ listProps={props0}
115
+ settingItem={settingItem}
116
+ formProps={formProps}
117
+ store={store}
118
+ settingTab={settingTab}
119
+ />
120
+ <TabBookmarks
121
+ treeProps={treeProps}
122
+ settingItem={settingItem}
123
+ formProps={formProps}
124
+ settingTab={settingTab}
125
+ />
126
+ <TabSettings
127
+ listProps={props0}
128
+ settingItem={settingItem}
129
+ settingTab={settingTab}
130
+ store={store}
131
+ />
132
+ <TabThemes
133
+ listProps={props0}
134
+ settingItem={settingItem}
135
+ formProps={formProps}
136
+ store={store}
137
+ settingTab={settingTab}
138
+ />
139
+ </div>
140
+ )
141
+ }
142
+
143
+ render () {
144
+ const {
145
+ showModal,
146
+ hideSettingModal,
147
+ innerWidth
148
+ } = this.props.store
149
+ const show = showModal === modals.setting
150
+ if (!show) {
151
+ return null
152
+ }
153
+ return (
154
+ <SettingModal
155
+ onCancel={hideSettingModal}
156
+ visible={show}
157
+ innerWidth={innerWidth}
158
+ >
159
+ {this.renderTabs()}
160
+ </SettingModal>
161
+ )
162
+ }
163
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * settings page
3
+ */
4
+
5
+ import { Component } from 'react'
6
+ import { Drawer } from 'antd'
7
+ import { CloseCircleOutlined } from '@ant-design/icons'
8
+ import { sidebarWidth } from '../../common/constants'
9
+ import './setting-wrap.styl'
10
+
11
+ export default class SettingWrap extends Component {
12
+ render () {
13
+ const pops = {
14
+ open: this.props.visible,
15
+ onClose: this.props.onCancel,
16
+ className: 'setting-wrap',
17
+ width: this.props.innerWidth - sidebarWidth,
18
+ zIndex: 888,
19
+ placement: 'left',
20
+ destroyOnClose: true,
21
+ headerStyle: {
22
+ display: 'none'
23
+ }
24
+ }
25
+ return (
26
+ <Drawer
27
+ {...pops}
28
+ >
29
+ <CloseCircleOutlined
30
+ className='close-setting-wrap'
31
+ onClick={this.props.onCancel}
32
+ />
33
+ {this.props.visible ? this.props.children : null}
34
+ </Drawer>
35
+ )
36
+ }
37
+ }
@@ -0,0 +1,52 @@
1
+ @require '../../css/includes/theme-default'
2
+
3
+ .setting-wrap
4
+ color text
5
+
6
+ body .ant-drawer .ant-drawer-content-wrapper
7
+ left 43px
8
+ // .setting-wrap-hide
9
+ // width 0
10
+ // border-left-width 0
11
+ .close-setting-wrap
12
+ position absolute
13
+ left 20px
14
+ top 70px
15
+ font-size 16px
16
+ color text
17
+ cursor pointer
18
+ z-index 889
19
+ &:hover
20
+ color text
21
+ .setting-row
22
+ position absolute
23
+ top 127px
24
+ overflow-y scroll
25
+ .setting-row-left
26
+ left 0
27
+ width 340px
28
+ bottom 0
29
+ padding 20px 0 20px 20px
30
+ .ant-tree
31
+ background none
32
+ .setting-row-right
33
+ left 340px
34
+ right 0
35
+ bottom 0
36
+ top 129px
37
+ padding 20px
38
+ .setting-tabs-bookmarks
39
+ .setting-row-left
40
+ width 440px
41
+ .setting-row-right
42
+ left 483px
43
+ .setting-tabs
44
+ position absolute
45
+ z-index 4
46
+ left 0
47
+ top 0
48
+ right 0
49
+ padding 55px 20px 0 50px
50
+ .setting-col
51
+ ::-webkit-scrollbar
52
+ width 0