@electerm/electerm-react 1.40.20 → 1.50.31

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 (104) hide show
  1. package/client/common/constants.js +57 -7
  2. package/client/common/new-terminal.js +2 -2
  3. package/client/components/auth/login.jsx +34 -57
  4. package/client/components/batch-op/batch-op.jsx +12 -11
  5. package/client/components/bookmark-form/index.jsx +2 -2
  6. package/client/components/bookmark-form/ssh-form.jsx +4 -1
  7. package/client/components/bookmark-form/tree-delete.jsx +5 -5
  8. package/client/components/context-menu/boomarks.jsx +8 -12
  9. package/client/components/context-menu/context-menu.jsx +10 -10
  10. package/client/components/context-menu/history.jsx +21 -24
  11. package/client/components/context-menu/menu-btn.jsx +11 -11
  12. package/client/components/context-menu/tabs.jsx +15 -19
  13. package/client/components/context-menu/zoom.jsx +25 -29
  14. package/client/components/footer/footer-entry.jsx +56 -56
  15. package/client/components/icons/split-icons.jsx +77 -0
  16. package/client/components/layout/layout-alg.js +260 -0
  17. package/client/components/layout/layout-item.jsx +94 -0
  18. package/client/components/layout/layout.jsx +167 -0
  19. package/client/components/layout/layout.styl +8 -0
  20. package/client/components/layout/layouts.jsx +72 -0
  21. package/client/components/layout/session-size-alg.js +31 -0
  22. package/client/components/main/custom-css.jsx +1 -1
  23. package/client/components/main/main.jsx +184 -110
  24. package/client/components/main/ui-theme.jsx +1 -1
  25. package/client/components/main/wrapper.styl +2 -4
  26. package/client/components/profile/profile-list.jsx +1 -3
  27. package/client/components/profile/profile-transport-mod.jsx +1 -1
  28. package/client/components/profile/profile-transport.jsx +6 -9
  29. package/client/components/quick-commands/quick-command-transport.jsx +6 -9
  30. package/client/components/quick-commands/quick-commands-box.jsx +144 -153
  31. package/client/components/quick-commands/quick-commands-select.jsx +10 -3
  32. package/client/components/rdp/rdp-session.jsx +3 -23
  33. package/client/components/rdp/resolution-edit.jsx +40 -42
  34. package/client/components/session/session.jsx +63 -328
  35. package/client/components/session/session.styl +1 -5
  36. package/client/components/session/sessions.jsx +140 -111
  37. package/client/components/setting-panel/bookmark-tree-list.jsx +1 -1
  38. package/client/components/setting-panel/setting-common.jsx +6 -4
  39. package/client/components/setting-panel/setting-modal.jsx +31 -31
  40. package/client/components/setting-panel/start-session-select.jsx +4 -4
  41. package/client/components/setting-panel/tab-settings.jsx +27 -5
  42. package/client/components/setting-sync/data-import.jsx +36 -39
  43. package/client/components/setting-sync/setting-sync-form.jsx +10 -10
  44. package/client/components/setting-sync/setting-sync.jsx +50 -52
  45. package/client/components/sftp/address-bookmark.jsx +57 -58
  46. package/client/components/sftp/confirm-modal-store.jsx +34 -40
  47. package/client/components/sftp/file-item.jsx +14 -3
  48. package/client/components/sftp/file-mode-modal.jsx +3 -0
  49. package/client/components/sftp/list-table-ui.jsx +4 -4
  50. package/client/components/sftp/sftp-entry.jsx +2 -2
  51. package/client/components/sftp/transfer-conflict-store.jsx +13 -17
  52. package/client/components/sftp/transport-action-store.jsx +38 -31
  53. package/client/components/sftp/transports-action-store.jsx +3 -3
  54. package/client/components/sftp/transports-ui-store.jsx +18 -23
  55. package/client/components/shortcuts/shortcut-handler.js +1 -0
  56. package/client/components/shortcuts/shortcuts-defaults.js +5 -5
  57. package/client/components/shortcuts/shortcuts.jsx +9 -12
  58. package/client/components/side-panel-r/right-side-panel.styl +40 -0
  59. package/client/components/side-panel-r/side-panel-r.jsx +102 -0
  60. package/client/components/sidebar/bookmark-select.jsx +40 -40
  61. package/client/components/sidebar/bookmark.jsx +63 -65
  62. package/client/components/sidebar/history.jsx +53 -50
  63. package/client/components/sidebar/index.jsx +195 -184
  64. package/client/components/sidebar/info-modal.jsx +202 -202
  65. package/client/components/sidebar/sidebar.styl +8 -2
  66. package/client/components/sidebar/transfer-history-modal.jsx +95 -100
  67. package/client/components/sidebar/transfer-list-control.jsx +2 -2
  68. package/client/components/sidebar/transfer-list.jsx +45 -42
  69. package/client/components/sidebar/transfer-modal.jsx +49 -52
  70. package/client/components/sidebar/transport-ui.jsx +1 -1
  71. package/client/components/tabs/index.jsx +261 -49
  72. package/client/components/tabs/tab.jsx +48 -66
  73. package/client/components/tabs/tabs.styl +6 -1
  74. package/client/components/tabs/window-control.jsx +46 -48
  75. package/client/components/terminal/attach-addon-custom.js +1 -1
  76. package/client/components/terminal/index.jsx +111 -113
  77. package/client/components/terminal/term-search.jsx +26 -24
  78. package/client/components/terminal-info/run-cmd.jsx +0 -25
  79. package/client/components/terminal-info/terminal-info.jsx +60 -0
  80. package/client/components/terminal-info/terminal-info.styl +1 -1
  81. package/client/components/tree-list/bookmark-transport.jsx +8 -9
  82. package/client/components/tree-list/tree-list.jsx +36 -26
  83. package/client/components/vnc/vnc-session.jsx +1 -6
  84. package/client/components/web/address-bar.jsx +50 -0
  85. package/client/components/web/web-session.jsx +32 -10
  86. package/client/entry/index.jsx +5 -6
  87. package/client/store/common.js +1 -1
  88. package/client/store/db-upgrade.js +1 -1
  89. package/client/store/event.js +2 -2
  90. package/client/store/index.js +21 -32
  91. package/client/store/init-state.js +15 -3
  92. package/client/store/load-data.js +1 -1
  93. package/client/store/quick-command.js +4 -4
  94. package/client/store/session.js +1 -1
  95. package/client/store/setting.js +10 -6
  96. package/client/store/system-menu.js +1 -10
  97. package/client/store/tab.js +91 -1
  98. package/client/store/transfer-list.js +5 -6
  99. package/client/store/watch.js +11 -6
  100. package/package.json +1 -1
  101. package/client/components/common/react-subx.jsx +0 -1
  102. package/client/components/common/resize-wrap.jsx +0 -222
  103. package/client/components/common/resize-wrap.styl +0 -9
  104. package/client/components/terminal-info/content.jsx +0 -152
