@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,44 @@
1
+ export default [
2
+ 'utf-8',
3
+ 'gbk',
4
+ 'gb18030',
5
+ 'hz-gb-2312',
6
+ 'big5',
7
+ 'euc-jp',
8
+ 'iso-2022-jp',
9
+ 'shift-jis',
10
+ 'euc-kr',
11
+ 'iso-2022-kr',
12
+ 'utf-16be',
13
+ 'utf-16le',
14
+ 'ibm866',
15
+ 'iso-8859-2',
16
+ 'iso-8859-3',
17
+ 'iso-8859-4',
18
+ 'iso-8859-5',
19
+ 'iso-8859-6',
20
+ 'iso-8859-7',
21
+ 'iso-8859-8',
22
+ 'iso-8859-8i',
23
+ 'iso-8859-10',
24
+ 'iso-8859-13',
25
+ 'iso-8859-14',
26
+ 'iso-8859-15',
27
+ 'iso-8859-16',
28
+ 'koi8-r',
29
+ 'koi8-u',
30
+ 'macintosh',
31
+ 'windows-874',
32
+ 'windows-1250',
33
+ 'windows-1251',
34
+ 'windows-1252',
35
+ 'windows-1253',
36
+ 'windows-1254',
37
+ 'windows-1255',
38
+ 'windows-1256',
39
+ 'windows-1257',
40
+ 'windows-1258',
41
+ 'x-mac-cyrillic',
42
+ 'x-user-defined',
43
+ 'replacement'
44
+ ]
@@ -0,0 +1,208 @@
1
+ /**
2
+ * bookmark form
3
+ */
4
+ import {
5
+ Input,
6
+ InputNumber,
7
+ Radio,
8
+ TreeSelect,
9
+ Select,
10
+ Form
11
+ } from 'antd'
12
+ import {
13
+ authTypeMap
14
+ } from '../../common/constants'
15
+ import { formItemLayout, tailFormItemLayout } from '../../common/form-layout'
16
+ import InputAutoFocus from '../common/input-auto-focus'
17
+ import encodes from './encodes'
18
+ import formatBookmarkGroups from './bookmark-group-tree-format'
19
+ import renderRunScripts from './render-delayed-scripts.jsx'
20
+ import './bookmark-form.styl'
21
+
22
+ const authTypes = Object.keys(authTypeMap).map(k => {
23
+ return k
24
+ })
25
+ const RadioButton = Radio.Button
26
+ const RadioGroup = Radio.Group
27
+ const FormItem = Form.Item
28
+ const { Option } = Select
29
+ const { prefix } = window
30
+ const e = prefix('form')
31
+ const c = prefix('common')
32
+ const sf = prefix('sftp')
33
+
34
+ export default function renderCommon (props) {
35
+ const {
36
+ autofocustrigger,
37
+ bookmarkGroups = [],
38
+ dns,
39
+ form,
40
+ onChangeAuthType
41
+ } = props
42
+ const tree = formatBookmarkGroups(bookmarkGroups)
43
+ return (
44
+ <div>
45
+ <FormItem
46
+ {...formItemLayout}
47
+ label={e('host')}
48
+ hasFeedback
49
+ rules={[{
50
+ max: 520, message: '520 chars max'
51
+ }, {
52
+ required: true, message: 'host required'
53
+ }]}
54
+ normalize={props.trim}
55
+ >
56
+ {
57
+ dns
58
+ ? (
59
+ <div className='dns-section'>
60
+ ip: {dns}
61
+ <span
62
+ className='color-blue pointer mg1l'
63
+ onClick={() => props.useIp(form)}
64
+ >
65
+ {e('use')}
66
+ </span>
67
+ </div>
68
+ )
69
+ : (
70
+ <div className='dns-section'>
71
+ hostname or ip
72
+ </div>
73
+ )
74
+ }
75
+ <FormItem noStyle name='host'>
76
+ <InputAutoFocus
77
+ autofocustrigger={autofocustrigger}
78
+ selectall='yes'
79
+ onBlur={props.onBlur}
80
+ onPaste={e => props.onPaste(e, form)}
81
+ />
82
+ </FormItem>
83
+ </FormItem>
84
+ <FormItem
85
+ {...formItemLayout}
86
+ label={e('username')}
87
+ hasFeedback
88
+ name='username'
89
+ rules={[{
90
+ max: 128, message: '128 chars max'
91
+ }]}
92
+ normalize={props.trim}
93
+ >
94
+ <Input />
95
+ </FormItem>
96
+ <FormItem
97
+ {...tailFormItemLayout}
98
+ className='mg1b'
99
+ name='authType'
100
+ >
101
+ <RadioGroup
102
+ size='small'
103
+ onChange={onChangeAuthType}
104
+ buttonStyle='solid'
105
+ >
106
+ {
107
+ authTypes.map(t => {
108
+ return (
109
+ <RadioButton value={t} key={t}>
110
+ {e(t)}
111
+ </RadioButton>
112
+ )
113
+ })
114
+ }
115
+ </RadioGroup>
116
+ </FormItem>
117
+ {props.renderAuth(props)}
118
+ <FormItem
119
+ {...formItemLayout}
120
+ label={e('port')}
121
+ hasFeedback
122
+ name='port'
123
+ rules={[{
124
+ required: true, message: 'port required'
125
+ }]}
126
+ >
127
+ <InputNumber
128
+ placeholder={e('port')}
129
+ min={1}
130
+ max={65535}
131
+ step={1}
132
+ />
133
+ </FormItem>
134
+ <FormItem
135
+ {...formItemLayout}
136
+ label={c('bookmarkCategory')}
137
+ name='category'
138
+ >
139
+ <TreeSelect
140
+ treeData={tree}
141
+ treeDefaultExpandAll
142
+ showSearch
143
+ />
144
+ </FormItem>
145
+ <FormItem
146
+ {...formItemLayout}
147
+ label={e('title')}
148
+ hasFeedback
149
+ name='title'
150
+ >
151
+ <Input />
152
+ </FormItem>
153
+ <FormItem
154
+ {...formItemLayout}
155
+ label={e('description')}
156
+ name='description'
157
+ hasFeedback
158
+ >
159
+ <Input.TextArea rows={1} />
160
+ </FormItem>
161
+ <FormItem
162
+ {...formItemLayout}
163
+ name='setEnv'
164
+ label='SetEnv'
165
+ >
166
+ <Input placeholder='SEC=xxx BEC=xxxx' />
167
+ </FormItem>
168
+ <FormItem
169
+ {...formItemLayout}
170
+ name='startDirectoryLocal'
171
+ label={`${e('startDirectory')}:${sf('local')}`}
172
+ >
173
+ <Input />
174
+ </FormItem>
175
+ <FormItem
176
+ {...formItemLayout}
177
+ name='startDirectory'
178
+ label={`${e('startDirectory')}:${sf('remote')}`}
179
+ >
180
+ <Input />
181
+ </FormItem>
182
+ {renderRunScripts()}
183
+ <FormItem
184
+ {...formItemLayout}
185
+ key='encode-select'
186
+ label={e('encode')}
187
+ name='encode'
188
+ >
189
+ <Select
190
+ showSearch
191
+ >
192
+ {
193
+ encodes.map(k => {
194
+ return (
195
+ <Option
196
+ value={k}
197
+ key={k}
198
+ >
199
+ {k}
200
+ </Option>
201
+ )
202
+ })
203
+ }
204
+ </Select>
205
+ </FormItem>
206
+ </div>
207
+ )
208
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * bookmark form
3
+ */
4
+ import {
5
+ Tabs
6
+ } from 'antd'
7
+ import { sshTunnelHelpLink } from '../../common/constants'
8
+ import HelpIcon from '../common/help-icon'
9
+
10
+ const { prefix } = window
11
+ const e = prefix('form')
12
+ const s = prefix('setting')
13
+ const h = prefix('ssh')
14
+ const q = prefix('quickCommands')
15
+
16
+ export default function renderTabs (props) {
17
+ const tunnelTag = (
18
+ <span>
19
+ {h('sshTunnel')}
20
+ <HelpIcon
21
+ link={sshTunnelHelpLink}
22
+ />
23
+ </span>
24
+ )
25
+ const items = [
26
+ {
27
+ key: 'auth',
28
+ label: e('auth'),
29
+ forceRender: true,
30
+ children: props.renderCommon(props)
31
+ },
32
+ {
33
+ key: 'settings',
34
+ label: s('settings'),
35
+ forceRender: true,
36
+ children: (
37
+ <div>
38
+ {props.renderEnableSftp()}
39
+ {props.uis}
40
+ {props.renderProxy(props)}
41
+ {props.renderX11()}
42
+ </div>
43
+ )
44
+ },
45
+ {
46
+ key: 'quickCommands',
47
+ label: q('quickCommands'),
48
+ forceRender: true,
49
+ children: props.qms
50
+ },
51
+ {
52
+ key: 'tunnel',
53
+ label: tunnelTag,
54
+ forceRender: true,
55
+ children: props.renderSshTunnel(props)
56
+ },
57
+ {
58
+ key: 'connectionHopping',
59
+ label: e('connectionHopping'),
60
+ forceRender: true,
61
+ children: props.renderConnectionHopping(props)
62
+ }
63
+ ]
64
+ return (
65
+ <Tabs
66
+ items={items}
67
+ />
68
+ )
69
+ }
@@ -0,0 +1,159 @@
1
+ /**
2
+ * bookmark form
3
+ */
4
+ import { Component } from '../common/react-subx'
5
+ import {
6
+ Radio
7
+ } from 'antd'
8
+ import {
9
+ settingMap,
10
+ connectionMap,
11
+ terminalSerialType,
12
+ terminalLocalType,
13
+ terminalTelnetType,
14
+ newBookmarkIdPrefix
15
+ } from '../../common/constants'
16
+ import SshForm from './ssh-form'
17
+ import SerialForm from './serial-form'
18
+ import LocalForm from './local-form'
19
+ import TelnetForm from './telnet-form'
20
+ import createTitle from '../../common/create-title'
21
+ import {
22
+ LoadingOutlined,
23
+ BookOutlined
24
+ } from '@ant-design/icons'
25
+
26
+ const { prefix } = window
27
+ const c = prefix('common')
28
+ const m = prefix('menu')
29
+ const s = prefix('setting')
30
+ const p = prefix('sftp')
31
+
32
+ export default class BookmarkIndex extends Component {
33
+ constructor (props) {
34
+ super(props)
35
+ let initType = props.formData.type
36
+ if (initType === terminalTelnetType) {
37
+ initType = terminalTelnetType
38
+ } else if (initType === terminalSerialType) {
39
+ initType = terminalSerialType
40
+ } else if (initType === terminalLocalType) {
41
+ initType = terminalLocalType
42
+ } else {
43
+ initType = connectionMap.ssh
44
+ }
45
+ this.state = {
46
+ ready: false,
47
+ bookmarkType: initType
48
+ }
49
+ }
50
+
51
+ componentDidMount () {
52
+ this.timer = setTimeout(() => {
53
+ this.setState({
54
+ ready: true
55
+ })
56
+ }, 200)
57
+ }
58
+
59
+ componentWillUnmount () {
60
+ clearTimeout(this.timer)
61
+ }
62
+
63
+ static mapper = {
64
+ [connectionMap.ssh]: SshForm,
65
+ [connectionMap.telnet]: TelnetForm,
66
+ [connectionMap.serial]: SerialForm,
67
+ [connectionMap.local]: LocalForm
68
+ }
69
+
70
+ handleChange = (e) => {
71
+ this.setState({
72
+ bookmarkType: e.target.value
73
+ })
74
+ }
75
+
76
+ renderTypes (bookmarkType, isNew, keys) {
77
+ if (!isNew) {
78
+ return null
79
+ }
80
+ return (
81
+ <Radio.Group
82
+ buttonStyle='solid'
83
+ size='small'
84
+ className='mg1l'
85
+ value={bookmarkType}
86
+ disabled={!isNew}
87
+ onChange={this.handleChange}
88
+ >
89
+ {
90
+ keys.map(k => {
91
+ const v = connectionMap[k]
92
+ return (
93
+ <Radio.Button key={v} value={v}>{p(v)}</Radio.Button>
94
+ )
95
+ })
96
+ }
97
+ </Radio.Group>
98
+ )
99
+ }
100
+
101
+ renderTitle (formData, isNew) {
102
+ if (isNew) {
103
+ return null
104
+ }
105
+ return (
106
+ <b className='mg1x'>
107
+ {createTitle(formData)}
108
+ </b>
109
+ )
110
+ }
111
+
112
+ render () {
113
+ const { formData } = this.props
114
+ const {
115
+ id = ''
116
+ } = formData
117
+ const {
118
+ type
119
+ } = this.props
120
+ if (type !== settingMap.bookmarks && type !== settingMap.history) {
121
+ return null
122
+ }
123
+ const { ready } = this.state
124
+ if (!ready) {
125
+ return (
126
+ <div className='pd3 aligncenter'>
127
+ <LoadingOutlined />
128
+ </div>
129
+ )
130
+ }
131
+ const {
132
+ bookmarkType
133
+ } = this.state
134
+ const Form = BookmarkIndex.mapper[bookmarkType]
135
+ const isNew = id.startsWith(newBookmarkIdPrefix)
136
+ const keys = Object.keys(connectionMap)
137
+ // if (isWin) {
138
+ // keys = keys.filter(k => k !== connectionMap.serial)
139
+ // }
140
+ return (
141
+ <div className='form-wrap pd1x'>
142
+ <div className='form-title pd1t pd1x pd2b'>
143
+ <BookOutlined className='mg1r' />
144
+ <span>
145
+ {
146
+ (!isNew
147
+ ? m('edit')
148
+ : s('new')
149
+ ) + ' ' + c(settingMap.bookmarks)
150
+ }
151
+ </span>
152
+ {this.renderTitle(formData, isNew)}
153
+ {this.renderTypes(bookmarkType, isNew, keys)}
154
+ </div>
155
+ <Form {...this.props} />
156
+ </div>
157
+ )
158
+ }
159
+ }
@@ -0,0 +1,152 @@
1
+ /**
2
+ * bookmark form
3
+ */
4
+
5
+ import { useEffect } from 'react'
6
+ import {
7
+ Tabs,
8
+ Input,
9
+ TreeSelect,
10
+ Form
11
+ } from 'antd'
12
+ import { formItemLayout } from '../../common/form-layout'
13
+ import {
14
+ newBookmarkIdPrefix,
15
+ terminalLocalType
16
+ } from '../../common/constants'
17
+ import formatBookmarkGroups from './bookmark-group-tree-format'
18
+ import findBookmarkGroupId from '../../common/find-bookmark-group-id'
19
+ import useSubmit from './use-submit'
20
+ import useUI from './use-ui'
21
+ import useQm from './use-quick-commands'
22
+ import copy from 'json-deep-copy'
23
+ import { defaults } from 'lodash-es'
24
+ import renderRunScripts from './render-delayed-scripts.jsx'
25
+
26
+ const FormItem = Form.Item
27
+ const { prefix } = window
28
+ const e = prefix('form')
29
+ const c = prefix('common')
30
+ const s = prefix('setting')
31
+
32
+ export default function LocalFormUi (props) {
33
+ const [
34
+ form,
35
+ handleFinish,
36
+ submitUi
37
+ ] = useSubmit(props)
38
+ useEffect(() => {
39
+ if (props.formData.id.startsWith(newBookmarkIdPrefix)) {
40
+ form.setFieldsValue({
41
+ category: props.currentBookmarkGroupId
42
+ })
43
+ }
44
+ }, [props.currentBookmarkGroupId])
45
+ const qms = useQm(form, props.formData)
46
+ const uis = useUI(props)
47
+ const {
48
+ id = ''
49
+ } = props.formData
50
+ const {
51
+ bookmarkGroups = [],
52
+ currentBookmarkGroupId
53
+ } = props
54
+ const initBookmarkGroupId = !id.startsWith(newBookmarkIdPrefix)
55
+ ? findBookmarkGroupId(bookmarkGroups, id)
56
+ : currentBookmarkGroupId
57
+ let initialValues = copy(props.formData)
58
+ const defaultValues = {
59
+ category: initBookmarkGroupId,
60
+ term: props.store.config.terminalType,
61
+ type: terminalLocalType,
62
+ runScripts: [{}],
63
+ enableSsh: true
64
+ }
65
+ initialValues = defaults(initialValues, defaultValues)
66
+ function renderCommon () {
67
+ const {
68
+ bookmarkGroups = []
69
+ } = props
70
+ const tree = formatBookmarkGroups(bookmarkGroups)
71
+ return (
72
+ <div className='pd1x'>
73
+ {renderRunScripts()}
74
+ <FormItem
75
+ {...formItemLayout}
76
+ label={e('title')}
77
+ name='title'
78
+ hasFeedback
79
+ >
80
+ <Input />
81
+ </FormItem>
82
+ <FormItem
83
+ {...formItemLayout}
84
+ label={e('description')}
85
+ name='description'
86
+ hasFeedback
87
+ >
88
+ <Input.TextArea rows={1} />
89
+ </FormItem>
90
+ <FormItem
91
+ {...formItemLayout}
92
+ label={c('bookmarkCategory')}
93
+ name='category'
94
+ >
95
+ <TreeSelect
96
+ treeData={tree}
97
+ treeDefaultExpandAll
98
+ showSearch
99
+ />
100
+ </FormItem>
101
+ <FormItem
102
+ {...formItemLayout}
103
+ label='type'
104
+ name='type'
105
+ className='hide'
106
+ >
107
+ <Input />
108
+ </FormItem>
109
+ </div>
110
+ )
111
+ }
112
+
113
+ function renderTabs () {
114
+ const items = [
115
+ {
116
+ key: 'auth',
117
+ label: e('auth'),
118
+ forceRender: true,
119
+ children: renderCommon()
120
+ },
121
+ {
122
+ key: 'settings',
123
+ label: s('settings'),
124
+ forceRender: true,
125
+ children: uis
126
+ },
127
+ {
128
+ key: 'quickCommands',
129
+ forceRender: true,
130
+ label: e('quickCommands'),
131
+ children: qms
132
+ }
133
+ ]
134
+ return (
135
+ <Tabs
136
+ items={items}
137
+ />
138
+ )
139
+ }
140
+
141
+ return (
142
+ <Form
143
+ form={form}
144
+ onFinish={handleFinish}
145
+ initialValues={initialValues}
146
+ name='local-form'
147
+ >
148
+ {renderTabs()}
149
+ {submitUi}
150
+ </Form>
151
+ )
152
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * bookmark form
3
+ */
4
+ import BookmarkForm from './ssh-form'
5
+ import LocalFormUi from './local-form-ui'
6
+
7
+ export default class LocalForm extends BookmarkForm {
8
+ render () {
9
+ return (
10
+ <LocalFormUi
11
+ {...this.props}
12
+ {...this.getProps()}
13
+ />
14
+ )
15
+ }
16
+ }
@@ -0,0 +1,49 @@
1
+ import {
2
+ Input,
3
+ Form,
4
+ AutoComplete
5
+ } from 'antd'
6
+ import { formItemLayout } from '../../common/form-layout'
7
+
8
+ const FormItem = Form.Item
9
+ const { prefix } = window
10
+ const e = prefix('form')
11
+
12
+ export default function renderProxy (props) {
13
+ const proxyTree = props.bookmarks
14
+ .reduce((prev, current) => {
15
+ const { proxy } = current
16
+ if (proxy && !prev[proxy]) {
17
+ prev[proxy] = 1
18
+ }
19
+ return prev
20
+ }, {})
21
+ const opts = {
22
+ options: Object.keys(proxyTree)
23
+ .map(d => {
24
+ return {
25
+ label: d,
26
+ value: d
27
+ }
28
+ }),
29
+ placeholder: 'socks5://127.0.0.1:1080',
30
+ allowClear: true
31
+ }
32
+ return (
33
+ <FormItem
34
+ {...formItemLayout}
35
+ label={e('proxy')}
36
+ hasFeedback
37
+ name='proxy'
38
+ rules={[{
39
+ max: 1024, message: '1024 chars max'
40
+ }]}
41
+ >
42
+ <AutoComplete
43
+ {...opts}
44
+ >
45
+ <Input />
46
+ </AutoComplete>
47
+ </FormItem>
48
+ )
49
+ }