@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,533 @@
1
+ /**
2
+ * terminal/sftp wrapper
3
+ */
4
+ import { Component } from 'react'
5
+ import Term from '../terminal'
6
+ import Sftp from '../sftp/sftp-entry'
7
+ import {
8
+ BorderVerticleOutlined,
9
+ BorderHorizontalOutlined,
10
+ CloseSquareFilled,
11
+ SearchOutlined,
12
+ FullscreenOutlined
13
+ } from '@ant-design/icons'
14
+ import { Tooltip } from 'antd'
15
+ import { last, findIndex, pick } from 'lodash-es'
16
+ import generate from '../../common/uid'
17
+ import copy from 'json-deep-copy'
18
+ import classnames from 'classnames'
19
+ import {
20
+ quickCommandBoxHeight,
21
+ terminalSplitDirectionMap,
22
+ termControlHeight,
23
+ paneMap,
24
+ ctrlOrCmd,
25
+ footerHeight,
26
+ terminalActions,
27
+ connectionMap
28
+ } from '../../common/constants'
29
+ import ResizeWrap from '../common/resize-wrap'
30
+ import keyControlPressed from '../../common/key-control-pressed'
31
+ import keyPressed from '../../common/key-pressed'
32
+ import safeName from '../../common/safe-name'
33
+ import TerminalInfoContent from '../terminal-info/content'
34
+ import uid from '../../common/id-with-stamp'
35
+ import postMessage from '../../common/post-msg'
36
+ import './session.styl'
37
+
38
+ const rebuildPosition = terminals => {
39
+ const indexs = terminals.map(t => t.position).sort((a, b) => a - b)
40
+ const indexMap = indexs.reduce((prev, pos, index) => {
41
+ return {
42
+ ...prev,
43
+ [pos]: index * 10
44
+ }
45
+ }, {})
46
+ return terminals.map(t => {
47
+ return {
48
+ ...t,
49
+ position: indexMap[t.position]
50
+ }
51
+ })
52
+ }
53
+
54
+ const getPrevTerminal = terminals => {
55
+ return last(terminals)
56
+ }
57
+
58
+ const { prefix } = window
59
+ const e = prefix('ssh')
60
+ const m = prefix('menu')
61
+
62
+ export default class SessionWrapper extends Component {
63
+ constructor (props) {
64
+ super(props)
65
+ const id = uid()
66
+ const {
67
+ terminals = [
68
+ {
69
+ id,
70
+ position: 0
71
+ }
72
+ ]
73
+ } = props.tab
74
+ const activeSplitId = terminals[0].id
75
+ this.state = {
76
+ pid: null,
77
+ enableSftp: false,
78
+ splitDirection: terminalSplitDirectionMap.horizontal,
79
+ activeSplitId,
80
+ key: Math.random(),
81
+ sessionOptions: null,
82
+ sessionId: generate(),
83
+ terminals,
84
+ showInfo: false,
85
+ infoPanelProps: {}
86
+ }
87
+ }
88
+
89
+ componentDidMount () {
90
+ this.updateTab()
91
+ this.initEvent()
92
+ }
93
+
94
+ componentWillUnmount () {
95
+ this.destroyEvent()
96
+ }
97
+
98
+ initEvent () {
99
+ window.addEventListener('keydown', this.handleEvent)
100
+ }
101
+
102
+ destroyEvent () {
103
+ window.removeEventListener('keydown', this.handleEvent)
104
+ }
105
+
106
+ isActive () {
107
+ const {
108
+ tab,
109
+ currentTabId
110
+ } = this.props
111
+ return currentTabId === tab.id &&
112
+ tab.pane === paneMap.terminal
113
+ }
114
+
115
+ handleEvent = (e) => {
116
+ if (!this.isActive()) {
117
+ return
118
+ }
119
+ if (keyControlPressed(e) && keyPressed(e, '/')) {
120
+ this.handleSplit()
121
+ }
122
+ }
123
+
124
+ handleShowInfo = (infoPanelProps) => {
125
+ this.setState({
126
+ showInfo: true,
127
+ infoPanelProps
128
+ })
129
+ }
130
+
131
+ hideInfoPanel = () => {
132
+ this.setState({
133
+ showInfo: false
134
+ })
135
+ }
136
+
137
+ computeHeight = () => {
138
+ const {
139
+ pinnedQuickCommandBar,
140
+ tabsHeight
141
+ } = this.props
142
+ return this.props.height -
143
+ tabsHeight -
144
+ footerHeight -
145
+ termControlHeight -
146
+ (pinnedQuickCommandBar ? quickCommandBoxHeight : 0)
147
+ }
148
+
149
+ editTab = (up) => {
150
+ const {
151
+ tab,
152
+ editTab
153
+ } = this.props
154
+ editTab(
155
+ tab.id,
156
+ up
157
+ )
158
+ }
159
+
160
+ onChangePane = pane => {
161
+ const update = {
162
+ pane
163
+ }
164
+ if (pane === paneMap.fileManager) {
165
+ this.setState({
166
+ enableSftp: true
167
+ })
168
+ }
169
+ this.editTab(update)
170
+ }
171
+
172
+ setSessionState = data => {
173
+ this.setState(data)
174
+ if (data.pid) {
175
+ this.editTab({
176
+ pid: data.pid
177
+ })
178
+ }
179
+ }
180
+
181
+ handleSplit = (e, id) => {
182
+ let terminals = copy(this.state.terminals)
183
+ let index = findIndex(terminals, t => t.id === id)
184
+ if (index === -1) {
185
+ index = terminals.length
186
+ } else {
187
+ index = index + 1
188
+ }
189
+ terminals.push({
190
+ id: uid(),
191
+ position: terminals[index - 1].position + 5
192
+ })
193
+ terminals = rebuildPosition(terminals)
194
+ this.setState({
195
+ terminals
196
+ }, this.updateTab)
197
+ }
198
+
199
+ updateTab = () => {
200
+ const terminals = copy(this.state.terminals)
201
+ this.editTab(
202
+ {
203
+ sessionId: this.state.sessionId,
204
+ terminals
205
+ }
206
+ )
207
+ }
208
+
209
+ delSplit = (splitId = this.state.activeSplitId) => {
210
+ const { terminals } = this.state
211
+ let newTerms = terminals.filter(t => t.id !== splitId)
212
+ if (!newTerms.length) {
213
+ return this.props.delTab(
214
+ this.props.tab.id
215
+ )
216
+ }
217
+ newTerms = rebuildPosition(newTerms)
218
+ const newActiveId = getPrevTerminal(newTerms).id
219
+ this.setState({
220
+ terminals: newTerms,
221
+ activeSplitId: newActiveId
222
+ }, this.updateTab)
223
+ window.store.focus()
224
+ }
225
+
226
+ handleChangeDirection = () => {
227
+ const { splitDirection } = this.state
228
+ this.setState({
229
+ splitDirection: splitDirection === terminalSplitDirectionMap.horizontal
230
+ ? terminalSplitDirectionMap.vertical
231
+ : terminalSplitDirectionMap.horizontal
232
+ })
233
+ }
234
+
235
+ setActive = activeSplitId => {
236
+ const up = {
237
+ activeSplitId
238
+ }
239
+ this.setState(up)
240
+ }
241
+
242
+ computePosition = (index) => {
243
+ const len = this.state.terminals.length || 1
244
+ const { width: windowWidth } = this.props
245
+ const { splitDirection } = this.state
246
+ const isHori = splitDirection === terminalSplitDirectionMap.horizontal
247
+ const heightAll = this.computeHeight()
248
+ const width = isHori
249
+ ? windowWidth / len
250
+ : windowWidth
251
+ const height = isHori
252
+ ? heightAll
253
+ : heightAll / len
254
+ const left = isHori
255
+ ? index * width
256
+ : 0
257
+ const top = isHori
258
+ ? 0
259
+ : index * height
260
+ return {
261
+ height,
262
+ width,
263
+ left,
264
+ top
265
+ }
266
+ }
267
+
268
+ renderTerminals = () => {
269
+ const {
270
+ terminals,
271
+ activeSplitId,
272
+ splitDirection,
273
+ sessionOptions,
274
+ sessionId
275
+ } = this.state
276
+ const {
277
+ pane
278
+ } = this.props.tab
279
+ const cls = pane === paneMap.terminal
280
+ ? 'terms-box'
281
+ : 'terms-box hide'
282
+ const height = this.computeHeight()
283
+ const { width, tab } = this.props
284
+ const themeConfig = copy(window.store.getThemeConfig())
285
+ return (
286
+ <div
287
+ className={cls}
288
+ style={{
289
+ width,
290
+ height
291
+ }}
292
+ >
293
+ <ResizeWrap
294
+ direction={splitDirection}
295
+ tab={tab}
296
+ >
297
+ {
298
+ terminals.map((t, index) => {
299
+ const logName = safeName(`${tab.title ? tab.title + '_' : ''}${tab.host ? tab.host + '_' : ''}${t.id}`)
300
+ const pops = {
301
+ ...this.props,
302
+ ...t,
303
+ activeSplitId,
304
+ themeConfig,
305
+ pane,
306
+ ...pick(
307
+ this,
308
+ [
309
+ 'setActive',
310
+ 'handleSplit',
311
+ 'delSplit',
312
+ 'setSessionState',
313
+ 'handleShowInfo',
314
+ 'onChangePane',
315
+ 'hideInfoPanel'
316
+ ]),
317
+ ...this.computePosition(t.position / 10)
318
+ }
319
+ return (
320
+ <Term
321
+ key={t.id}
322
+ logName={logName}
323
+ sessionId={sessionId}
324
+ terminalIndex={index}
325
+ sessionOptions={sessionOptions}
326
+ {...pops}
327
+ />
328
+ )
329
+ })
330
+ }
331
+ </ResizeWrap>
332
+ </div>
333
+ )
334
+ }
335
+
336
+ renderSftp = () => {
337
+ const { sessionOptions, sessionId, pid, enableSftp } = this.state
338
+ const { pane } = this.props.tab
339
+ const height = this.computeHeight()
340
+ const cls = pane === paneMap.terminal
341
+ ? 'hide'
342
+ : ''
343
+ return (
344
+ <div className={cls}>
345
+ <Sftp
346
+ pid={pid}
347
+ enableSftp={enableSftp}
348
+ sessionOptions={sessionOptions}
349
+ height={height}
350
+ sessionId={sessionId}
351
+ pane={pane}
352
+ {...this.props}
353
+ />
354
+ </div>
355
+ )
356
+ }
357
+
358
+ handleFullscreen = () => {
359
+ window.store.toggleTermFullscreen(true)
360
+ }
361
+
362
+ handleOpenSearch = () => {
363
+ postMessage({
364
+ action: terminalActions.openTerminalSearch,
365
+ activeSplitId: this.state.activeSplitId
366
+ })
367
+ }
368
+
369
+ renderSearchIcon = () => {
370
+ const title = e('search')
371
+ return (
372
+ <Tooltip title={title}>
373
+ <SearchOutlined
374
+ className='mg1r icon-info font16 iblock pointer spliter'
375
+ onClick={this.handleOpenSearch}
376
+ />
377
+ </Tooltip>
378
+ )
379
+ }
380
+
381
+ fullscreenIcon = () => {
382
+ const title = e('fullscreen')
383
+ return (
384
+ <Tooltip title={title}>
385
+ <FullscreenOutlined
386
+ className='mg1r icon-info font16 iblock pointer spliter'
387
+ onClick={this.handleFullscreen}
388
+ />
389
+ </Tooltip>
390
+ )
391
+ }
392
+
393
+ renderControl = () => {
394
+ const { splitDirection, terminals } = this.state
395
+ const { props } = this
396
+ const { pane } = props.tab
397
+ const termType = props.tab?.type
398
+ const isSsh = props.tab.authType
399
+ const isLocal = termType === connectionMap.local || !termType
400
+ const isHori = splitDirection === terminalSplitDirectionMap.horizontal
401
+ const cls1 = 'mg1r icon-split pointer iblock spliter'
402
+ const cls2 = 'icon-direction pointer iblock spliter'
403
+ const Icon1 = isHori
404
+ ? BorderHorizontalOutlined
405
+ : BorderVerticleOutlined
406
+ const Icon2 = !isHori
407
+ ? BorderHorizontalOutlined
408
+ : BorderVerticleOutlined
409
+ const hide = terminals.length < 2
410
+ const types = [
411
+ paneMap.terminal,
412
+ paneMap.fileManager
413
+ ]
414
+ const controls = [
415
+ isSsh ? paneMap.ssh : paneMap.terminal
416
+ ]
417
+ if (isSsh || isLocal) {
418
+ controls.push(isSsh ? paneMap.sftp : paneMap.fileManager)
419
+ }
420
+ return (
421
+ <div
422
+ className='terminal-control fix'
423
+ >
424
+ <div className='term-sftp-tabs fleft'>
425
+ {
426
+ controls.map((type, i) => {
427
+ const cls = classnames(
428
+ 'type-tab',
429
+ type,
430
+ {
431
+ active: types[i] === pane
432
+ }
433
+ )
434
+ return (
435
+ <span
436
+ className={cls}
437
+ key={type + '_' + i}
438
+ onClick={() => this.onChangePane(types[i])}
439
+ >
440
+ {e(type)}
441
+ <span className='type-tab-line' />
442
+ </span>
443
+ )
444
+ })
445
+ }
446
+ </div>
447
+ {
448
+ pane === paneMap.terminal
449
+ ? (
450
+ <div className='fright term-controls'>
451
+ {this.fullscreenIcon()}
452
+ {this.renderSearchIcon()}
453
+ {
454
+ hide
455
+ ? null
456
+ : (
457
+ <CloseSquareFilled
458
+ className='mg1r icon-trash font16 iblock pointer spliter'
459
+ onClick={() => this.delSplit()}
460
+ title={m('del')}
461
+ />
462
+ )
463
+ }
464
+ <Tooltip
465
+ title={`${e('split')}(${ctrlOrCmd} + /)`}
466
+ >
467
+ <Icon1
468
+ className={cls1}
469
+ onClick={this.handleSplit}
470
+ />
471
+ </Tooltip>
472
+ <Tooltip
473
+ title={e('changeDirection')}
474
+ >
475
+ <Icon2
476
+ className={cls2}
477
+ onClick={this.handleChangeDirection}
478
+ />
479
+ </Tooltip>
480
+ </div>
481
+ )
482
+ : null
483
+ }
484
+ </div>
485
+ )
486
+ }
487
+
488
+ render () {
489
+ const {
490
+ splitDirection,
491
+ infoPanelProps,
492
+ showInfo
493
+ } = this.state
494
+ const { pane } = this.props.tab
495
+ const infoProps = {
496
+ ...pick(this.props.config, ['host', 'port', 'saveTerminalLogToFile']),
497
+ ...infoPanelProps,
498
+ appPath: this.props.appPath,
499
+ showInfo,
500
+ tabsHeight: this.props.tabsHeight,
501
+ topMenuHeight: this.props.topMenuHeight,
502
+ // pid,
503
+ // sessionId,
504
+ // isRemote: this.isRemote(),
505
+ // isActive: this.isActiveTerminal(),
506
+ hideInfoPanel: this.hideInfoPanel
507
+ }
508
+ const cls = classnames(
509
+ 'term-sftp-box',
510
+ pane,
511
+ splitDirection,
512
+ {
513
+ 'is-transporting': this.props.tab.isTransporting
514
+ },
515
+ {
516
+ 'disable-ssh': this.props.tab.enableSsh === false
517
+ }
518
+ )
519
+ return (
520
+ <div
521
+ className={cls}
522
+ id={`is-${this.props.tab.id}`}
523
+ >
524
+ {this.renderControl()}
525
+ {this.renderTerminals()}
526
+ {this.renderSftp()}
527
+ <TerminalInfoContent
528
+ {...infoProps}
529
+ />
530
+ </div>
531
+ )
532
+ }
533
+ }
@@ -0,0 +1,53 @@
1
+ @require '../../css/includes/theme-default'
2
+ @keyframes rotate
3
+ from
4
+ background-position -3000px
5
+ to
6
+ background-position 0px
7
+ .type-tab-line
8
+ position absolute
9
+ bottom 0
10
+ left 0
11
+ width 100%
12
+ height 1px
13
+ background text-dark
14
+ display none
15
+
16
+ .type-tab
17
+ position relative
18
+ display inline-block
19
+ vertical-align middle
20
+ line-height 30px
21
+ color text-dark
22
+ margin-right 20px
23
+ font-size 14px
24
+ cursor pointer
25
+ &:hover
26
+ &.active
27
+ color text
28
+ &.active
29
+ .type-tab-line
30
+ display inline-block
31
+ .is-transporting
32
+ .type-tab.sftp
33
+ .type-tab-line
34
+ display inline-block
35
+ background linear-gradient(to right, success 0%, main 25%, error 50%, primary 75%, success 100%)
36
+ animation: rotate 60s infinite linear
37
+ .disable-ssh
38
+ .type-tab.ssh
39
+ display none
40
+ .spliter
41
+ color text
42
+ font-size 16px
43
+ &:hover
44
+ color text-light
45
+
46
+ .session-wrap
47
+ display none
48
+ .session-current
49
+ display block
50
+ .no-sessions
51
+ background main-dark
52
+ text-align center
53
+ padding 50px 0