@electerm/electerm-react 1.39.109 → 1.40.1

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 (39) hide show
  1. package/client/common/constants.js +0 -1
  2. package/client/components/bookmark-form/bookmark-select.jsx +96 -0
  3. package/client/components/bookmark-form/color-picker.jsx +18 -9
  4. package/client/components/bookmark-form/form-ssh-common.jsx +4 -2
  5. package/client/components/bookmark-form/profile-form-item.jsx +43 -0
  6. package/client/components/bookmark-form/rdp-form-ui.jsx +10 -9
  7. package/client/components/bookmark-form/render-auth-ssh.jsx +6 -3
  8. package/client/components/bookmark-form/render-connection-hopping.jsx +15 -1
  9. package/client/components/bookmark-form/render-profile-item.jsx +0 -0
  10. package/client/components/bookmark-form/telnet-form-ui.jsx +19 -40
  11. package/client/components/bookmark-form/vnc-form-ui.jsx +6 -1
  12. package/client/components/bookmark-form/web-form-ui.jsx +1 -1
  13. package/client/components/profile/profile-form-elem.jsx +14 -28
  14. package/client/components/profile/profile-form-rdp.jsx +31 -0
  15. package/client/components/profile/profile-form-ssh.jsx +41 -0
  16. package/client/components/profile/profile-form-telnet.jsx +35 -0
  17. package/client/components/profile/profile-form-vnc.jsx +31 -0
  18. package/client/components/profile/profile-tabs.jsx +32 -0
  19. package/client/components/quick-commands/on-drop.js +19 -0
  20. package/client/components/quick-commands/quick-commands-box.jsx +2 -17
  21. package/client/components/quick-commands/quick-commands-list.jsx +4 -19
  22. package/client/components/rdp/rdp-session.jsx +3 -9
  23. package/client/components/setting-panel/keywords-form.jsx +5 -0
  24. package/client/components/setting-panel/keywords-transport.jsx +32 -0
  25. package/client/components/setting-panel/setting-terminal.jsx +16 -1
  26. package/client/components/setting-panel/tab-themes.jsx +2 -2
  27. package/client/components/sftp/file-item.jsx +2 -2
  28. package/client/components/terminal/attach-addon-custom.js +12 -11
  29. package/client/components/terminal/index.jsx +40 -6
  30. package/client/components/theme/theme-edit-slot.jsx +28 -0
  31. package/client/components/theme/theme-editor.jsx +37 -0
  32. package/client/components/{terminal-theme/index.jsx → theme/theme-form.jsx} +103 -34
  33. package/client/components/theme/theme-form.styl +10 -0
  34. package/client/components/vnc/vnc-session.jsx +2 -1
  35. package/client/store/common.js +25 -4
  36. package/client/store/sync.js +4 -4
  37. package/package.json +1 -1
  38. /package/client/components/{terminal-theme → theme}/terminal-theme-list.styl +0 -0
  39. /package/client/components/{terminal-theme → theme}/theme-list.jsx +0 -0
@@ -1,10 +1,12 @@
1
- import { useRef } from 'react'
2
- import { Button, Input, message, Upload, Form } from 'antd'
1
+ import { useRef, useState } from 'react'
2
+ import { Button, Input, message, Upload, Form, Space } from 'antd'
3
3
  import { convertTheme, convertThemeToText, exportTheme, validThemeProps, requiredThemeProps } from '../../common/terminal-theme'
4
4
  import { defaultTheme, defaultThemeLight } from '../../common/constants'
5
5
  import generate from '../../common/uid'
6
6
  import Link from '../common/external-link'
7
7
  import InputAutoFocus from '../common/input-auto-focus'
8
+ import ThemePicker from './theme-editor'
9
+ // import './theme-form.styl'
8
10
 
9
11
  const { TextArea } = Input
10
12
  const FormItem = Form.Item
@@ -12,6 +14,8 @@ const e = window.translate
12
14
 
