@electerm/electerm-react 2.4.28 → 2.4.38
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.
- package/client/components/bookmark-form/common/color-picker.jsx +3 -0
- package/client/components/common/input-confirm-common.jsx +78 -0
- package/client/components/common/input-confirm-common.styl +5 -0
- package/client/components/common/input-confirm.jsx +12 -65
- package/client/components/common/input-number-confirm.jsx +13 -0
- package/client/components/common/modal.jsx +1 -8
- package/client/components/common/textarea-confirm.jsx +13 -0
- package/client/components/setting-panel/keywords-form.jsx +2 -2
- package/client/components/setting-panel/number-config.jsx +2 -4
- package/client/components/setting-panel/setting-common.jsx +12 -14
- package/client/components/setting-panel/setting-terminal.jsx +7 -7
- package/client/components/setting-sync/setting-sync-form.jsx +1 -1
- package/client/components/sys-menu/zoom.jsx +1 -1
- package/client/components/tree-list/bookmark-transport.jsx +0 -1
- package/client/store/system-menu.js +0 -1
- package/package.json +1 -1
- package/client/components/setting-panel/keyword-input.jsx +0 -60
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { CheckOutlined, CloseOutlined } from '@ant-design/icons'
|
|
3
|
+
import { Space } from 'antd'
|
|
4
|
+
import './input-confirm-common.styl'
|
|
5
|
+
|
|
6
|
+
export default function InputConfirmCommon ({
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
inputComponent: InputComponent,
|
|
10
|
+
iconPlacement = 'addonAfter', // 'addonAfter', 'suffix', or 'below'
|
|
11
|
+
extraAddonAfter,
|
|
12
|
+
...rest
|
|
13
|
+
}) {
|
|
14
|
+
const [localValue, setLocalValue] = useState(value)
|
|
15
|
+
const [isEditing, setIsEditing] = useState(false)
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setLocalValue(value)
|
|
19
|
+
}, [value])
|
|
20
|
+
|
|
21
|
+
function handleChange (e) {
|
|
22
|
+
const newValue = e && e.target ? e.target.value : e
|
|
23
|
+
setLocalValue(newValue)
|
|
24
|
+
setIsEditing(true)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function handleConfirm () {
|
|
28
|
+
onChange(localValue)
|
|
29
|
+
setIsEditing(false)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function handleCancel () {
|
|
33
|
+
setLocalValue(value)
|
|
34
|
+
setIsEditing(false)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const icons = isEditing
|
|
38
|
+
? (
|
|
39
|
+
<>
|
|
40
|
+
<CheckOutlined
|
|
41
|
+
onClick={handleConfirm}
|
|
42
|
+
className='mg1x pointer'
|
|
43
|
+
/>
|
|
44
|
+
<CloseOutlined
|
|
45
|
+
onClick={handleCancel}
|
|
46
|
+
className='pointer'
|
|
47
|
+
/>
|
|
48
|
+
</>
|
|
49
|
+
)
|
|
50
|
+
: null
|
|
51
|
+
const { className, ...restProps } = rest
|
|
52
|
+
const cls = className ? `${className} input-confirm` : 'input-confirm'
|
|
53
|
+
const finalAddon = extraAddonAfter || icons
|
|
54
|
+
? (
|
|
55
|
+
<Space.Addon>
|
|
56
|
+
{extraAddonAfter}
|
|
57
|
+
{icons}
|
|
58
|
+
</Space.Addon>
|
|
59
|
+
)
|
|
60
|
+
: null
|
|
61
|
+
|
|
62
|
+
const childProps = {
|
|
63
|
+
...restProps,
|
|
64
|
+
value: localValue,
|
|
65
|
+
onChange: handleChange
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const inputElement = <InputComponent {...childProps} />
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div>
|
|
72
|
+
<Space.Compact className={cls}>
|
|
73
|
+
{inputElement}
|
|
74
|
+
{finalAddon}
|
|
75
|
+
</Space.Compact>
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
@@ -1,66 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
constructor (props) {
|
|
14
|
-
super(props)
|
|
15
|
-
this.state = {
|
|
16
|
-
v: props.value,
|
|
17
|
-
onEdit: false
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
componentDidUpdate (prevProps) {
|
|
22
|
-
if (prevProps.value !== this.props.value) {
|
|
23
|
-
this.setState({
|
|
24
|
-
v: this.props.value
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
handleChange = (v) => {
|
|
30
|
-
this.setState({ v })
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
handleClick = () => {
|
|
34
|
-
this.setState({ onEdit: true })
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
handleSubmit = () => {
|
|
38
|
-
this.setState({ onEdit: false })
|
|
39
|
-
this.props.onChange(this.state.v)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
after = () => {
|
|
43
|
-
const { onEdit } = this.state
|
|
44
|
-
if (onEdit) {
|
|
45
|
-
return (
|
|
46
|
-
<CheckOutlined
|
|
47
|
-
className='font16 pointer'
|
|
48
|
-
onClick={this.handleSubmit}
|
|
49
|
-
/>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
return this.props.addonAfter
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
render () {
|
|
56
|
-
return (
|
|
57
|
-
<InputNumber
|
|
58
|
-
{...this.props}
|
|
59
|
-
value={this.state.v}
|
|
60
|
-
onClick={this.handleClick}
|
|
61
|
-
onChange={this.handleChange}
|
|
62
|
-
addonAfter={this.after()}
|
|
63
|
-
/>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
1
|
+
import { Input } from 'antd'
|
|
2
|
+
import InputConfirmCommon from './input-confirm-common'
|
|
3
|
+
|
|
4
|
+
export default function InputConfirm (props) {
|
|
5
|
+
const { extraAddonAfter, ...rest } = props
|
|
6
|
+
return (
|
|
7
|
+
<InputConfirmCommon
|
|
8
|
+
{...rest}
|
|
9
|
+
inputComponent={Input}
|
|
10
|
+
extraAddonAfter={extraAddonAfter}
|
|
11
|
+
/>
|
|
12
|
+
)
|
|
66
13
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InputNumber } from 'antd'
|
|
2
|
+
import InputConfirmCommon from './input-confirm-common'
|
|
3
|
+
|
|
4
|
+
export default function InputNumberConfirm (props) {
|
|
5
|
+
const { addonAfter, ...rest } = props
|
|
6
|
+
return (
|
|
7
|
+
<InputConfirmCommon
|
|
8
|
+
{...rest}
|
|
9
|
+
inputComponent={InputNumber}
|
|
10
|
+
extraAddonAfter={addonAfter}
|
|
11
|
+
/>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -57,19 +57,12 @@ export default function Modal (props) {
|
|
|
57
57
|
if (!open) return
|
|
58
58
|
|
|
59
59
|
const handleKeyDown = (e) => {
|
|
60
|
-
const isConfirm = !!document.querySelector('.custom-modal-cancel-btn')
|
|
61
60
|
if (e.key === 'Escape') {
|
|
62
61
|
if (onCancel) {
|
|
63
62
|
onCancel()
|
|
64
63
|
e.preventDefault()
|
|
65
64
|
}
|
|
66
|
-
} else if ((e.key === 'Enter' || e.key === ' ')
|
|
67
|
-
// For info, Enter/Space closes
|
|
68
|
-
if (onCancel) {
|
|
69
|
-
onCancel()
|
|
70
|
-
e.preventDefault()
|
|
71
|
-
}
|
|
72
|
-
} else if ((e.key === 'Enter' || e.key === ' ') && isConfirm) {
|
|
65
|
+
} else if ((e.key === 'Enter' || e.key === ' ')) {
|
|
73
66
|
// For confirm, Enter/Space confirms
|
|
74
67
|
const okBtn = document.querySelector('.custom-modal-ok-btn')
|
|
75
68
|
if (okBtn) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Input } from 'antd'
|
|
2
|
+
import InputConfirmCommon from './input-confirm-common'
|
|
3
|
+
|
|
4
|
+
const { TextArea } = Input
|
|
5
|
+
|
|
6
|
+
export default function TextareaConfirm (props) {
|
|
7
|
+
return (
|
|
8
|
+
<InputConfirmCommon
|
|
9
|
+
{...props}
|
|
10
|
+
inputComponent={TextArea}
|
|
11
|
+
/>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
PlusOutlined
|
|
11
11
|
} from '@ant-design/icons'
|
|
12
12
|
import { useEffect } from 'react'
|
|
13
|
-
import
|
|
13
|
+
import InputConfirm from '../common/input-confirm'
|
|
14
14
|
|
|
15
15
|
const FormItem = Form.Item
|
|
16
16
|
const FormList = Form.List
|
|
@@ -55,7 +55,7 @@ export default function KeywordForm (props) {
|
|
|
55
55
|
name={[field.name, 'keyword']}
|
|
56
56
|
rules={[{ validator: checker }]}
|
|
57
57
|
>
|
|
58
|
-
<
|
|
58
|
+
<InputConfirm
|
|
59
59
|
addonBefore={renderBefore(field.name)}
|
|
60
60
|
/>
|
|
61
61
|
</FormItem>
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
InputNumber
|
|
3
|
-
} from 'antd'
|
|
1
|
+
import InputNumberConfirm from '../common/input-number-confirm'
|
|
4
2
|
import { isNumber, isNaN } from 'lodash-es'
|
|
5
3
|
|
|
6
4
|
export default function NumberConfig ({
|
|
@@ -40,7 +38,7 @@ export default function NumberConfig ({
|
|
|
40
38
|
}
|
|
41
39
|
return (
|
|
42
40
|
<div className={`pd2b ${cls || ''}`}>
|
|
43
|
-
<
|
|
41
|
+
<InputNumberConfirm
|
|
44
42
|
{...opts}
|
|
45
43
|
/>
|
|
46
44
|
</div>
|
|
@@ -9,8 +9,6 @@ import message from '../common/message'
|
|
|
9
9
|
import {
|
|
10
10
|
Select,
|
|
11
11
|
Switch,
|
|
12
|
-
Input,
|
|
13
|
-
InputNumber,
|
|
14
12
|
Alert,
|
|
15
13
|
Button,
|
|
16
14
|
Table,
|
|
@@ -19,6 +17,9 @@ import {
|
|
|
19
17
|
} from 'antd'
|
|
20
18
|
import deepCopy from 'json-deep-copy'
|
|
21
19
|
import Password from '../common/password'
|
|
20
|
+
import InputConfirm from '../common/input-confirm'
|
|
21
|
+
import InputNumberConfirm from '../common/input-number-confirm'
|
|
22
|
+
import TextareaConfirm from '../common/textarea-confirm'
|
|
22
23
|
import {
|
|
23
24
|
settingMap,
|
|
24
25
|
proxyHelpLink
|
|
@@ -149,8 +150,8 @@ export default class SettingCommon extends Component {
|
|
|
149
150
|
this.props.store.setTheme(id)
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
handleCustomCss = (
|
|
153
|
-
this.onChangeValue(
|
|
153
|
+
handleCustomCss = (value) => {
|
|
154
|
+
this.onChangeValue(value, 'customCss')
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
onChangeValue = (value, name) => {
|
|
@@ -222,7 +223,7 @@ export default class SettingCommon extends Component {
|
|
|
222
223
|
)
|
|
223
224
|
}
|
|
224
225
|
|
|
225
|
-
renderNumber = (name, options, title = ''
|
|
226
|
+
renderNumber = (name, options, title = '') => {
|
|
226
227
|
let value = this.props.config[name]
|
|
227
228
|
if (options.valueParser) {
|
|
228
229
|
value = options.valueParser(value)
|
|
@@ -256,13 +257,10 @@ export default class SettingCommon extends Component {
|
|
|
256
257
|
}
|
|
257
258
|
return vv
|
|
258
259
|
}
|
|
259
|
-
opts.style = {
|
|
260
|
-
width
|
|
261
|
-
}
|
|
262
260
|
}
|
|
263
261
|
return (
|
|
264
262
|
<div className={`pd2b ${cls || ''}`}>
|
|
265
|
-
<
|
|
263
|
+
<InputNumberConfirm
|
|
266
264
|
{...opts}
|
|
267
265
|
/>
|
|
268
266
|
</div>
|
|
@@ -272,10 +270,10 @@ export default class SettingCommon extends Component {
|
|
|
272
270
|
renderText = (name, placeholder) => {
|
|
273
271
|
const value = this.props.config[name]
|
|
274
272
|
const defaultValue = defaultSettings[name]
|
|
275
|
-
const onChange = (
|
|
273
|
+
const onChange = (v) => this.onChangeValue(v, name)
|
|
276
274
|
return (
|
|
277
275
|
<div className='pd2b'>
|
|
278
|
-
<
|
|
276
|
+
<InputConfirm
|
|
279
277
|
value={value}
|
|
280
278
|
onChange={onChange}
|
|
281
279
|
placeholder={placeholder || defaultValue}
|
|
@@ -289,7 +287,7 @@ export default class SettingCommon extends Component {
|
|
|
289
287
|
const args = this.props.config[agrsProp]
|
|
290
288
|
const value = this.props.config[name]
|
|
291
289
|
const defaultValue = defaultSettings[name]
|
|
292
|
-
const onChange = (
|
|
290
|
+
const onChange = (v) => this.onChangeValue(v, name)
|
|
293
291
|
const onChangeArgs = (v) => this.onChangeValue(v, agrsProp)
|
|
294
292
|
const styleArg = {
|
|
295
293
|
style: {
|
|
@@ -299,7 +297,7 @@ export default class SettingCommon extends Component {
|
|
|
299
297
|
return (
|
|
300
298
|
<div className='pd2b'>
|
|
301
299
|
<Space.Compact block>
|
|
302
|
-
<
|
|
300
|
+
<InputConfirm
|
|
303
301
|
value={value}
|
|
304
302
|
onChange={onChange}
|
|
305
303
|
placeholder={defaultValue}
|
|
@@ -569,7 +567,7 @@ export default class SettingCommon extends Component {
|
|
|
569
567
|
|
|
570
568
|
<div className='pd2b'>
|
|
571
569
|
<span className='inline-title mg1r'>{e('customCss')}</span>
|
|
572
|
-
<
|
|
570
|
+
<TextareaConfirm
|
|
573
571
|
onChange={this.handleCustomCss}
|
|
574
572
|
value={customCss}
|
|
575
573
|
rows={3}
|
|
@@ -7,7 +7,6 @@ import message from '../common/message'
|
|
|
7
7
|
import {
|
|
8
8
|
Select,
|
|
9
9
|
Switch,
|
|
10
|
-
Input,
|
|
11
10
|
Upload,
|
|
12
11
|
Button,
|
|
13
12
|
AutoComplete,
|
|
@@ -23,6 +22,7 @@ import {
|
|
|
23
22
|
} from '../../common/constants'
|
|
24
23
|
import defaultSettings from '../../common/default-setting'
|
|
25
24
|
import ShowItem from '../common/show-item'
|
|
25
|
+
import InputConfirm from '../common/input-confirm'
|
|
26
26
|
import { osResolve } from '../../common/resolve'
|
|
27
27
|
import { chooseSaveDirectory } from '../../common/choose-save-folder'
|
|
28
28
|
import mapper from '../../common/auto-complete-data-mapper'
|
|
@@ -170,7 +170,7 @@ export default class SettingTerminal extends Component {
|
|
|
170
170
|
const inputProps = {
|
|
171
171
|
value: sessionLogPath,
|
|
172
172
|
placeholder: path,
|
|
173
|
-
onChange:
|
|
173
|
+
onChange: this.handleLogChange,
|
|
174
174
|
addonAfter: (
|
|
175
175
|
<>
|
|
176
176
|
<Button
|
|
@@ -197,7 +197,7 @@ export default class SettingTerminal extends Component {
|
|
|
197
197
|
}
|
|
198
198
|
return (
|
|
199
199
|
<div className='pd2b'>
|
|
200
|
-
<
|
|
200
|
+
<InputConfirm {...inputProps} />
|
|
201
201
|
</div>
|
|
202
202
|
)
|
|
203
203
|
}
|
|
@@ -235,10 +235,10 @@ export default class SettingTerminal extends Component {
|
|
|
235
235
|
renderText = (name, placeholder) => {
|
|
236
236
|
const value = this.props.config[name]
|
|
237
237
|
const defaultValue = defaultSettings[name]
|
|
238
|
-
const onChange = (
|
|
238
|
+
const onChange = (v) => this.onChangeValue(v, name)
|
|
239
239
|
return (
|
|
240
240
|
<div className='pd2b'>
|
|
241
|
-
<
|
|
241
|
+
<InputConfirm
|
|
242
242
|
value={value}
|
|
243
243
|
onChange={onChange}
|
|
244
244
|
placeholder={placeholder || defaultValue}
|
|
@@ -339,8 +339,8 @@ export default class SettingTerminal extends Component {
|
|
|
339
339
|
className='width-100'
|
|
340
340
|
options={dataSource.map(this.renderBgOption)}
|
|
341
341
|
>
|
|
342
|
-
<
|
|
343
|
-
|
|
342
|
+
<InputConfirm
|
|
343
|
+
extraAddonAfter={after}
|
|
344
344
|
/>
|
|
345
345
|
</AutoComplete>
|
|
346
346
|
</Tooltip>
|
|
@@ -148,7 +148,7 @@ export default function SyncForm (props) {
|
|
|
148
148
|
if (syncType === syncTypes.gitee) {
|
|
149
149
|
return (
|
|
150
150
|
<Alert
|
|
151
|
-
|
|
151
|
+
title={
|
|
152
152
|
<span>
|
|
153
153
|
Gitee data sync is not recommended. For more information, please refer to the
|
|
154
154
|
<Link to='https://github.com/electerm/electerm/wiki/gitee-data-sync-warning' className='mg1l'>
|
package/package.json
CHANGED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Input } from 'antd'
|
|
2
|
-
import { CheckOutlined, CloseOutlined } from '@ant-design/icons'
|
|
3
|
-
import { useState, useEffect } from 'react'
|
|
4
|
-
|
|
5
|
-
export default function KeywordInput (props) {
|
|
6
|
-
const { value, onChange, addonBefore, ...rest } = props
|
|
7
|
-
const [localValue, setLocalValue] = useState(value || '')
|
|
8
|
-
const [isEditing, setIsEditing] = useState(false)
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
setLocalValue(value || '')
|
|
12
|
-
}, [value])
|
|
13
|
-
|
|
14
|
-
function handleChange (e) {
|
|
15
|
-
const newValue = e.target.value
|
|
16
|
-
setLocalValue(newValue)
|
|
17
|
-
setIsEditing(true)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function handleConfirm () {
|
|
21
|
-
onChange(localValue)
|
|
22
|
-
setIsEditing(false)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function handleCancel () {
|
|
26
|
-
setLocalValue(value || '')
|
|
27
|
-
setIsEditing(false)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function handleBlur () {
|
|
31
|
-
// Optionally hide icons on blur, but since user might click icons, maybe not
|
|
32
|
-
// setIsEditing(false)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const addonAfter = isEditing
|
|
36
|
-
? (
|
|
37
|
-
<div>
|
|
38
|
-
<CheckOutlined
|
|
39
|
-
onClick={handleConfirm}
|
|
40
|
-
className='mg1r pointer'
|
|
41
|
-
/>
|
|
42
|
-
<CloseOutlined
|
|
43
|
-
onClick={handleCancel}
|
|
44
|
-
className='pointer'
|
|
45
|
-
/>
|
|
46
|
-
</div>
|
|
47
|
-
)
|
|
48
|
-
: null
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Input
|
|
52
|
-
value={localValue}
|
|
53
|
-
onChange={handleChange}
|
|
54
|
-
onBlur={handleBlur}
|
|
55
|
-
addonBefore={addonBefore}
|
|
56
|
-
addonAfter={addonAfter}
|
|
57
|
-
{...rest}
|
|
58
|
-
/>
|
|
59
|
-
)
|
|
60
|
-
}
|