@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,93 @@
1
+ /**
2
+ * transporter UI component
3
+ */
4
+ import { useRef, useEffect } from 'react'
5
+ import Transport from './transport-action'
6
+ import postMessage from '../../common/post-msg'
7
+ import { transportTypes } from './transport-types'
8
+
9
+ export default function TransportsUI (props) {
10
+ const {
11
+ transferList
12
+ } = props
13
+ const timer = useRef(null)
14
+ function onDestroy () {
15
+ clearTimeout(timer.current)
16
+ }
17
+ useEffect(() => {
18
+ return onDestroy
19
+ }, [])
20
+ const pauseAll = () => {
21
+ props.modifier({
22
+ pauseAll: true
23
+ })
24
+ postMessage({
25
+ action: transportTypes.pauseTransport,
26
+ ids: []
27
+ })
28
+ }
29
+ const resumeAll = () => {
30
+ props.modifier({
31
+ pauseAll: false
32
+ })
33
+ postMessage({
34
+ action: transportTypes.resumeTransport,
35
+ ids: []
36
+ })
37
+ }
38
+ const pauseOrResumeAll = () => {
39
+ if (props.pauseAll) {
40
+ return resumeAll()
41
+ }
42
+ return pauseAll()
43
+ }
44
+ const cancelAll = () => {
45
+ props.modifier({
46
+ pauseAll: false
47
+ })
48
+ postMessage({
49
+ action: transportTypes.cancelTransport,
50
+ ids: []
51
+ }, '*')
52
+ }
53
+
54
+ function onMessage (e) {
55
+ const action = e?.data?.action
56
+ const id = e?.data?.id
57
+ if (id === props.sessionId || id === 'all') {
58
+ switch (action) {
59
+ case transportTypes.cancelAll:
60
+ cancelAll()
61
+ break
62
+ case transportTypes.pauseOrResumeAll:
63
+ pauseOrResumeAll()
64
+ break
65
+ default:
66
+ break
67
+ }
68
+ }
69
+ }
70
+ function initEvent () {
71
+ window.addEventListener('message', onMessage)
72
+ }
73
+ function destroyEvents () {
74
+ window.removeEventListener('message', onMessage)
75
+ }
76
+ useEffect(() => {
77
+ initEvent()
78
+ return destroyEvents
79
+ }, [])
80
+ if (!transferList.length) {
81
+ return null
82
+ }
83
+ return transferList.map((t, i) => {
84
+ const { id } = t
85
+ return (
86
+ <Transport
87
+ {...props}
88
+ transfer={t}
89
+ key={id + ':tr:' + i}
90
+ />
91
+ )
92
+ })
93
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * zip/unzip remote files
3
+ * should only support linux server
4
+ */
5
+
6
+ import { runCmd } from '../terminal/terminal-apis'
7
+ import { getFolderFromFilePath } from './file-read'
8
+ import resolve from '../../common/resolve'
9
+ import generate from '../../common/uid'
10
+
11
+ const isRemote = true
12
+ const temp = '/tmp'
13
+
14
+ export async function zipCmd (pid, sessionId, filePath) {
15
+ // tar -czf bin.tar.gz bin
16
+ const id = generate()
17
+ const { path, name } = getFolderFromFilePath(filePath, isRemote)
18
+ const np = resolve(temp, `electerm-${id}.tar.gz`)
19
+ const cmd = `tar -C ${path} -czf ${np} ${name}`
20
+ await runCmd(pid, sessionId, cmd)
21
+ return np
22
+ }
23
+
24
+ export function unzipCmd (pid, sessionId, from, to) {
25
+ const cmd = `tar -xzf "${from}" -C "${to}"`
26
+ return runCmd(pid, sessionId, cmd)
27
+ }
28
+
29
+ export async function rmCmd (pid, sessionId, path) {
30
+ const cmd = `rm -rf "${path}"`
31
+ return runCmd(pid, sessionId, cmd)
32
+ }
33
+
34
+ export async function mvCmd (pid, sessionId, from, to) {
35
+ const cmd = `mv "${from}" "${to}"`
36
+ return runCmd(pid, sessionId, cmd)
37
+ }
38
+
39
+ export async function mkdirCmd (pid, sessionId, p) {
40
+ const cmd = `mkdir "${p}"`
41
+ return runCmd(pid, sessionId, cmd)
42
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * history select
3
+ */
4
+
5
+ import { Component } from '../common/react-subx'
6
+ import TreeList from '../setting-panel/tree-list'
7
+
8
+ export default class BookmarkSelect extends Component {
9
+ render () {
10
+ const { store, from } = this.props
11
+ const {
12
+ listStyle,
13
+ openedSideBar,
14
+ expandedKeys
15
+ } = store
16
+ if (from === 'sidebar' && openedSideBar !== 'bookmarks') {
17
+ return null
18
+ }
19
+ const onClickItem = (item) => {
20
+ if (!store.pinned) {
21
+ store.setOpenedSideBar('')
22
+ }
23
+ store.onSelectBookmark(item.id)
24
+ }
25
+ const base = {
26
+ store,
27
+ bookmarks: [
28
+ ...(store.getBookmarks() || []),
29
+ ...store.sshConfigItems
30
+ ],
31
+ type: 'bookmarks',
32
+ onClickItem,
33
+ listStyle,
34
+ staticList: true
35
+ }
36
+ const propsTree = {
37
+ ...base,
38
+ shouldConfirmDel: true,
39
+ bookmarkGroups: store.getBookmarkGroupsTotal(),
40
+ expandedKeys
41
+ }
42
+ return (
43
+ <TreeList
44
+ {...propsTree}
45
+ />
46
+ )
47
+ }
48
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * history select
3
+ */
4
+
5
+ import { Component } from '../common/react-subx'
6
+ import BookmarkSelect from './bookmark-select'
7
+ import { pick } from 'lodash-es'
8
+ import { ArrowsAltOutlined, EditOutlined, PlusCircleOutlined, ShrinkOutlined, PushpinOutlined } from '@ant-design/icons'
9
+ import { Tooltip } from 'antd'
10
+
11
+ const { prefix } = window
12
+ const c = prefix('common')
13
+ const m = prefix('menu')
14
+ const e = prefix('control')
15
+
16
+ export default class BookmarkPanel extends Component {
17
+ render () {
18
+ const { props } = this
19
+ const { store } = props
20
+ const prps = {
21
+ className: 'font16 mg1x mg2l pointer iblock control-icon'
22
+ }
23
+ const prps1 = {
24
+ className: prps.className + (store.pinned ? ' pinned' : '')
25
+ }
26
+ const pop1 = {
27
+ ...prps,
28
+ onClick: store.onNewSsh
29
+ }
30
+ const pop2 = {
31
+ ...prps,
32
+ onClick: store.expandBookmarks
33
+ }
34
+ const pop3 = {
35
+ ...prps,
36
+ onClick: store.collapseBookmarks
37
+ }
38
+ return (
39
+ <div
40
+ className='sidebar-panel bookmarks-panel animate-fast'
41
+ {...pick(props, ['onMouseEnter', 'onMouseLeave'])}
42
+ >
43
+ <div className='pd1y pd2t pd2x'>
44
+ <div className='fix'>
45
+ <div className='fleft'>{c('bookmarks')}</div>
46
+ <div className='fright'>
47
+ <Tooltip title={e('newBookmark')}>
48
+ <PlusCircleOutlined
49
+ {...pop1}
50
+ />
51
+ </Tooltip>
52
+ <Tooltip title={`${m('edit')} ${c('bookmarks')}`}>
53
+ <EditOutlined
54
+ {...pop1}
55
+ />
56
+ </Tooltip>
57
+ <Tooltip title={c('expandAll')}>
58
+ <ArrowsAltOutlined
59
+ {...pop2}
60
+ />
61
+ </Tooltip>
62
+ <Tooltip title={c('collapseAll')}>
63
+ <ShrinkOutlined
64
+ {...pop3}
65
+ />
66
+ </Tooltip>
67
+ <Tooltip title={c('pin')}>
68
+ <PushpinOutlined
69
+ {...prps1}
70
+ onClick={store.handlePin}
71
+ />
72
+ </Tooltip>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ <div className='pd2x'>
77
+ <BookmarkSelect store={store} from='sidebar' />
78
+ </div>
79
+ </div>
80
+ )
81
+ }
82
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * history select
3
+ */
4
+
5
+ import { Component } from '../common/react-subx'
6
+ import ItemList from '../setting-panel/list'
7
+ import { pick } from 'lodash-es'
8
+ import { EditOutlined, PushpinOutlined } from '@ant-design/icons'
9
+ import { Tooltip } from 'antd'
10
+
11
+ const { prefix } = window
12
+ const c = prefix('common')
13
+ const m = prefix('menu')
14
+
15
+ export default class HistoryPanel extends Component {
16
+ render () {
17
+ const { props } = this
18
+ const { store } = props
19
+ const {
20
+ openedSideBar
21
+ } = store
22
+ if (openedSideBar !== 'history') {
23
+ return null
24
+ }
25
+ const prps = {
26
+ className: 'font16 mg1x mg2l pointer iblock control-icon'
27
+ }
28
+ const prps1 = {
29
+ className: prps.className + (store.pinned ? ' pinned' : '')
30
+ }
31
+ return (
32
+ <div
33
+ className='sidebar-panel history-panel animate-fast'
34
+ {...pick(props, ['onMouseEnter', 'onMouseLeave'])}
35
+ >
36
+ <div className='pd1y pd2t pd2x'>
37
+ <div className='fix'>
38
+ <div className='fleft'>{c('history')}</div>
39
+ <div className='fleft'>
40
+ <Tooltip title={`${m('edit')} ${c('history')}`}>
41
+ <EditOutlined
42
+ className='font16 mg1x mg2l pointer iblock control-icon icon-do-edit'
43
+ onClick={store.handleEditHistory}
44
+ />
45
+ </Tooltip>
46
+ <Tooltip title={c('pin')}>
47
+ <PushpinOutlined
48
+ {...prps1}
49
+ onClick={store.handlePin}
50
+ />
51
+ </Tooltip>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ <div className='pd2x'>
56
+ <ItemList
57
+ type='history'
58
+ list={store.history || []}
59
+ onClickItem={item => store.onSelectHistory(item.id)}
60
+ activeItemId={store.activeItemId}
61
+ />
62
+ </div>
63
+ </div>
64
+ )
65
+ }
66
+ }
@@ -0,0 +1,230 @@
1
+ import {
2
+ BookOutlined,
3
+ ClockCircleOutlined,
4
+ CloudSyncOutlined,
5
+ InfoCircleOutlined,
6
+ PictureOutlined,
7
+ PlusCircleOutlined,
8
+ SettingOutlined,
9
+ UpCircleOutlined,
10
+ BarsOutlined
11
+ } from '@ant-design/icons'
12
+
13
+ import { Tooltip } from 'antd'
14
+ import { Component } from '../common/react-subx'
15
+ import BookMarksWrap from './bookmark'
16
+ import HistoryWrap from './history'
17
+ import TransferList from './transfer-list'
18
+ import MenuBtn from '../context-menu/menu-btn'
19
+ import InfoModal from './info-modal'
20
+ import {
21
+ sidebarWidth,
22
+ settingMap,
23
+ modals
24
+ } from '../../common/constants'
25
+ import SideIcon from './side-icon'
26
+ import './sidebar.styl'
27
+
28
+ const { prefix } = window
29
+ const e = prefix('control')
30
+ const c = prefix('common')
31
+ const m = prefix('menu')
32
+ const t = prefix('terminalThemes')
33
+ const u = prefix('updater')
34
+ const ss = prefix('settingSync')
35
+ const b = prefix('batchOp')
36
+
37
+ export default class Sidebar extends Component {
38
+ handler = null
39
+
40
+ handleMouseLeave = () => {
41
+ if (this.props.store.pinned) {
42
+ return false
43
+ }
44
+ const interval = 400
45
+ this.handler = setTimeout(
46
+ () => this.props.store.setOpenedSideBar(''),
47
+ interval
48
+ )
49
+ }
50
+
51
+ handleMouseEnterBookmark = () => {
52
+ if (this.props.store.pinned) {
53
+ return false
54
+ }
55
+ clearTimeout(this.handler)
56
+ this.props.store.setOpenedSideBar('bookmarks')
57
+ }
58
+
59
+ handleMouseEnterHistory = () => {
60
+ if (this.props.store.pinned) {
61
+ return false
62
+ }
63
+ clearTimeout(this.handler)
64
+ this.props.store.setOpenedSideBar('history')
65
+ }
66
+
67
+ handleShowUpgrade = () => {
68
+ this.props.store.storeAssign({
69
+ _upgradeInfo: JSON.stringify({
70
+ ...this.props.store.upgradeInfo,
71
+ showUpgradeModal: true
72
+ })
73
+ })
74
+ }
75
+
76
+ render () {
77
+ const { store } = this.props
78
+ const {
79
+ openedSideBar,
80
+ onNewSsh,
81
+ openSetting,
82
+ openAbout,
83
+ openSettingSync,
84
+ height,
85
+ openTerminalThemes,
86
+ upgradeInfo,
87
+ onClickBookmark,
88
+ onClickHistory,
89
+ toggleBatchOp,
90
+ settingTab,
91
+ showModal,
92
+ showInfoModal,
93
+ settingItem,
94
+ isSyncingSetting
95
+ } = store
96
+ const {
97
+ showUpgradeModal,
98
+ upgradePercent,
99
+ checkingRemoteVersion,
100
+ shouldUpgrade
101
+ } = upgradeInfo
102
+ const showSetting = showModal === modals.setting
103
+ const showBatchOp = showModal === modals.batchOps
104
+ const settingActive = showSetting && settingTab === settingMap.setting && settingItem.id === 'setting-common'
105
+ const syncActive = showSetting && settingTab === settingMap.setting && settingItem.id === 'setting-sync'
106
+ const themeActive = showSetting && settingTab === settingMap.terminalThemes
107
+ const historyActive = showSetting && settingTab === settingMap.history
108
+ const bookmarksActive = showSetting && settingTab === settingMap.bookmarks
109
+ return (
110
+ <div
111
+ className={`sidebar type-${openedSideBar}`}
112
+ style={{
113
+ width: sidebarWidth,
114
+ height
115
+ }}
116
+ >
117
+ <div className='sidebar-bar btns'>
118
+ <div className='control-icon-wrap'>
119
+ <MenuBtn store={store} />
120
+ </div>
121
+ <SideIcon
122
+ title={e('newBookmark')}
123
+ >
124
+ <PlusCircleOutlined
125
+ className='font22 iblock control-icon'
126
+ onClick={onNewSsh}
127
+ />
128
+ </SideIcon>
129
+ <SideIcon
130
+ title={c(settingMap.bookmarks)}
131
+ active={bookmarksActive}
132
+ >
133
+ <BookOutlined
134
+ onMouseEnter={this.handleMouseEnterBookmark}
135
+ onMouseLeave={this.handleMouseLeave}
136
+ onClick={onClickBookmark}
137
+ className='font20 iblock control-icon'
138
+ />
139
+ </SideIcon>
140
+ <SideIcon
141
+ title={c(settingMap.history)}
142
+ active={historyActive}
143
+ >
144
+ <ClockCircleOutlined
145
+ onMouseEnter={this.handleMouseEnterHistory}
146
+ onMouseLeave={this.handleMouseLeave}
147
+ onClick={onClickHistory}
148
+ className='font20 iblock control-icon'
149
+ />
150
+ </SideIcon>
151
+ <TransferList store={store} />
152
+ <SideIcon
153
+ title={t(settingMap.terminalThemes)}
154
+ active={themeActive}
155
+ >
156
+ <PictureOutlined
157
+ className='font20 iblock pointer control-icon'
158
+ onClick={openTerminalThemes}
159
+ />
160
+ </SideIcon>
161
+ <SideIcon
162
+ title={c(settingMap.setting)}
163
+ active={settingActive}
164
+ >
165
+ <SettingOutlined className='iblock font20 control-icon' onClick={openSetting} />
166
+ </SideIcon>
167
+ <SideIcon
168
+ title={ss('settingSync')}
169
+ active={syncActive}
170
+ >
171
+ <CloudSyncOutlined
172
+ className='iblock font20 control-icon'
173
+ onClick={openSettingSync}
174
+ spin={isSyncingSetting}
175
+ />
176
+ </SideIcon>
177
+ <SideIcon
178
+ title={b('batchOp')}
179
+ active={showBatchOp}
180
+ >
181
+ <BarsOutlined className='iblock font20 control-icon' onClick={toggleBatchOp} />
182
+ </SideIcon>
183
+ <SideIcon
184
+ title={m('about')}
185
+ active={showInfoModal}
186
+ >
187
+ <InfoCircleOutlined
188
+ className='iblock font16 control-icon open-about-icon'
189
+ onClick={openAbout}
190
+ />
191
+ </SideIcon>
192
+ {
193
+ !checkingRemoteVersion && !showUpgradeModal && shouldUpgrade
194
+ ? (
195
+ <Tooltip
196
+ title={`${u('upgrading')} ${upgradePercent || 0}%`}
197
+ placement='right'
198
+ >
199
+ <div
200
+ className='control-icon-wrap'
201
+ >
202
+ <UpCircleOutlined
203
+ className='iblock font18 control-icon hvr-bob upgrade-icon'
204
+ onClick={this.handleShowUpgrade}
205
+ />
206
+ </div>
207
+ </Tooltip>
208
+ )
209
+ : null
210
+ }
211
+ </div>
212
+ <InfoModal store={store} />
213
+ <div
214
+ className='sidebar-list'
215
+ >
216
+ <BookMarksWrap
217
+ store={store}
218
+ onMouseEnter={this.handleMouseEnterBookmark}
219
+ onMouseLeave={this.handleMouseLeave}
220
+ />
221
+ <HistoryWrap
222
+ store={store}
223
+ onMouseEnter={this.handleMouseEnterHistory}
224
+ onMouseLeave={this.handleMouseLeave}
225
+ />
226
+ </div>
227
+ </div>
228
+ )
229
+ }
230
+ }