@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.
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/client/common/auto-complete-data-mapper.js +6 -0
- package/client/common/byte-format.js +14 -0
- package/client/common/class.js +52 -0
- package/client/common/clipboard.js +49 -0
- package/client/common/constants.js +308 -0
- package/client/common/create-lang-edit-link.js +7 -0
- package/client/common/create-title.js +29 -0
- package/client/common/db-fix.js +24 -0
- package/client/common/db.js +155 -0
- package/client/common/download-mirrors.js +10 -0
- package/client/common/download.js +16 -0
- package/client/common/error-handler.jsx +27 -0
- package/client/common/fetch-from-server.js +47 -0
- package/client/common/fetch.jsx +71 -0
- package/client/common/find-bookmark-group-id.js +15 -0
- package/client/common/find-parent.js +30 -0
- package/client/common/form-layout.js +27 -0
- package/client/common/fs.js +21 -0
- package/client/common/get-proxy.js +8 -0
- package/client/common/id-with-stamp.js +10 -0
- package/client/common/index-sorter.js +4 -0
- package/client/common/init-setting-item.js +32 -0
- package/client/common/is-absolute-path.js +3 -0
- package/client/common/is-ip.js +16 -0
- package/client/common/is-valid-path.js +7 -0
- package/client/common/key-control-pressed.js +13 -0
- package/client/common/key-pressed.js +13 -0
- package/client/common/key-shift-pressed.js +7 -0
- package/client/common/mode2permission.js +81 -0
- package/client/common/new-terminal.js +31 -0
- package/client/common/parse-int10.js +3 -0
- package/client/common/parse-json-safe.js +11 -0
- package/client/common/pass-enc.js +25 -0
- package/client/common/post-msg.js +3 -0
- package/client/common/pre.js +156 -0
- package/client/common/promise-timeout.js +27 -0
- package/client/common/resolve.js +31 -0
- package/client/common/run-idle.js +1 -0
- package/client/common/safe-local-storage.js +35 -0
- package/client/common/safe-name.js +19 -0
- package/client/common/sftp.js +74 -0
- package/client/common/terminal-theme.js +158 -0
- package/client/common/test-connection.js +12 -0
- package/client/common/time.js +30 -0
- package/client/common/to-simple-obj.js +5 -0
- package/client/common/track.js +7 -0
- package/client/common/transfer.js +76 -0
- package/client/common/trzsz.js +62 -0
- package/client/common/ui-theme.js +44 -0
- package/client/common/uid.js +5 -0
- package/client/common/update-check.js +79 -0
- package/client/common/upgrade.js +68 -0
- package/client/common/wait.js +8 -0
- package/client/common/ws.js +161 -0
- package/client/components/batch-op/batch-op.jsx +650 -0
- package/client/components/bookmark-form/bookmark-form.styl +8 -0
- package/client/components/bookmark-form/bookmark-group-tree-format.js +39 -0
- package/client/components/bookmark-form/encodes.js +44 -0
- package/client/components/bookmark-form/form-ssh-common.jsx +208 -0
- package/client/components/bookmark-form/form-tabs.jsx +69 -0
- package/client/components/bookmark-form/index.jsx +159 -0
- package/client/components/bookmark-form/local-form-ui.jsx +152 -0
- package/client/components/bookmark-form/local-form.jsx +16 -0
- package/client/components/bookmark-form/proxy.jsx +49 -0
- package/client/components/bookmark-form/quick-command-list.jsx +31 -0
- package/client/components/bookmark-form/quick-command.jsx +228 -0
- package/client/components/bookmark-form/render-auth-ssh.jsx +104 -0
- package/client/components/bookmark-form/render-connection-hopping.jsx +229 -0
- package/client/components/bookmark-form/render-delayed-scripts.jsx +88 -0
- package/client/components/bookmark-form/render-ssh-tunnel.jsx +116 -0
- package/client/components/bookmark-form/serial-form-ui.jsx +311 -0
- package/client/components/bookmark-form/serial-form.jsx +20 -0
- package/client/components/bookmark-form/sftp-enable.jsx +33 -0
- package/client/components/bookmark-form/ssh-form-ui.jsx +100 -0
- package/client/components/bookmark-form/ssh-form.jsx +348 -0
- package/client/components/bookmark-form/telnet-form-ui.jsx +154 -0
- package/client/components/bookmark-form/telnet-form.jsx +16 -0
- package/client/components/bookmark-form/tree-delete.jsx +87 -0
- package/client/components/bookmark-form/use-form-funcs.jsx +50 -0
- package/client/components/bookmark-form/use-quick-commands.jsx +83 -0
- package/client/components/bookmark-form/use-submit.jsx +77 -0
- package/client/components/bookmark-form/use-ui.jsx +82 -0
- package/client/components/bookmark-form/x11.jsx +23 -0
- package/client/components/common/animate-text.jsx +37 -0
- package/client/components/common/animate-text.styl +54 -0
- package/client/components/common/external-link.jsx +28 -0
- package/client/components/common/help-icon.jsx +25 -0
- package/client/components/common/highlight.jsx +23 -0
- package/client/components/common/highlight.styl +3 -0
- package/client/components/common/input-auto-focus.jsx +68 -0
- package/client/components/common/input-confirm.jsx +66 -0
- package/client/components/common/logo-elem.jsx +22 -0
- package/client/components/common/markdown.jsx +27 -0
- package/client/components/common/react-subx.jsx +1 -0
- package/client/components/common/resize-wrap.jsx +222 -0
- package/client/components/common/resize-wrap.styl +9 -0
- package/client/components/common/search.jsx +9 -0
- package/client/components/common/show-item.jsx +27 -0
- package/client/components/context-menu/boomarks.jsx +15 -0
- package/client/components/context-menu/context-menu.jsx +340 -0
- package/client/components/context-menu/context-menu.styl +90 -0
- package/client/components/context-menu/history.jsx +27 -0
- package/client/components/context-menu/icon-holder.jsx +5 -0
- package/client/components/context-menu/menu-btn.jsx +224 -0
- package/client/components/context-menu/sub-tab-menu.jsx +23 -0
- package/client/components/context-menu/tabs.jsx +22 -0
- package/client/components/context-menu/zoom.jsx +40 -0
- package/client/components/footer/batch-input.jsx +177 -0
- package/client/components/footer/footer-entry.jsx +141 -0
- package/client/components/footer/footer.styl +47 -0
- package/client/components/icons/match-case.jsx +10 -0
- package/client/components/icons/match-whole-word.jsx +13 -0
- package/client/components/icons/regular-exp.jsx +10 -0
- package/client/components/main/css-overwrite.jsx +92 -0
- package/client/components/main/error-wrapper.jsx +59 -0
- package/client/components/main/index.jsx +11 -0
- package/client/components/main/loading.jsx +25 -0
- package/client/components/main/main.jsx +149 -0
- package/client/components/main/term-fullscreen-control.jsx +21 -0
- package/client/components/main/term-fullscreen.styl +27 -0
- package/client/components/main/ui-theme.jsx +31 -0
- package/client/components/main/upgrade.jsx +351 -0
- package/client/components/main/upgrade.styl +27 -0
- package/client/components/main/wrapper.styl +41 -0
- package/client/components/quick-commands/qm.styl +29 -0
- package/client/components/quick-commands/quick-command-item.jsx +36 -0
- package/client/components/quick-commands/quick-command-transport-mod.jsx +54 -0
- package/client/components/quick-commands/quick-command-transport.jsx +12 -0
- package/client/components/quick-commands/quick-commands-box.jsx +233 -0
- package/client/components/quick-commands/quick-commands-form-elem.jsx +119 -0
- package/client/components/quick-commands/quick-commands-form.jsx +33 -0
- package/client/components/quick-commands/quick-commands-list.jsx +128 -0
- package/client/components/quick-commands/quick-commands-select.jsx +38 -0
- package/client/components/session/session.jsx +533 -0
- package/client/components/session/session.styl +53 -0
- package/client/components/session/sessions.jsx +445 -0
- package/client/components/setting-panel/bookmark-transport.jsx +148 -0
- package/client/components/setting-panel/bookmark-tree-list.jsx +14 -0
- package/client/components/setting-panel/col.jsx +18 -0
- package/client/components/setting-panel/list.jsx +186 -0
- package/client/components/setting-panel/list.styl +33 -0
- package/client/components/setting-panel/on-tree-drop.js +222 -0
- package/client/components/setting-panel/setting-modal.jsx +163 -0
- package/client/components/setting-panel/setting-wrap.jsx +37 -0
- package/client/components/setting-panel/setting-wrap.styl +52 -0
- package/client/components/setting-panel/setting.jsx +858 -0
- package/client/components/setting-panel/setting.styl +4 -0
- package/client/components/setting-panel/start-session-select.jsx +91 -0
- package/client/components/setting-panel/tab-bookmarks.jsx +37 -0
- package/client/components/setting-panel/tab-history.jsx +44 -0
- package/client/components/setting-panel/tab-quick-commands.jsx +38 -0
- package/client/components/setting-panel/tab-settings.jsx +42 -0
- package/client/components/setting-panel/tab-themes.jsx +34 -0
- package/client/components/setting-panel/tree-list.jsx +978 -0
- package/client/components/setting-panel/tree-list.styl +57 -0
- package/client/components/setting-sync/data-import.jsx +65 -0
- package/client/components/setting-sync/setting-sync-form.jsx +271 -0
- package/client/components/setting-sync/setting-sync.jsx +81 -0
- package/client/components/setting-sync/sync.styl +7 -0
- package/client/components/sftp/address-bar.jsx +139 -0
- package/client/components/sftp/address-bookmark-item.jsx +47 -0
- package/client/components/sftp/address-bookmark.jsx +81 -0
- package/client/components/sftp/address-bookmark.styl +8 -0
- package/client/components/sftp/confirm-modal.jsx +184 -0
- package/client/components/sftp/file-icon.jsx +22 -0
- package/client/components/sftp/file-item.jsx +1226 -0
- package/client/components/sftp/file-mode-modal.jsx +205 -0
- package/client/components/sftp/file-props-modal.jsx +211 -0
- package/client/components/sftp/file-read.js +81 -0
- package/client/components/sftp/list-table-ui.jsx +547 -0
- package/client/components/sftp/owner-list.js +97 -0
- package/client/components/sftp/paged-list.jsx +60 -0
- package/client/components/sftp/permission-render.jsx +42 -0
- package/client/components/sftp/sftp-entry.jsx +1069 -0
- package/client/components/sftp/sftp.styl +217 -0
- package/client/components/sftp/transfer-common.js +9 -0
- package/client/components/sftp/transfer-conflict.jsx +315 -0
- package/client/components/sftp/transfer-speed-format.js +60 -0
- package/client/components/sftp/transfer-tag.jsx +40 -0
- package/client/components/sftp/transfer-tag.styl +11 -0
- package/client/components/sftp/transfer.styl +55 -0
- package/client/components/sftp/transport-action.jsx +410 -0
- package/client/components/sftp/transport-entry.jsx +108 -0
- package/client/components/sftp/transport-types.js +8 -0
- package/client/components/sftp/transports-action.jsx +111 -0
- package/client/components/sftp/transports-ui.jsx +93 -0
- package/client/components/sftp/zip.js +42 -0
- package/client/components/sidebar/bookmark-select.jsx +48 -0
- package/client/components/sidebar/bookmark.jsx +82 -0
- package/client/components/sidebar/history.jsx +66 -0
- package/client/components/sidebar/index.jsx +230 -0
- package/client/components/sidebar/info-modal.jsx +250 -0
- package/client/components/sidebar/info.styl +27 -0
- package/client/components/sidebar/side-icon.jsx +25 -0
- package/client/components/sidebar/sidebar.styl +128 -0
- package/client/components/sidebar/transfer-history-modal.jsx +110 -0
- package/client/components/sidebar/transfer-history.styl +3 -0
- package/client/components/sidebar/transfer-list-control.jsx +205 -0
- package/client/components/sidebar/transfer-list.jsx +55 -0
- package/client/components/sidebar/transfer-modal.jsx +76 -0
- package/client/components/sidebar/transfer.styl +8 -0
- package/client/components/sidebar/transport-ui.jsx +109 -0
- package/client/components/tabs/index.jsx +320 -0
- package/client/components/tabs/tab.jsx +427 -0
- package/client/components/tabs/tabs.styl +220 -0
- package/client/components/tabs/window-control.jsx +55 -0
- package/client/components/terminal/attach-addon-custom.js +70 -0
- package/client/components/terminal/build-ls-term-id.js +5 -0
- package/client/components/terminal/index.jsx +1358 -0
- package/client/components/terminal/normal-buffer.jsx +33 -0
- package/client/components/terminal/term-search.jsx +224 -0
- package/client/components/terminal/term-search.styl +15 -0
- package/client/components/terminal/terminal-apis.js +31 -0
- package/client/components/terminal/terminal-interactive.jsx +148 -0
- package/client/components/terminal/terminal.styl +96 -0
- package/client/components/terminal/xterm-zmodem.js +48 -0
- package/client/components/terminal/zmodem-transfer.jsx +98 -0
- package/client/components/terminal/zmodem.styl +14 -0
- package/client/components/terminal-info/activity.jsx +54 -0
- package/client/components/terminal-info/base.jsx +25 -0
- package/client/components/terminal-info/content.jsx +101 -0
- package/client/components/terminal-info/data-cols-parser.jsx +50 -0
- package/client/components/terminal-info/disk.jsx +29 -0
- package/client/components/terminal-info/index.jsx +25 -0
- package/client/components/terminal-info/network.jsx +114 -0
- package/client/components/terminal-info/resource.jsx +80 -0
- package/client/components/terminal-info/run-cmd.jsx +273 -0
- package/client/components/terminal-info/terminal-info.styl +29 -0
- package/client/components/terminal-info/up.jsx +15 -0
- package/client/components/terminal-theme/index.jsx +264 -0
- package/client/components/terminal-theme/terminal-theme-list.styl +3 -0
- package/client/components/terminal-theme/theme-list.jsx +146 -0
- package/client/components/text-editor/text-editor-form.jsx +97 -0
- package/client/components/text-editor/text-editor.jsx +182 -0
- package/client/css/antd-overwrite.styl +14 -0
- package/client/css/basic.styl +38 -0
- package/client/css/includes/box.styl +154 -0
- package/client/css/includes/font-size.styl +6 -0
- package/client/css/includes/index.styl +3 -0
- package/client/css/includes/text.styl +31 -0
- package/client/css/includes/theme-default.styl +20 -0
- package/client/entry/basic.js +58 -0
- package/client/entry/index.jsx +15 -0
- package/client/entry/worker.js +137 -0
- package/client/store/address-bookmark.js +25 -0
- package/client/store/app-upgrade.js +23 -0
- package/client/store/batch-input-history.js +26 -0
- package/client/store/bookmark-group.js +128 -0
- package/client/store/bookmark.js +22 -0
- package/client/store/common.js +140 -0
- package/client/store/context-menu.js +23 -0
- package/client/store/db-upgrade.js +43 -0
- package/client/store/event.js +70 -0
- package/client/store/index.js +335 -0
- package/client/store/init-state.js +191 -0
- package/client/store/item.js +120 -0
- package/client/store/load-data.js +198 -0
- package/client/store/quick-command.js +43 -0
- package/client/store/session.js +54 -0
- package/client/store/setting.js +208 -0
- package/client/store/sidebar.js +48 -0
- package/client/store/sync.js +390 -0
- package/client/store/system-menu.js +120 -0
- package/client/store/tab.js +74 -0
- package/client/store/terminal-theme.js +116 -0
- package/client/store/transfer-history.js +27 -0
- package/client/store/transfer-list.js +20 -0
- package/client/store/ui-theme.js +71 -0
- package/client/store/watch.js +116 -0
- package/client/views/index.pug +58 -0
- package/package.json +34 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// .tree-list
|
|
2
|
+
// .ant-tree li
|
|
3
|
+
// > .ant-tree-node-content-wrapper
|
|
4
|
+
// width calc(100% - 24px)
|
|
5
|
+
// line-height 1.6
|
|
6
|
+
// height auto
|
|
7
|
+
// .ant-tree-child-tree
|
|
8
|
+
// span.ant-tree-switcher.ant-tree-switcher-noop
|
|
9
|
+
// display none
|
|
10
|
+
// li.ant-tree-treenode-switcher-open
|
|
11
|
+
// li.ant-tree-treenode-switcher-close
|
|
12
|
+
// & > .ant-tree-switcher.ant-tree-switcher-noop
|
|
13
|
+
// display inline-block
|
|
14
|
+
// .ant-tree-node-content-wrapper-open
|
|
15
|
+
// .ant-tree-node-content-wrapper-close
|
|
16
|
+
// width calc(100% - 48px)
|
|
17
|
+
// display inline-block
|
|
18
|
+
// .ant-tree-child-tree
|
|
19
|
+
// .ant-tree-node-content-wrapper
|
|
20
|
+
// display block
|
|
21
|
+
// padding-left 8px
|
|
22
|
+
// width 100%
|
|
23
|
+
// overflow hidden
|
|
24
|
+
// white-space nowrap
|
|
25
|
+
// text-overflow ellipsis
|
|
26
|
+
|
|
27
|
+
.tree-control-btn
|
|
28
|
+
display none
|
|
29
|
+
margin-left 3px
|
|
30
|
+
width 16px
|
|
31
|
+
line-height 26px
|
|
32
|
+
height 20px
|
|
33
|
+
.tree-item
|
|
34
|
+
display flex
|
|
35
|
+
&.is-category
|
|
36
|
+
.tree-item-title
|
|
37
|
+
font-weight bold
|
|
38
|
+
&:hover
|
|
39
|
+
.tree-control-btn
|
|
40
|
+
display inline-block
|
|
41
|
+
vertical-align middle
|
|
42
|
+
.tree-item-title
|
|
43
|
+
flex-grow 1
|
|
44
|
+
height 20px
|
|
45
|
+
max-width 300px
|
|
46
|
+
overflow hidden
|
|
47
|
+
white-space nowrap
|
|
48
|
+
text-overflow ellipsis
|
|
49
|
+
.sidebar-panel .tree-item-title
|
|
50
|
+
max-width 180px
|
|
51
|
+
.with-plus
|
|
52
|
+
&:after
|
|
53
|
+
content '+'
|
|
54
|
+
position absolute
|
|
55
|
+
font-size 16px
|
|
56
|
+
top 2px
|
|
57
|
+
right 2px
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* data import/export
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
Upload,
|
|
8
|
+
Switch,
|
|
9
|
+
Tooltip
|
|
10
|
+
} from 'antd'
|
|
11
|
+
import {
|
|
12
|
+
ImportOutlined,
|
|
13
|
+
ExportOutlined,
|
|
14
|
+
InfoCircleOutlined
|
|
15
|
+
} from '@ant-design/icons'
|
|
16
|
+
import { Component } from '../common/react-subx'
|
|
17
|
+
|
|
18
|
+
const { prefix } = window
|
|
19
|
+
const e = prefix('form')
|
|
20
|
+
const t = prefix('terminalThemes')
|
|
21
|
+
const s = prefix('settingSync')
|
|
22
|
+
|
|
23
|
+
export class DataTransport extends Component {
|
|
24
|
+
render () {
|
|
25
|
+
const txt = s('autoSync')
|
|
26
|
+
const {
|
|
27
|
+
store
|
|
28
|
+
} = this.props
|
|
29
|
+
return (
|
|
30
|
+
<div className='pd2 fix'>
|
|
31
|
+
<div className='fleft'>
|
|
32
|
+
<Button
|
|
33
|
+
icon={<ExportOutlined />}
|
|
34
|
+
className='mg1r'
|
|
35
|
+
onClick={store.handleExportAllData}
|
|
36
|
+
>
|
|
37
|
+
{t('export')}
|
|
38
|
+
</Button>
|
|
39
|
+
<Upload
|
|
40
|
+
beforeUpload={store.importAll}
|
|
41
|
+
fileList={[]}
|
|
42
|
+
>
|
|
43
|
+
<Button
|
|
44
|
+
icon={<ImportOutlined />}
|
|
45
|
+
>
|
|
46
|
+
{e('importFromFile')}
|
|
47
|
+
</Button>
|
|
48
|
+
</Upload>
|
|
49
|
+
</div>
|
|
50
|
+
<div className='fright'>
|
|
51
|
+
<Switch
|
|
52
|
+
checked={store.config.autoSync || false}
|
|
53
|
+
checkedChildren={txt}
|
|
54
|
+
onChange={store.handleAutoSync}
|
|
55
|
+
unCheckedChildren={txt}
|
|
56
|
+
className='mg3l mg1r'
|
|
57
|
+
/>
|
|
58
|
+
<Tooltip title={s('autoSyncTip')}>
|
|
59
|
+
<InfoCircleOutlined />
|
|
60
|
+
</Tooltip>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* setting sync panel,
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* bookmark form
|
|
7
|
+
*/
|
|
8
|
+
import { useDelta, useConditionalEffect } from 'react-delta'
|
|
9
|
+
import { ArrowDownOutlined, ArrowUpOutlined, SaveOutlined, ClearOutlined } from '@ant-design/icons'
|
|
10
|
+
import { Button, Input, notification, Form } from 'antd'
|
|
11
|
+
import Link from '../common/external-link'
|
|
12
|
+
import dayjs from 'dayjs'
|
|
13
|
+
import eq from 'fast-deep-equal'
|
|
14
|
+
import { syncTokenCreateUrls, syncTypes } from '../../common/constants'
|
|
15
|
+
import './sync.styl'
|
|
16
|
+
import HelpIcon from '../common/help-icon'
|
|
17
|
+
|
|
18
|
+
const FormItem = Form.Item
|
|
19
|
+
const { prefix } = window
|
|
20
|
+
const e = prefix('form')
|
|
21
|
+
const ss = prefix('settingSync')
|
|
22
|
+
const s = prefix('setting')
|
|
23
|
+
const sh = prefix('ssh')
|
|
24
|
+
|
|
25
|
+
export default function SyncForm (props) {
|
|
26
|
+
const [form] = Form.useForm()
|
|
27
|
+
const delta = useDelta(props.formData)
|
|
28
|
+
useConditionalEffect(() => {
|
|
29
|
+
form.resetFields()
|
|
30
|
+
}, delta && delta.prev && !eq(delta.prev, delta.curr))
|
|
31
|
+
|
|
32
|
+
function disabled () {
|
|
33
|
+
const {
|
|
34
|
+
token,
|
|
35
|
+
gistId
|
|
36
|
+
} = props.formData
|
|
37
|
+
return !token || !gistId
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function save (res) {
|
|
41
|
+
const { syncType } = props
|
|
42
|
+
const up = {
|
|
43
|
+
[syncType + 'AccessToken']: res.token
|
|
44
|
+
}
|
|
45
|
+
if (res.gistId) {
|
|
46
|
+
up[syncType + 'GistId'] = res.gistId
|
|
47
|
+
}
|
|
48
|
+
if (res.syncPassword) {
|
|
49
|
+
up[syncType + 'SyncPassword'] = res.syncPassword
|
|
50
|
+
}
|
|
51
|
+
if (res.apiUrl) {
|
|
52
|
+
up[syncType + 'ApiUrl'] = res.apiUrl
|
|
53
|
+
}
|
|
54
|
+
props.store.updateSyncSetting(up)
|
|
55
|
+
const test = await props.store.testSyncToken(syncType, res.gistId)
|
|
56
|
+
if (!test) {
|
|
57
|
+
return notification.error({
|
|
58
|
+
message: 'token invalid'
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
if (!res.gistId) {
|
|
62
|
+
props.store.createGist(syncType)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function upload () {
|
|
67
|
+
props
|
|
68
|
+
.store
|
|
69
|
+
.uploadSetting(props.syncType)
|
|
70
|
+
.catch(props.store.onError)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function download () {
|
|
74
|
+
props
|
|
75
|
+
.store
|
|
76
|
+
.downloadSetting(props.syncType)
|
|
77
|
+
.catch(props.store.onError)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// onChangeAutoSync = checked => {
|
|
81
|
+
// this.props.store.updateSyncSetting({
|
|
82
|
+
// autoSync: checked
|
|
83
|
+
// })
|
|
84
|
+
// }
|
|
85
|
+
|
|
86
|
+
function getTokenCreateGuideUrl () {
|
|
87
|
+
return syncTokenCreateUrls[props.syncType]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function renderGistUrl () {
|
|
91
|
+
if (!props.formData.url) {
|
|
92
|
+
return null
|
|
93
|
+
}
|
|
94
|
+
return (
|
|
95
|
+
<Link to={props.formData.url}>Check gist</Link>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const {
|
|
100
|
+
lastSyncTime = ''
|
|
101
|
+
} = props.formData
|
|
102
|
+
const { syncType } = props
|
|
103
|
+
const isCustom = syncType === syncTypes.custom
|
|
104
|
+
const timeFormatted = lastSyncTime
|
|
105
|
+
? dayjs(lastSyncTime).format('YYYY-MM-DD HH:mm:ss')
|
|
106
|
+
: '-'
|
|
107
|
+
const customNameMapper = {
|
|
108
|
+
token: 'JWT Secret',
|
|
109
|
+
gist: 'User ID'
|
|
110
|
+
}
|
|
111
|
+
const otherNameMapper = {
|
|
112
|
+
token: 'access token',
|
|
113
|
+
gist: 'gist id'
|
|
114
|
+
}
|
|
115
|
+
function createLabel (name, text) {
|
|
116
|
+
return (
|
|
117
|
+
<span>
|
|
118
|
+
{isCustom ? (customNameMapper[name] || name) : name}
|
|
119
|
+
<HelpIcon link={getTokenCreateGuideUrl()} />
|
|
120
|
+
</span>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
function createPlaceHolder (name) {
|
|
124
|
+
if (syncType === syncTypes.custom) {
|
|
125
|
+
return customNameMapper[name]
|
|
126
|
+
}
|
|
127
|
+
return syncType + ' ' + otherNameMapper[name]
|
|
128
|
+
}
|
|
129
|
+
function createId (name) {
|
|
130
|
+
return 'sync-input-' + name + '-' + syncType
|
|
131
|
+
}
|
|
132
|
+
function createUrlItem () {
|
|
133
|
+
if (syncType !== syncTypes.custom) {
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
return (
|
|
137
|
+
<FormItem
|
|
138
|
+
label={createLabel('API Url')}
|
|
139
|
+
name='apiUrl'
|
|
140
|
+
rules={[{
|
|
141
|
+
max: 200, message: '200 chars max'
|
|
142
|
+
}]}
|
|
143
|
+
>
|
|
144
|
+
<Input
|
|
145
|
+
placeholder='API Url'
|
|
146
|
+
id='sync-input-url-custom'
|
|
147
|
+
/>
|
|
148
|
+
</FormItem>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
const desc = syncType === syncTypes.custom
|
|
152
|
+
? 'jwt secret'
|
|
153
|
+
: 'personal access token'
|
|
154
|
+
const idDesc = syncType === syncTypes.custom
|
|
155
|
+
? 'user id'
|
|
156
|
+
: 'gist ID'
|
|
157
|
+
const tokenLabel = createLabel('token', desc)
|
|
158
|
+
const gistLabel = createLabel('gist', idDesc)
|
|
159
|
+
const syncPasswordName = s('encrypt') + ' ' + e('password')
|
|
160
|
+
const syncPasswordLabel = createLabel(syncPasswordName, '')
|
|
161
|
+
return (
|
|
162
|
+
<Form
|
|
163
|
+
onFinish={save}
|
|
164
|
+
form={form}
|
|
165
|
+
className='form-wrap pd1x'
|
|
166
|
+
name={'setting-sync-form' + syncType}
|
|
167
|
+
layout='vertical'
|
|
168
|
+
initialValues={props.formData}
|
|
169
|
+
>
|
|
170
|
+
{createUrlItem()}
|
|
171
|
+
<FormItem
|
|
172
|
+
label={tokenLabel}
|
|
173
|
+
hasFeedback
|
|
174
|
+
name='token'
|
|
175
|
+
rules={[{
|
|
176
|
+
max: 100, message: '100 chars max'
|
|
177
|
+
}, {
|
|
178
|
+
required: true, message: createPlaceHolder('token') + ' required'
|
|
179
|
+
}]}
|
|
180
|
+
>
|
|
181
|
+
<Input.Password
|
|
182
|
+
placeholder={createPlaceHolder('token')}
|
|
183
|
+
id={createId('token')}
|
|
184
|
+
/>
|
|
185
|
+
</FormItem>
|
|
186
|
+
<FormItem
|
|
187
|
+
label={gistLabel}
|
|
188
|
+
name='gistId'
|
|
189
|
+
rules={[{
|
|
190
|
+
max: 100, message: '100 chars max'
|
|
191
|
+
}]}
|
|
192
|
+
>
|
|
193
|
+
<Input
|
|
194
|
+
placeholder={createPlaceHolder('gistId')}
|
|
195
|
+
id={createId('gistId')}
|
|
196
|
+
/>
|
|
197
|
+
</FormItem>
|
|
198
|
+
<FormItem
|
|
199
|
+
label={syncPasswordLabel}
|
|
200
|
+
hasFeedback
|
|
201
|
+
name='syncPassword'
|
|
202
|
+
rules={[{
|
|
203
|
+
max: 100, message: '100 chars max'
|
|
204
|
+
}]}
|
|
205
|
+
>
|
|
206
|
+
<Input.Password
|
|
207
|
+
placeholder={syncType + ' ' + syncPasswordName}
|
|
208
|
+
/>
|
|
209
|
+
</FormItem>
|
|
210
|
+
{/* <FormItem
|
|
211
|
+
{...formItemLayout}
|
|
212
|
+
label={ss('autoSync')}
|
|
213
|
+
>
|
|
214
|
+
<Switch
|
|
215
|
+
checked={autoSync}
|
|
216
|
+
disabled={this.disabled()}
|
|
217
|
+
onChange={this.onChangeAutoSync}
|
|
218
|
+
/>
|
|
219
|
+
</FormItem> */}
|
|
220
|
+
<FormItem>
|
|
221
|
+
<p>
|
|
222
|
+
<Button
|
|
223
|
+
type='dashed'
|
|
224
|
+
className='mg1r mg1b sync-btn-save'
|
|
225
|
+
htmlType='submit'
|
|
226
|
+
icon={<SaveOutlined />}
|
|
227
|
+
>{e('save')}
|
|
228
|
+
</Button>
|
|
229
|
+
{/* <Button
|
|
230
|
+
type='dashed'
|
|
231
|
+
onClick={this.sync}
|
|
232
|
+
disabled={this.disabled()}
|
|
233
|
+
className='mg1r'
|
|
234
|
+
loading={isSyncingSetting}
|
|
235
|
+
icon='swap'
|
|
236
|
+
>{ss('sync')}</Button> */}
|
|
237
|
+
<Button
|
|
238
|
+
type='dashed'
|
|
239
|
+
onClick={upload}
|
|
240
|
+
disabled={disabled()}
|
|
241
|
+
className='mg1r mg1b'
|
|
242
|
+
icon={<ArrowUpOutlined />}
|
|
243
|
+
>{ss('uploadSettings')}
|
|
244
|
+
</Button>
|
|
245
|
+
<Button
|
|
246
|
+
type='dashed'
|
|
247
|
+
onClick={download}
|
|
248
|
+
disabled={disabled()}
|
|
249
|
+
className='mg1r mg1b sync-btn-down'
|
|
250
|
+
icon={<ArrowDownOutlined />}
|
|
251
|
+
>{ss('downloadSettings')}
|
|
252
|
+
</Button>
|
|
253
|
+
<Button
|
|
254
|
+
type='dashed'
|
|
255
|
+
onClick={props.store.handleClearSyncSetting}
|
|
256
|
+
disabled={disabled()}
|
|
257
|
+
className='mg1r mg1b sync-btn-clear'
|
|
258
|
+
icon={<ClearOutlined />}
|
|
259
|
+
>{sh('clear')}
|
|
260
|
+
</Button>
|
|
261
|
+
</p>
|
|
262
|
+
<p>
|
|
263
|
+
{ss('lastSyncTime')}: {timeFormatted}
|
|
264
|
+
</p>
|
|
265
|
+
<p>
|
|
266
|
+
{renderGistUrl()}
|
|
267
|
+
</p>
|
|
268
|
+
</FormItem>
|
|
269
|
+
</Form>
|
|
270
|
+
)
|
|
271
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sync setting module entry
|
|
3
|
+
*/
|
|
4
|
+
import { Component } from '../common/react-subx'
|
|
5
|
+
import { Tabs, Spin } from 'antd'
|
|
6
|
+
import SyncForm from './setting-sync-form'
|
|
7
|
+
import { syncTypes } from '../../common/constants'
|
|
8
|
+
import { DataTransport } from './data-import'
|
|
9
|
+
import { pick } from 'lodash-es'
|
|
10
|
+
|
|
11
|
+
export default class SyncSettingEntry extends Component {
|
|
12
|
+
handleChange = (key) => {
|
|
13
|
+
this.props.store.syncType = key
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
renderForm () {
|
|
17
|
+
const {
|
|
18
|
+
store
|
|
19
|
+
} = this.props
|
|
20
|
+
const {
|
|
21
|
+
syncSetting
|
|
22
|
+
} = store.config
|
|
23
|
+
const syncProps = {
|
|
24
|
+
store,
|
|
25
|
+
...syncSetting,
|
|
26
|
+
...pick(store, [
|
|
27
|
+
'autofocustrigger',
|
|
28
|
+
'isSyncingSetting',
|
|
29
|
+
'isSyncDownload',
|
|
30
|
+
'isSyncUpload',
|
|
31
|
+
'syncType'
|
|
32
|
+
])
|
|
33
|
+
}
|
|
34
|
+
const type = store.syncType
|
|
35
|
+
const formData = {
|
|
36
|
+
gistId: syncSetting[type + 'GistId'],
|
|
37
|
+
token: syncSetting[type + 'AccessToken'],
|
|
38
|
+
url: syncSetting[type + 'Url'],
|
|
39
|
+
apiUrl: syncSetting[type + 'ApiUrl'],
|
|
40
|
+
lastSyncTime: syncSetting[type + 'LastSyncTime'],
|
|
41
|
+
syncPassword: syncSetting[type + 'SyncPassword']
|
|
42
|
+
}
|
|
43
|
+
return (
|
|
44
|
+
<SyncForm
|
|
45
|
+
{...syncProps}
|
|
46
|
+
syncType={type}
|
|
47
|
+
encrypt={syncSetting.syncEncrypt}
|
|
48
|
+
formData={formData}
|
|
49
|
+
/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
render () {
|
|
54
|
+
const {
|
|
55
|
+
store
|
|
56
|
+
} = this.props
|
|
57
|
+
|
|
58
|
+
const syncItems = Object.keys(syncTypes).map(type => {
|
|
59
|
+
return {
|
|
60
|
+
key: type,
|
|
61
|
+
label: type,
|
|
62
|
+
children: null
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
return (
|
|
66
|
+
<div className='pd2l'>
|
|
67
|
+
<DataTransport store={store} />
|
|
68
|
+
<Spin spinning={store.isSyncingSetting}>
|
|
69
|
+
<Tabs
|
|
70
|
+
activeKey={store.syncType}
|
|
71
|
+
onChange={this.handleChange}
|
|
72
|
+
items={syncItems}
|
|
73
|
+
/>
|
|
74
|
+
{
|
|
75
|
+
this.renderForm()
|
|
76
|
+
}
|
|
77
|
+
</Spin>
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArrowUpOutlined,
|
|
3
|
+
EyeInvisibleFilled,
|
|
4
|
+
EyeFilled,
|
|
5
|
+
ReloadOutlined,
|
|
6
|
+
ArrowRightOutlined,
|
|
7
|
+
LoadingOutlined
|
|
8
|
+
} from '@ant-design/icons'
|
|
9
|
+
import {
|
|
10
|
+
Input,
|
|
11
|
+
Tooltip
|
|
12
|
+
} from 'antd'
|
|
13
|
+
import {
|
|
14
|
+
typeMap
|
|
15
|
+
} from '../../common/constants'
|
|
16
|
+
import classnames from 'classnames'
|
|
17
|
+
import AddrBookmark from './address-bookmark'
|
|
18
|
+
|
|
19
|
+
const { prefix } = window
|
|
20
|
+
const e = prefix('sftp')
|
|
21
|
+
|
|
22
|
+
function renderAddonBefore (props, realPath) {
|
|
23
|
+
const {
|
|
24
|
+
type,
|
|
25
|
+
host
|
|
26
|
+
} = props
|
|
27
|
+
const isShow = props[`${type}ShowHiddenFile`]
|
|
28
|
+
const title = `${isShow ? e('hide') : e('show')} ${e('hfd')}`
|
|
29
|
+
const Icon = isShow ? EyeFilled : EyeInvisibleFilled
|
|
30
|
+
return (
|
|
31
|
+
<div>
|
|
32
|
+
<Tooltip
|
|
33
|
+
title={title}
|
|
34
|
+
placement='topLeft'
|
|
35
|
+
arrow={{ pointAtCenter: true }}
|
|
36
|
+
>
|
|
37
|
+
<Icon
|
|
38
|
+
type='eye'
|
|
39
|
+
className='mg1r'
|
|
40
|
+
onClick={() => props.toggleShowHiddenFile(type)}
|
|
41
|
+
/>
|
|
42
|
+
</Tooltip>
|
|
43
|
+
<Tooltip
|
|
44
|
+
title={e('goParent')}
|
|
45
|
+
arrow={{ pointAtCenter: true }}
|
|
46
|
+
placement='topLeft'
|
|
47
|
+
>
|
|
48
|
+
<ArrowUpOutlined
|
|
49
|
+
onClick={() => props.goParent(type)}
|
|
50
|
+
className='mg1r'
|
|
51
|
+
/>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
<AddrBookmark
|
|
54
|
+
store={window.store}
|
|
55
|
+
realPath={realPath}
|
|
56
|
+
host={host}
|
|
57
|
+
type={type}
|
|
58
|
+
onClickHistory={props.onClickHistory}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function renderAddonAfter (isLoadingRemote, onGoto, GoIcon, type) {
|
|
65
|
+
return (
|
|
66
|
+
<GoIcon
|
|
67
|
+
onClick={isLoadingRemote ? () => null : () => onGoto(type)}
|
|
68
|
+
/>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function renderHistory (props, type) {
|
|
73
|
+
const currentPath = props[type + 'Path']
|
|
74
|
+
const options = props[type + 'PathHistory']
|
|
75
|
+
.filter(o => o !== currentPath)
|
|
76
|
+
const focused = props[type + 'InputFocus']
|
|
77
|
+
if (!options.length) {
|
|
78
|
+
return null
|
|
79
|
+
}
|
|
80
|
+
const cls = classnames(
|
|
81
|
+
'sftp-history',
|
|
82
|
+
'animated',
|
|
83
|
+
`sftp-history-${type}`,
|
|
84
|
+
{ focused }
|
|
85
|
+
)
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
className={cls}
|
|
89
|
+
>
|
|
90
|
+
{
|
|
91
|
+
options.map(o => {
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
key={o}
|
|
95
|
+
className='sftp-history-item'
|
|
96
|
+
onClick={() => props.onClickHistory(type, o)}
|
|
97
|
+
>
|
|
98
|
+
{o}
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default function AddressBar (props) {
|
|
108
|
+
const {
|
|
109
|
+
loadingSftp,
|
|
110
|
+
type,
|
|
111
|
+
onGoto
|
|
112
|
+
} = props
|
|
113
|
+
const n = `${type}PathTemp`
|
|
114
|
+
const path = props[n]
|
|
115
|
+
const realPath = props[`${type}Path`]
|
|
116
|
+
const isLoadingRemote = type === typeMap.remote && loadingSftp
|
|
117
|
+
const GoIcon = isLoadingRemote
|
|
118
|
+
? LoadingOutlined
|
|
119
|
+
: (realPath === path ? ReloadOutlined : ArrowRightOutlined)
|
|
120
|
+
return (
|
|
121
|
+
<div className='pd1y sftp-title-wrap'>
|
|
122
|
+
<div className='sftp-title'>
|
|
123
|
+
<Input
|
|
124
|
+
value={path}
|
|
125
|
+
onChange={e => props.onChange(e, n)}
|
|
126
|
+
onPressEnter={e => props.onGoto(type, e)}
|
|
127
|
+
addonBefore={renderAddonBefore(props, realPath)}
|
|
128
|
+
onFocus={() => props.onInputFocus(type)}
|
|
129
|
+
onBlur={() => props.onInputBlur(type)}
|
|
130
|
+
disabled={loadingSftp}
|
|
131
|
+
addonAfter={
|
|
132
|
+
renderAddonAfter(isLoadingRemote, onGoto, GoIcon, type)
|
|
133
|
+
}
|
|
134
|
+
/>
|
|
135
|
+
{renderHistory(props, type)}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Component } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
CloseCircleOutlined
|
|
4
|
+
} from '@ant-design/icons'
|
|
5
|
+
|
|
6
|
+
export default class AddrBookmarkItem extends Component {
|
|
7
|
+
handleClick = () => {
|
|
8
|
+
const {
|
|
9
|
+
handleClick,
|
|
10
|
+
item,
|
|
11
|
+
type
|
|
12
|
+
} = this.props
|
|
13
|
+
handleClick(
|
|
14
|
+
type, item.addr
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
handleDel = (e) => {
|
|
19
|
+
e.stopPropagation()
|
|
20
|
+
const {
|
|
21
|
+
handleDel,
|
|
22
|
+
item
|
|
23
|
+
} = this.props
|
|
24
|
+
handleDel(
|
|
25
|
+
item
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render () {
|
|
30
|
+
const {
|
|
31
|
+
item
|
|
32
|
+
} = this.props
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
key={item.id}
|
|
36
|
+
className='sftp-history-item addr-bookmark-item'
|
|
37
|
+
onClick={this.handleClick}
|
|
38
|
+
>
|
|
39
|
+
{item.addr}
|
|
40
|
+
<CloseCircleOutlined
|
|
41
|
+
className='del-addr-bookmark'
|
|
42
|
+
onClick={this.handleDel}
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
}
|