13
15
  export default function ThemeForm (props) {
14
16
  const [form] = Form.useForm()
17
+ const [txt, setTxt] = useState(convertThemeToText(props.formData))
18
+ const [editor, setEditor] = useState('theme-editor-color-picker')
15
19
  const action = useRef('submit')
16
20
  function exporter () {
17
21
  exportTheme(props.formData.id)
@@ -82,18 +86,27 @@ export default function ThemeForm (props) {
82
86
  return Promise.reject(message)
83
87
  }
84
88
  // Return an object with the flag and the message
89
+ setTxt(value)
85
90
  return Promise.resolve()
86
91
  }
87
92
 
88
93
  async function handleSubmit (res) {
94
+ if (!res.themeText) {
95
+ res.themeText = txt
96
+ }
89
97
  const { formData } = props
90
98
  const {
91
99
  themeName,
92
100
  themeText
93
101
  } = res
102
+ const converted = convertTheme(themeText)
103
+
104
+ if (converted.uiThemeConfig.main !== converted.themeConfig.background) {
105
+ converted.themeConfig.background = converted.uiThemeConfig.main
106
+ }
94
107
  const update = {
95
108
  name: themeName,
96
- ...convertTheme(themeText)
109
+ ...converted
97
110
  }
98
111
  const update1 = {
99
112
  ...update,
@@ -135,15 +148,22 @@ export default function ThemeForm (props) {
135
148
  async function beforeUpload (file) {
136
149
  const txt = await window.fs.readFile(file.path)
137
150
  const { name, themeConfig, uiThemeConfig } = convertTheme(txt)
151
+ const tt = convertThemeToText({
152
+ themeConfig, uiThemeConfig
153
+ })
138
154
  form.setFieldsValue({
139
155
  themeName: name,
140
- themeText: convertThemeToText({
141
- themeConfig, uiThemeConfig
142
- })
156
+ themeText: tt
143
157
  })
158
+ setTxt(tt)
144
159
  return false
145
160
  }
146
161
 
162
+ function handleSwitchEditor (e) {
163
+ e.preventDefault()
164
+ setEditor(editor === 'theme-editor-txt' ? 'theme-editor-color-picker' : 'theme-editor-txt')
165
+ }
166
+
147
167
  function renderFuncs (id) {
148
168
  if (!id) {
149
169
  return null
@@ -160,6 +180,43 @@ export default function ThemeForm (props) {
160
180
  )
161
181
  }
162
182
 
183
+ function onPickerChange (value, name) {
184
+ const realName = name.includes('terminal:')
185
+ ? name.replace('terminal:', '')
186
+ : name
187
+ const text = form.getFieldValue('themeText')
188
+ const obj = convertTheme(text)
189
+ if (obj.themeConfig[realName]) {
190
+ obj.themeConfig[realName] = value
191
+ } else if (obj.uiThemeConfig[realName]) {
192
+ obj.uiThemeConfig[realName] = value
193
+ }
194
+ form.setFieldsValue({
195
+ themeText: convertThemeToText(obj)
196
+ })
197
+ setTxt(convertThemeToText(obj))
198
+ }
199
+
200
+ function renderTxt () {
201
+ return (
202
+ <FormItem
203
+ noStyle
204
+ name='themeText'
205
+ hasFeedback
206
+ rules={[{
207
+ max: 1000, message: '1000 chars max'
208
+ }, {
209
+ required: true,
210
+ message: 'theme config required'
211
+ }, {
212
+ validator: validateInput
213
+ }]}
214
+ >
215
+ <TextArea rows={33} disabled={disabled} />
216
+ </FormItem>
217
+ )
218
+ }
219
+
163
220
  const {
164
221
  readonly,
165
222
  id,
@@ -173,12 +230,18 @@ export default function ThemeForm (props) {
173
230
  const { autofocustrigger } = props.store
174
231
  const isDefaultTheme = id === defaultTheme.id || id === defaultThemeLight.id
175
232
  const disabled = readonly || isDefaultTheme
233
+ const switchTxt = editor === 'theme-editor-txt' ? e('editWithColorPicker') : e('editWithTextEditor')
234
+ const pickerProps = {
235
+ onChange: onPickerChange,
236
+ themeText: txt,
237
+ disabled
238
+ }
176
239
  return (
177
240
  <Form
178
241
  onFinish={handleSubmit}
179
242
  form={form}
180
243
  initialValues={initialValues}
181
- className='form-wrap'
244
+ className={editor}
182
245
  name='terminal-theme-form'
183
246
  layout='vertical'
184
247
  >
@@ -202,35 +265,41 @@ export default function ThemeForm (props) {
202
265
  <FormItem
203
266
  label={e('themeConfig')}
204
267
  >
205
- <div className='pd1b'>
206
- <Upload
207
- beforeUpload={beforeUpload}
208
- fileList={[]}
209
- className='mg1b'
210
- >
211
- <Button
212
- type='dashed'
213
- disabled={disabled}
268
+ <div className='mg1b fix'>
269
+ <span className='fleft'>
270
+ <Space compact>
271
+ <Button
272
+ type='dashed'
273
+ onClick={handleSwitchEditor}
274
+ >
275
+ {switchTxt}
276
+ </Button>
277
+ </Space>
278
+ </span>
279
+ <span className='fright'>
280
+ <Upload
281
+ beforeUpload={beforeUpload}
282
+ fileList={[]}
283
+ className='mg1b'
214
284
  >
215
- {e('importFromFile')}
216
- </Button>
217
- </Upload>
285
+ <Button
286
+ type='dashed'
287
+ disabled={disabled}
288
+ >
289
+ {e('importFromFile')}
290
+ </Button>
291
+ </Upload>
292
+ </span>
218
293
  </div>
219
- <FormItem
220
- noStyle
221
- name='themeText'
222
- hasFeedback
223
- rules={[{
224
- max: 1000, message: '1000 chars max'
225
- }, {
226
- required: true,
227
- message: 'theme config required'
228
- }, {
229
- validator: validateInput
230
- }]}
231
- >
232
- <TextArea rows={33} disabled={disabled} />
233
- </FormItem>
294
+ {
295
+ editor === 'theme-editor-txt'
296
+ ? renderTxt()
297
+ : (
298
+ <ThemePicker
299
+ {...pickerProps}
300
+ />
301
+ )
302
+ }
234
303
  </FormItem>
235
304
  {
236
305
  disabled
@@ -0,0 +1,10 @@
1
+ .theme-editor-txt
2
+ .editor-u-textarea
3
+ display block !important
4
+ .editor-u-picker
5
+ display none !important
6
+ .theme-editor-color-picker
7
+ .editor-u-textarea
8
+ display none !important
9
+ .editor-u-picker
10
+ display block !important
@@ -71,7 +71,8 @@ export default class VncSession extends RdpSession {
71
71
  server = ''
72
72
  } = config
73
73
  const { sessionId, id } = this.props
74
- const tab = deepCopy(this.props.tab || {})
74
+ const tab = window.store.applyProfile(deepCopy(this.props.tab || {}))
75
+ console.log('vnc tab', this.props.tab)
75
76
  const {
76
77
  type,
77
78
  term: terminalType,
@@ -12,7 +12,8 @@ import {
12
12
  modals,
13
13
  leftSidebarWidthKey,
14
14
  rightSidebarWidthKey,
15
- dismissDelKeyTipLsKey
15
+ dismissDelKeyTipLsKey,
16
+ connectionMap
16
17
  } from '../common/constants'
17
18
  import * as ls from '../common/safe-local-storage'
18
19
 
@@ -212,10 +213,11 @@ export default Store => {
212
213
 
213
214
  Store.prototype.applyProfile = function (tab) {
214
215
  const {
215
- authType,
216
- profile
216
+ profile,
217
+ type,
218
+ authType
217
219
  } = tab
218
- if (authType !== 'profiles') {
220
+ if (!profile || authType !== 'profiles') {
219
221
  return tab
220
222
  }
221
223
  const p = window.store.profiles.find(x => x.id === profile)
@@ -227,6 +229,25 @@ export default Store => {
227
229
  // delete tab.passphrase
228
230
  delete p.name
229
231
  delete p.id
232
+ if (type === connectionMap.rdp) {
233
+ return {
234
+ ...tab,
235
+ ...p.rdp
236
+ }
237
+ } else if (type === connectionMap.vnc) {
238
+ return {
239
+ ...tab,
240
+ ...p.vnc
241
+ }
242
+ } else if (type === connectionMap.telnet) {
243
+ return {
244
+ ...tab,
245
+ ...p.telnet
246
+ }
247
+ }
248
+ delete p.rdp
249
+ delete p.vnc
250
+ delete p.telnet
230
251
  return {
231
252
  ...tab,
232
253
  ...p
@@ -120,7 +120,6 @@ export default (Store) => {
120
120
  const { store } = window
121
121
  const currentSyncType = store.syncType
122
122
  const currentSettings = store.config.syncSetting || {}
123
- console.log('currentSettings: ', currentSyncType, currentSettings)
124
123
  // Create a new object without the current sync type's settings
125
124
  const updatedSettings = Object.keys(currentSettings).reduce((acc, key) => {
126
125
  if (!key.startsWith(currentSyncType)) {
@@ -128,8 +127,6 @@ export default (Store) => {
128
127
  }
129
128
  return acc
130
129
  }, {})
131
- console.log('updatedSettings: ', updatedSettings)
132
-
133
130
  store.setConfig({
134
131
  syncSetting: updatedSettings
135
132
  })
@@ -190,7 +187,10 @@ export default (Store) => {
190
187
  })
191
188
  }
192
189
  str = JSON.stringify(str)
193
- if (n === settingMap.bookmarks && pass) {
190
+ if (
191
+ (n === settingMap.bookmarks || n === settingMap.profiles) &&
192
+ pass
193
+ ) {
194
194
  str = await window.pre.runGlobalAsync('encryptAsync', str, pass)
195
195
  }
196
196
  objs[`${n}.json`] = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "1.39.109",
3
+ "version": "1.40.1",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",