@@ -117,8 +117,9 @@ export default class Sftp extends Component {
117
117
  componentWillUnmount () {
118
118
  this.destroyEvent()
119
119
  this.sftp && this.sftp.destroy()
120
- delete this.sftp
120
+ this.sftp = null
121
121
  clearTimeout(this.timer4)
122
+ this.timer4 = null
122
123
  }
123
124
 
124
125
  directions = [
@@ -624,7 +625,6 @@ export default class Sftp extends Component {
624
625
  proxy: getProxy(tab, config),
625
626
  ...sessionOptions
626
627
  })
627
- delete opts.terminals
628
628
  const r = await sftp.connect(opts)
629
629
  .catch(e => {
630
630
  if (
@@ -3,7 +3,7 @@
3
3
  * when list changes, do transfer and other op
4
4
  */
5
5
 
6
- import { Component } from '../common/react-subx'
6
+ import { PureComponent } from 'react'
7
7
  import { typeMap } from '../../common/constants'
8
8
  import {
9
9
  getLocalFileInfo,
@@ -16,7 +16,7 @@ import { findIndex, find } from 'lodash-es'
16
16
  import generate from '../../common/uid'
17
17
  import resolve from '../../common/resolve'
18
18
 
19
- export default class TransferConflictStore extends Component {
19
+ export default class TransferConflictStore extends PureComponent {
20
20
  state = {
21
21
  currentId: ''
22
22
  }
@@ -79,10 +79,8 @@ export default class TransferConflictStore extends Component {
79
79
  fromFile
80
80
  } = transfer
81
81
  this.clear()
82
- const { store } = this.props
83
- let {
84
- fileTransfers
85
- } = store
82
+ let { fileTransfers } = this.props
83
+ const { store } = window
86
84
  const index = findIndex(fileTransfers, d => d.id === id)
87
85
  if (index < 0) {
88
86
  return store.setFileTransfers(fileTransfers)
@@ -114,15 +112,13 @@ export default class TransferConflictStore extends Component {
114
112
  }
115
113
 
116
114
  tagTransferError = (id, errorMsg) => {
117
- const { store } = this.props
118
- const {
119
- fileTransfers
120
- } = store
115
+ const { fileTransfers } = this.props
121
116
  const tr = find(fileTransfers, d => d.id === id)
122
117
  if (!tr) {
123
118
  return
124
119
  }
125
- window.store.addTransferHistory({
120
+ const { store } = window
121
+ store.addTransferHistory({
126
122
  ...tr,
127
123
  host: tr.host,
128
124
  error: errorMsg,
@@ -136,7 +132,7 @@ export default class TransferConflictStore extends Component {
136
132
  }
137
133
 
138
134
  setConflict (tr) {
139
- if (window.store.transferToConfirm.id) {
135
+ if (this.props.transferToConfirm.id) {
140
136
  return
141
137
  }
142
138
  window.store.setState(
@@ -165,10 +161,10 @@ export default class TransferConflictStore extends Component {
165
161
  this.clear()
166
162
  const {
167
163
  store
168
- } = this.props
164
+ } = window
169
165
  const {
170
166
  fileTransfers
171
- } = store
167
+ } = this.props
172
168
  const index = findIndex(fileTransfers, t => {
173
169
  return t.id === tr.id
174
170
  })
@@ -178,7 +174,7 @@ export default class TransferConflictStore extends Component {
178
174
  fromFile
179
175
  }
180
176
  Object.assign(fileTransfers[index], up)
181
- } else {
177
+ } else if (fileTransfers[0]) {
182
178
  fileTransfers[0].r = Math.random()
183
179
  }
184
180
  store.setFileTransfers(fileTransfers)
@@ -189,10 +185,10 @@ export default class TransferConflictStore extends Component {
189
185
  }
190
186
 
191
187
  watchFile = async () => {
192
- const { store } = this.props
188
+ const { store } = window
193
189
  const {
194
190
  fileTransfers
195
- } = store
191
+ } = this.props
196
192
  if (!fileTransfers.length && this.currentId) {
197
193
  return this.clear()
198
194
  }
@@ -1,4 +1,4 @@
1
- import { Component } from '../common/react-subx'
1
+ import { Component } from 'react'
2
2
  import copy from 'json-deep-copy'
3
3
  import { findIndex, isFunction } from 'lodash-es'
4
4
  import generate from '../../common/uid'
@@ -51,16 +51,23 @@ export default class TransportAction extends Component {
51
51
  }
52
52
  }
53
53
 
54
+ componentWillUnmount () {
55
+ this.transport && this.transport.destroy()
56
+ this.transport = null
57
+ clearTimeout(this.timer)
58
+ this.timer = null
59
+ }
60
+
54
61
  update = (up) => {
55
- const { store, transfer } = this.props
62
+ const { fileTransfers, transfer } = this.props
56
63
  const {
57
- fileTransfers
58
- } = store
64
+ store
65
+ } = window
59
66
  const index = findIndex(fileTransfers, t => t.id === transfer.id)
60
67
  if (index < 0) {
61
68
  return store.setFileTransfers(fileTransfers)
62
69
  }
63
- window.store.editTransfer(
70
+ store.editTransfer(
64
71
  fileTransfers[index].id,
65
72
  up
66
73
  )
@@ -69,13 +76,10 @@ export default class TransportAction extends Component {
69
76
  }
70
77
 
71
78
  insert = (insts) => {
72
- const { store, transfer } = this.props
73
- const {
74
- fileTransfers
75
- } = store
79
+ const { fileTransfers, transfer } = this.props
76
80
  const index = findIndex(fileTransfers, t => t.id === transfer.id)
77
81
  fileTransfers.splice(index, 1, ...insts)
78
- store.setFileTransfers(fileTransfers)
82
+ window.store.setFileTransfers(fileTransfers)
79
83
  }
80
84
 
81
85
  remoteList = () => {
@@ -95,11 +99,12 @@ export default class TransportAction extends Component {
95
99
  }
96
100
 
97
101
  onEnd = (update = {}) => {
98
- if (this.inst.onCancel) {
102
+ if (this.onCancel) {
99
103
  return
100
104
  }
101
105
  const {
102
- transfer
106
+ transfer,
107
+ config
103
108
  } = this.props
104
109
  const {
105
110
  typeTo,
@@ -107,16 +112,16 @@ export default class TransportAction extends Component {
107
112
  } = transfer
108
113
  const cb = this[typeTo + 'List']
109
114
  const finishTime = Date.now()
110
- if (!this.props.store.config.disableTransferHistory) {
115
+ if (!config.disableTransferHistory) {
111
116
  window.store.addTransferHistory(
112
117
  {
113
118
  ...transfer,
114
119
  ...update,
115
120
  finishTime,
116
- startTime: this.inst.startTime,
121
+ startTime: this.startTime,
117
122
  size: transfer.fromFile.size,
118
123
  next: null,
119
- speed: format(transfer.fromFile.size, this.inst.startTime)
124
+ speed: format(transfer.fromFile.size, this?.startTime)
120
125
  }
121
126
  )
122
127
  }
@@ -127,7 +132,7 @@ export default class TransportAction extends Component {
127
132
  }
128
133
 
129
134
  onData = (transferred) => {
130
- if (this.inst.onCancel) {
135
+ if (this.onCancel) {
131
136
  return
132
137
  }
133
138
  const { transfer } = this.props
@@ -140,7 +145,7 @@ export default class TransportAction extends Component {
140
145
  up.percent = percent
141
146
  up.status = 'active'
142
147
  up.transferred = transferred
143
- up.startTime = this.inst.startTime
148
+ up.startTime = this.startTime
144
149
  up.speed = format(transferred, up.startTime)
145
150
  Object.assign(
146
151
  up,
@@ -151,34 +156,36 @@ export default class TransportAction extends Component {
151
156
  }
152
157
 
153
158
  cancel = (callback) => {
154
- if (this.inst.onCancel) {
159
+ if (this.onCancel) {
155
160
  return
156
161
  }
162
+ this.onCancel = true
157
163
  const {
158
- transfer,
159
- store
164
+ transfer
160
165
  } = this.props
161
- this.inst.onCancel = true
162
- const { id } = transfer
163
- this.inst.transport && this.inst.transport.destroy()
164
166
  let {
165
167
  fileTransfers
166
- } = store
168
+ } = this.props
169
+ const { id } = transfer
170
+ this.transport && this.transport.destroy()
171
+ this.transport = null
167
172
  fileTransfers = fileTransfers.filter(t => {
168
173
  return t.id !== id
169
174
  })
170
- store.setFileTransfers(fileTransfers)
175
+ this.timer = setTimeout(() => {
176
+ window.store.setFileTransfers(fileTransfers)
177
+ }, 100)
171
178
  if (isFunction(callback)) {
172
179
  callback()
173
180
  }
174
181
  }
175
182
 
176
183
  pause = () => {
177
- this.inst.transport && this.inst.transport.pause()
184
+ this.transport && this.transport.pause()
178
185
  }
179
186
 
180
187
  resume = () => {
181
- this.inst.transport && this.inst.transport.resume()
188
+ this.transport && this.transport.resume()
182
189
  }
183
190
 
184
191
  mvOrCp = () => {
@@ -343,7 +350,7 @@ export default class TransportAction extends Component {
343
350
  : toPath
344
351
  const mode = toFile.mode || fromMode
345
352
  const sftp = window.sftps[this.sessionId]
346
- this.inst.transport = await sftp[transferType]({
353
+ this.transport = await sftp[transferType]({
347
354
  remotePath,
348
355
  localPath,
349
356
  options: { mode },
@@ -358,7 +365,7 @@ export default class TransportAction extends Component {
358
365
  }
359
366
 
360
367
  initTransfer = async () => {
361
- if (this.inst.started) {
368
+ if (this.started) {
362
369
  return
363
370
  }
364
371
  const { transfer } = this.props
@@ -378,8 +385,8 @@ export default class TransportAction extends Component {
378
385
  this.update({
379
386
  startTime: t
380
387
  })
381
- this.inst.startTime = t
382
- this.inst.started = true
388
+ this.startTime = t
389
+ this.started = true
383
390
  if (typeFrom === typeTo) {
384
391
  return this.mvOrCp()
385
392
  } else if (unzip && inited) {
@@ -3,7 +3,7 @@
3
3
  * when list changes, do transfer and other op
4
4
  */
5
5
 
6
- import { Component } from '../common/react-subx'
6
+ import { Component } from 'react'
7
7
  import Transports from './transports-ui-store'
8
8
  import { maxTransport } from '../../common/constants'
9
9
 
@@ -21,10 +21,10 @@ export default class TransportsActionStore extends Component {
21
21
  }
22
22
 
23
23
  control = async () => {
24
- const { store } = this.props
24
+ const { store } = window
25
25
  let {
26
26
  fileTransfers
27
- } = store
27
+ } = this.props
28
28
 
29
29
  fileTransfers = fileTransfers.map(t => {
30
30
  const {
@@ -1,30 +1,25 @@
1
1
  /**
2
2
  * transporter UI component
3
3
  */
4
- import { Component } from '../common/react-subx'
4
+
5
5
  import Transport from './transport-action-store'
6
6
 
7
- export default class TransportsUI extends Component {
8
- render () {
9
- const { store } = this.props
10
- const {
11
- fileTransfers
12
- } = store
13
- if (!fileTransfers.length) {
14
- return null
15
- }
16
- return fileTransfers.map((t, i) => {
17
- const { id } = t
18
- return (
19
- <Transport
20
- {...this.props}
21
- transfer={t}
22
- inited={t.inited}
23
- cancel={t.cancel}
24
- pause={t.pausing}
25
- key={id + ':tr:' + i}
26
- />
27
- )
28
- })
7
+ export default function TransportsUI (props) {
8
+ const { fileTransfers } = props
9
+ if (!fileTransfers.length) {
10
+ return null
29
11
  }
12
+ return fileTransfers.map((t, i) => {
13
+ const { id } = t
14
+ return (
15
+ <Transport
16
+ {...props}
17
+ transfer={t}
18
+ inited={t.inited}
19
+ cancel={t.cancel}
20
+ pause={t.pausing}
21
+ key={id + ':tr:' + i}
22
+ />
23
+ )
24
+ })
30
25
  }
@@ -108,6 +108,7 @@ export function shortcutExtend (Cls) {
108
108
  window.store.runQuickCommandItem(
109
109
  qmMatch.id
110
110
  )
111
+ return false
111
112
  }
112
113
  }
113
114
  for (let i = 0; i < len; i++) {
@@ -10,6 +10,11 @@ export default () => {
10
10
  shortcut: 'alt+r',
11
11
  shortcutMac: 'alt+r'
12
12
  },
13
+ {
14
+ name: 'app_cloneToNextLayout',
15
+ shortcut: 'ctrl+/',
16
+ shortcutMac: 'meta+/'
17
+ },
13
18
  {
14
19
  name: 'app_newBookmark',
15
20
  shortcut: 'ctrl+n',
@@ -40,11 +45,6 @@ export default () => {
40
45
  shortcut: 'ctrl+tab',
41
46
  shortcutMac: 'ctrl+tab'
42
47
  },
43
- {
44
- name: 'terminal_split',
45
- shortcut: 'ctrl+/',
46
- shortcutMac: 'meta+/'
47
- },
48
48
  {
49
49
  name: 'terminal_clear',
50
50
  shortcut: 'ctrl+l,ctrl+shift+l',
@@ -1,4 +1,4 @@
1
- import { Component } from '../common/react-subx'
1
+ import { PureComponent } from 'react'
2
2
  import shortcutsDefaultsGen from './shortcuts-defaults'
3
3
  import ShortcutEdit from './shortcut-editor'
4
4
  import deepCopy from 'json-deep-copy'
@@ -13,24 +13,24 @@ import {
13
13
  const e = window.translate
14
14
  const shortcutsDefaults = shortcutsDefaultsGen()
15
15
 
16
- export default class Shortcuts extends Component {
16
+ export default class Shortcuts extends PureComponent {
17
17
  handleResetAll = () => {
18
- this.props.store.updateConfig({
18
+ window.store.updateConfig({
19
19
  shortcuts: {}
20
20
  })
21
21
  }
22
22
 
23
23
  updateConfig = (name, value) => {
24
- const { store } = this.props
25
- const shortcuts = deepCopy(store.config.shortcuts || {})
24
+ const { config } = this.props
25
+ const shortcuts = deepCopy(config.shortcuts || {})
26
26
  shortcuts[name] = value
27
- this.props.store.updateConfig({
27
+ window.store.updateConfig({
28
28
  shortcuts
29
29
  })
30
30
  }
31
31
 
32
32
  getData () {
33
- const { shortcuts = {} } = this.props.store.config
33
+ const { shortcuts = {} } = this.props.config
34
34
  return shortcutsDefaults
35
35
  .filter(g => !g.readonly)
36
36
  .map((c, i) => {
@@ -46,9 +46,8 @@ export default class Shortcuts extends Component {
46
46
  }
47
47
 
48
48
  getKeysTakenData = () => {
49
- const { store } = this.props
50
- const { shortcuts = {} } = store.config
51
- const { quickCommands = [] } = store
49
+ const { config, quickCommands = [] } = this.props
50
+ const { shortcuts = {} } = config
52
51
 
53
52
  // Gather system shortcuts
54
53
  const systemShortcuts = shortcutsDefaults.reduce((p, k) => {
@@ -84,7 +83,6 @@ export default class Shortcuts extends Component {
84
83
  }
85
84
 
86
85
  render () {
87
- const { store } = this.props
88
86
  const columns = [
89
87
  {
90
88
  title: 'NO.',
@@ -127,7 +125,6 @@ export default class Shortcuts extends Component {
127
125
  <ShortcutEdit
128
126
  data={inst}
129
127
  keysTaken={this.getKeysTakenData()}
130
- store={store}
131
128
  updateConfig={this.updateConfig}
132
129
  />
133
130
  )
@@ -0,0 +1,40 @@
1
+ @require '../../css/includes/theme-default'
2
+
3
+ .right-side-panel
4
+ position absolute
5
+ right 0
6
+ top 0
7
+ bottom 0
8
+ z-index 200
9
+ background main
10
+ color text-light
11
+ border-left 1px solid darken(main, 30%)
12
+
13
+ .drag-handle
14
+ left 0
15
+ right auto
16
+ display block
17
+
18
+ .right-side-panel-controls
19
+ position absolute
20
+ left 10px
21
+ top 10px
22
+ color text-dark
23
+ font-size 16px
24
+ &:hover
25
+ color text
26
+ cursor pointer
27
+ &.right-side-panel-pin
28
+ left 30px
29
+ &.pinned
30
+ color success
31
+ .right-side-panel-content
32
+ padding 10px
33
+ overflow-y scroll
34
+ position absolute
35
+ left 0
36
+ top 30px
37
+ right 0
38
+ bottom 0
39
+ .animate-fast
40
+ animation-duration .2s
@@ -0,0 +1,102 @@
1
+ import React, { useRef, memo } from 'react'
2
+ import './right-side-panel.styl'
3
+ import {
4
+ CloseCircleOutlined,
5
+ PushpinOutlined
6
+ } from '@ant-design/icons'
7
+
8
+ export default memo(function RightSidePanel (
9
+ {
10
+ rightPanelVisible,
11
+ rightPanelPinned,
12
+ rightPanelWidth,
13
+ children
14
+ }
15
+ ) {
16
+ if (!rightPanelVisible) {
17
+ return null
18
+ }
19
+
20
+ const dragStart = useRef(false)
21
+ const clientX = useRef(0)
22
+
23
+ function handleMousedown (e) {
24
+ dragStart.current = true
25
+ clientX.current = e.clientX
26
+ document.body.addEventListener('mouseup', handleMouseup)
27
+ document.body.addEventListener('mousemove', handleMousemove)
28
+ }
29
+
30
+ function handleMouseup (e) {
31
+ dragStart.current = false
32
+ const {
33
+ clientX: cx
34
+ } = e
35
+ let nw = clientX.current - cx + rightPanelWidth
36
+ if (nw < 400) {
37
+ nw = 400
38
+ } else if (nw > 1000) {
39
+ nw = 1000
40
+ }
41
+ window.store.setRightSidePanelWidth(nw)
42
+ document.body.removeEventListener('mouseup', handleMouseup)
43
+ document.body.removeEventListener('mousemove', handleMousemove)
44
+ }
45
+
46
+ function handleMousemove (e) {
47
+ const {
48
+ clientX: cx
49
+ } = e
50
+ const el = document.getElementById('right-side-panel')
51
+ let nw = clientX.current - cx + rightPanelWidth
52
+ if (nw < 400) {
53
+ nw = 400
54
+ } else if (nw > 1000) {
55
+ nw = 1000
56
+ }
57
+ el.style.width = nw + 'px'
58
+ }
59
+
60
+ function onClose () {
61
+ window.store.rightPanelVisible = false
62
+ }
63
+
64
+ function togglePin () {
65
+ window.store.rightPanelPinned = !window.store.rightPanelPinned
66
+ }
67
+
68
+ const panelProps = {
69
+ className: 'right-side-panel animate-fast',
70
+ id: 'right-side-panel',
71
+ style: {
72
+ width: `${rightPanelWidth}px`
73
+ }
74
+ }
75
+
76
+ const pinProps = {
77
+ className: 'right-side-panel-pin right-side-panel-controls' + (rightPanelPinned ? ' pinned' : ''),
78
+ onClick: togglePin
79
+ }
80
+
81
+ return (
82
+ <div
83
+ {...panelProps}
84
+ >
85
+ <div
86
+ className='drag-handle'
87
+ onMouseDown={handleMousedown}
88
+ draggable={false}
89
+ />
90
+ <CloseCircleOutlined
91
+ className='right-side-panel-close right-side-panel-controls'
92
+ onClick={onClose}
93
+ />
94
+ <PushpinOutlined
95
+ {...pinProps}
96
+ />
97
+ <div className='right-side-panel-content'>
98
+ {children}
99
+ </div>
100
+ </div>
101
+ )
102
+ })
@@ -2,47 +2,47 @@
2
2
  * history select
3
3
  */
4
4
 
5
- import { Component } from '../common/react-subx'
5
+ import { auto } from 'manate/react'
6
6
  import TreeList from '../tree-list/tree-list'
7
7
 
8
- export default class BookmarkSelect extends Component {
9
- render () {
10
- const { store, from } = this.props
11
- const {
12
- listStyle,
13
- openedSideBar,
14
- expandedKeys
15
- } = store
16
- if (from === 'sidebar' && openedSideBar !== 'bookmarks') {
17
- return null
18
- }
19
- const onClickItem = (item) => {
20
- if (!store.pinned) {
21
- store.setOpenedSideBar('')
22
- }
23
- store.onSelectBookmark(item.id)
24
- }
25
- const base = {
26
- store,
27
- bookmarks: store.bookmarks || [],
28
- type: 'bookmarks',
29
- onClickItem,
30
- listStyle,
31
- staticList: true
32
- }
33
- if (!store.config.hideSshConfig) {
34
- base.bookmarks.push(...store.sshConfigItems)
35
- }
36
- const propsTree = {
37
- ...base,
38
- shouldConfirmDel: true,
39
- bookmarkGroups: store.getBookmarkGroupsTotal(),
40
- expandedKeys
8
+ export default auto(function BookmarkSelect (props) {
9
+ const { store, from } = props
10
+ const {
11
+ listStyle,
12
+ openedSideBar,
13
+ leftSidebarWidth,
14
+ expandedKeys
15
+ } = store
16
+ if (from === 'sidebar' && openedSideBar !== 'bookmarks') {
17
+ return null
18
+ }
19
+ const onClickItem = (item) => {
20
+ if (!store.pinned) {
21
+ store.setOpenedSideBar('')
41
22
  }
42
- return (
43
- <TreeList
44
- {...propsTree}
45
- />
46
- )
23
+ store.onSelectBookmark(item.id)
24
+ }
25
+ const base = {
26
+ bookmarks: store.bookmarks || [],
27
+ type: 'bookmarks',
28
+ onClickItem,
29
+ listStyle,
30
+ staticList: true
31
+ }
32
+ if (!store.config.hideSshConfig) {
33
+ base.bookmarks.push(...store.sshConfigItems)
34
+ }
35
+ const propsTree = {
36
+ ...base,
37
+ shouldConfirmDel: true,
38
+ bookmarkGroups: store.getBookmarkGroupsTotal(),
39
+ expandedKeys,
40
+ leftSidebarWidth,
41
+ bookmarkGroupTree: store.bookmarkGroupTree
47
42
  }
48
- }
43
+ return (
44
+ <TreeList
45
+ {...propsTree}
46
+ />
47
+ )
48
+ })