@electerm/electerm-react 1.51.3 → 1.51.8

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 (54) hide show
  1. package/client/common/constants.js +1 -2
  2. package/client/common/db.js +10 -9
  3. package/client/components/batch-op/batch-op.jsx +16 -5
  4. package/client/components/bookmark-form/index.jsx +1 -1
  5. package/client/components/bookmark-form/ssh-form.jsx +3 -23
  6. package/client/components/bookmark-form/use-submit.jsx +6 -15
  7. package/client/components/context-menu/context-menu.styl +5 -5
  8. package/client/components/context-menu/history.jsx +2 -11
  9. package/client/components/context-menu/sub-tab-menu.jsx +1 -1
  10. package/client/components/footer/footer-entry.jsx +1 -6
  11. package/client/components/layout/layout-item.jsx +2 -2
  12. package/client/components/main/main.jsx +9 -5
  13. package/client/components/session/session.jsx +15 -1
  14. package/client/components/session/session.styl +3 -2
  15. package/client/components/setting-panel/list.styl +0 -1
  16. package/client/components/setting-panel/on-tree-drop.js +5 -5
  17. package/client/components/setting-panel/setting-modal.jsx +0 -12
  18. package/client/components/sftp/confirm-modal-store.jsx +0 -7
  19. package/client/components/sftp/file-mode-modal.jsx +2 -2
  20. package/client/components/sftp/sftp-entry.jsx +2 -2
  21. package/client/components/sftp/transfer-conflict-store.jsx +69 -66
  22. package/client/components/sftp/transport-action-store.jsx +32 -50
  23. package/client/components/sftp/transports-action-store.jsx +15 -15
  24. package/client/components/sftp/transports-ui-store.jsx +9 -5
  25. package/client/components/sidebar/bookmark-select.jsx +1 -1
  26. package/client/components/sidebar/bookmark.jsx +4 -63
  27. package/client/components/sidebar/history-item.jsx +34 -0
  28. package/client/components/sidebar/history.jsx +17 -52
  29. package/client/components/sidebar/index.jsx +4 -34
  30. package/client/components/sidebar/sidebar-panel.jsx +107 -0
  31. package/client/components/sidebar/sidebar.styl +14 -0
  32. package/client/components/sidebar/transfer-list-control.jsx +1 -0
  33. package/client/components/sidebar/transfer.styl +1 -1
  34. package/client/components/sidebar/transport-ui.jsx +179 -37
  35. package/client/components/tabs/index.jsx +4 -4
  36. package/client/components/tabs/tab.jsx +19 -10
  37. package/client/components/tree-list/tree-list.jsx +8 -10
  38. package/client/entry/worker.js +5 -3
  39. package/client/store/bookmark-group.js +3 -5
  40. package/client/store/common.js +11 -1
  41. package/client/store/db-upgrade.js +0 -2
  42. package/client/store/index.js +0 -3
  43. package/client/store/init-state.js +4 -3
  44. package/client/store/item.js +0 -19
  45. package/client/store/load-data.js +2 -0
  46. package/client/store/setting.js +2 -51
  47. package/client/store/sidebar.js +7 -8
  48. package/client/store/sync.js +7 -7
  49. package/client/store/tab.js +72 -4
  50. package/client/store/transfer-history.js +3 -9
  51. package/client/store/transfer-list.js +75 -75
  52. package/client/store/watch.js +9 -1
  53. package/package.json +1 -1
  54. package/client/components/setting-panel/tab-history.jsx +0 -43
@@ -21,7 +21,7 @@ import {
21
21
  } from 'antd'
22
22
  import createName from '../../common/create-title'
23
23
  import InputAutoFocus from '../common/input-auto-focus'
24
- import { find, uniq, findIndex, isEqual, filter, pick } from 'lodash-es'
24
+ import { find, uniq, isEqual, filter, pick } from 'lodash-es'
25
25
  import {
26
26
  maxBookmarkGroupTitleLength,
27
27
  defaultBookmarkGroupId,
@@ -597,13 +597,13 @@ export default class ItemListTree extends Component {
597
597
  } = window.store
598
598
 
599
599
  if (!pidDragged && !pidDrop) {
600
- const indexDrag = findIndex(bookmarkGroups, item => item.id === idDragged)
600
+ const indexDrag = bookmarkGroups.findIndex(item => item.id === idDragged)
601
601
  if (indexDrag < 0) {
602
602
  return
603
603
  }
604
604
  const dragItem = bookmarkGroups.splice(indexDrag, 1)[0]
605
605
  dragItem.level = 1
606
- const indexDrop = findIndex(bookmarkGroups, item => item.id === idDrop)
606
+ const indexDrop = bookmarkGroups.findIndex(item => item.id === idDrop)
607
607
  if (indexDrop < 0) {
608
608
  return
609
609
  }
@@ -653,7 +653,7 @@ export default class ItemListTree extends Component {
653
653
  )
654
654
  } else {
655
655
  const arr = parentDrop.bookmarkGroupIds || []
656
- let index = findIndex(arr, item => item === idDrop)
656
+ let index = arr.findIndex(item => item === idDrop)
657
657
  if (index < 0) {
658
658
  index = 0
659
659
  }
@@ -704,7 +704,7 @@ export default class ItemListTree extends Component {
704
704
  )
705
705
  } else {
706
706
  const arr = parentDrop.bookmarkIds || []
707
- let index = findIndex(arr, item => item === idDrop)
707
+ let index = arr.findIndex(item => item === idDrop)
708
708
  if (index < 0) {
709
709
  index = 0
710
710
  }
@@ -724,7 +724,7 @@ export default class ItemListTree extends Component {
724
724
  pidDrop &&
725
725
  !pidDragged
726
726
  ) {
727
- const i = findIndex(bookmarkGroups, item => item.id === idDragged)
727
+ const i = bookmarkGroups.findIndex(item => item.id === idDragged)
728
728
  if (i >= 0) {
729
729
  const item = bookmarkGroups[i]
730
730
  item.level = 2
@@ -795,13 +795,11 @@ export default class ItemListTree extends Component {
795
795
  }
796
796
 
797
797
  updateBookmarkGroups = (bookmarkGroups, bookmark, categoryId) => {
798
- let index = findIndex(
799
- bookmarkGroups,
798
+ let index = bookmarkGroups.findIndex(
800
799
  bg => bg.id === categoryId
801
800
  )
802
801
  if (index < 0) {
803
- index = findIndex(
804
- bookmarkGroups,
802
+ index = bookmarkGroups.findIndex(
805
803
  bg => bg.id === defaultBookmarkGroupId
806
804
  )
807
805
  }
@@ -136,6 +136,8 @@ async function onMsg (e) {
136
136
  }
137
137
 
138
138
  self.addEventListener('message', onMsg)
139
- send({
140
- action: 'worker-init'
141
- })
139
+ setTimeout(() => {
140
+ send({
141
+ action: 'worker-init'
142
+ })
143
+ }, 10)
@@ -2,7 +2,7 @@
2
2
  * bookmark group functions
3
3
  */
4
4
 
5
- import { find, findIndex } from 'lodash-es'
5
+ import { find } from 'lodash-es'
6
6
  import {
7
7
  defaultBookmarkGroupId,
8
8
  settingMap,
@@ -82,12 +82,10 @@ export default Store => {
82
82
  const groupIds = groups.map(g => g.id)
83
83
  const updates = []
84
84
  const defaultCatIndex = tobeDel.level !== 2
85
- ? findIndex(
86
- bookmarkGroups,
85
+ ? bookmarkGroups.findIndex(
87
86
  g => g.id === defaultBookmarkGroupId
88
87
  )
89
- : findIndex(
90
- bookmarkGroups,
88
+ : bookmarkGroups.findIndex(
91
89
  g => (g.bookmarkGroupIds || []).includes(tobeDel.id)
92
90
  )
93
91
  for (const g of groups) {
@@ -12,7 +12,8 @@ import {
12
12
  leftSidebarWidthKey,
13
13
  rightSidebarWidthKey,
14
14
  dismissDelKeyTipLsKey,
15
- connectionMap
15
+ connectionMap,
16
+ terminalActions
16
17
  } from '../common/constants'
17
18
  import * as ls from '../common/safe-local-storage'
18
19
 
@@ -46,6 +47,15 @@ export default Store => {
46
47
  })
47
48
  }
48
49
 
50
+ Store.prototype.openInfoPanel = function () {
51
+ const { store } = window
52
+ store.rightPanelVisible = true
53
+ postMessage({
54
+ action: terminalActions.showInfoPanel,
55
+ activeTabId: store.activeTabId
56
+ })
57
+ }
58
+
49
59
  Store.prototype.onResize = debounce(async function () {
50
60
  const { width, height } = await window.pre.runGlobalAsync('getScreenSize')
51
61
  const isMaximized = window.pre.runSync('isMaximized')
@@ -4,7 +4,6 @@
4
4
 
5
5
  import { Modal } from 'antd'
6
6
  import delay from '../common/wait'
7
- import initWatch from './watch'
8
7
 
9
8
  export default (Store) => {
10
9
  Store.prototype.checkForDbUpgrade = async function () {
@@ -14,7 +13,6 @@ export default (Store) => {
14
13
  }
15
14
  const shouldUpgrade = await window.pre.runGlobalAsync('checkDbUpgrade')
16
15
  if (!shouldUpgrade) {
17
- initWatch(store)
18
16
  return false
19
17
  }
20
18
  const {
@@ -238,12 +238,9 @@ const arrGetterProps = [
238
238
  'addressBookmarksLocal',
239
239
  'sshConfigItems',
240
240
  'itermThemes',
241
- 'history',
242
241
  'bookmarks',
243
242
  'bookmarkGroups',
244
243
  'profiles',
245
- 'fileTransfers',
246
- 'transferHistory',
247
244
  'quickCommands',
248
245
  'terminalThemes',
249
246
  'serials',
@@ -48,8 +48,9 @@ export default () => {
48
48
  lastDataUpdateTime: 0,
49
49
  tabs: [],
50
50
  activeTabId: '',
51
- _history: '[]',
51
+ history: ls.getItemJSON('history', []),
52
52
  _bookmarks: '[]',
53
+ sidebarPanelTab: 'bookmarks',
53
54
  _profiles: '[]',
54
55
  _bookmarkGroups: JSON.stringify(
55
56
  getDefaultBookmarkGroups([])
@@ -78,8 +79,8 @@ export default () => {
78
79
  fileOperation: fileOperationsMap.cp, // cp or mv
79
80
  pauseAllTransfer: false,
80
81
  transferTab: 'transfer',
81
- _transferHistory: '[]',
82
- _fileTransfers: '[]',
82
+ transferHistory: [],
83
+ fileTransfers: [],
83
84
  _transferToConfirm: '{}',
84
85
  _sftpSortSetting: ls.getItem(sftpDefaultSortSettingKey) || JSON.stringify({
85
86
  local: {
@@ -4,24 +4,12 @@
4
4
 
5
5
  import { find } from 'lodash-es'
6
6
  import {
7
- maxHistory,
8
7
  settingMap
9
8
  } from '../common/constants'
10
9
  import getInitItem from '../common/init-setting-item'
11
10
  import { update, remove, dbNames } from '../common/db'
12
- import copy from 'json-deep-copy'
13
11
 
14
12
  export default Store => {
15
- Store.prototype.removeOldHistoryFromDb = function (items) {
16
- const arr = items.slice(maxHistory).map(k => {
17
- return {
18
- db: 'history',
19
- id: k.id
20
- }
21
- })
22
- window.store.batchDbDel(arr)
23
- }
24
-
25
13
  Store.prototype.addItem = function (item, type) {
26
14
  return window.store.addItems([item], type)
27
15
  }
@@ -33,12 +21,6 @@ export default Store => {
33
21
  ...objs,
34
22
  ...items
35
23
  ]
36
- if (type === settingMap.history && items.length > maxHistory) {
37
- store.removeOldHistoryFromDb(
38
- copy(items)
39
- )
40
- items.slice(0, maxHistory)
41
- }
42
24
  store.setItems(type, items)
43
25
  if (dbNames.includes(type)) {
44
26
  store.batchDbAdd(
@@ -59,7 +41,6 @@ export default Store => {
59
41
  if (!item) {
60
42
  return
61
43
  }
62
- // let index = findIndex(items, t => t.id === id)
63
44
  Object.assign(item, updates)
64
45
  store.setItems(type, items)
65
46
  if (dbNames.includes(type)) {
@@ -12,6 +12,7 @@ import encodes from '../components/bookmark-form/encodes'
12
12
  import runIdle from '../common/run-idle'
13
13
  import { initWsCommon } from '../common/fetch-from-server'
14
14
  import safeParse from '../common/parse-json-safe'
15
+ import initWatch from './watch'
15
16
 
16
17
  function getHost (argv, opts) {
17
18
  const arr = argv
@@ -201,6 +202,7 @@ export default (Store) => {
201
202
  store.fetchSshConfigItems()
202
203
  }
203
204
  store.initCommandLine().catch(store.onError)
205
+ initWatch(store)
204
206
  if (store.config.checkUpdateOnStart) {
205
207
  store.onCheckUpdate(false)
206
208
  }
@@ -6,7 +6,6 @@ import { find } from 'lodash-es'
6
6
  import {
7
7
  message
8
8
  } from 'antd'
9
- import generate from '../common/uid'
10
9
  import copy from 'json-deep-copy'
11
10
  import {
12
11
  settingMap,
@@ -40,16 +39,6 @@ export default Store => {
40
39
  }
41
40
  )
42
41
  }
43
- Store.prototype.handleEditHistory = function () {
44
- const { store } = window
45
- const all = store.history
46
- store.storeAssign({
47
- settingTab: settingMap.history,
48
- autofocustrigger: Date.now()
49
- })
50
- store.setSettingItem(all[0] || getInitItem([], settingMap.history))
51
- store.openSettingModal()
52
- }
53
42
 
54
43
  Store.prototype.openBookmarkEdit = function (item) {
55
44
  const { store } = window
@@ -71,14 +60,10 @@ export default Store => {
71
60
  store.openSettingModal()
72
61
  }
73
62
 
74
- Store.prototype.onSelectHistory = function (id) {
63
+ Store.prototype.onSelectHistory = function (tab) {
75
64
  const { store } = window
76
- const history = store.history
77
- const item = find(history, it => it.id === id)
78
65
  store.addTab({
79
- ...copy(item),
80
- from: 'history',
81
- srcId: item.id,
66
+ ...copy(tab),
82
67
  ...newTerm(true, true),
83
68
  batch: window.openTabBatch ?? store.currentLayoutBatch
84
69
  })
@@ -87,7 +72,6 @@ export default Store => {
87
72
 
88
73
  Store.prototype.onSelectBookmark = function (id) {
89
74
  const { store } = window
90
- const history = store.history
91
75
  const bookmarks = store.bookmarks
92
76
  const item = copy(
93
77
  find(bookmarks, it => it.id === id) ||
@@ -105,39 +89,6 @@ export default Store => {
105
89
  })
106
90
 
107
91
  delete window.openTabBatch
108
-
109
- if (store.config.disableSshHistory) {
110
- return
111
- }
112
-
113
- // Critical Change: Use bookmarkId for matching instead of history id
114
- const bookmarkId = item.id
115
- const existingIndex = history.findIndex(h => h.bookmarkId === bookmarkId)
116
- if (existingIndex >= 0) {
117
- history[existingIndex].count = (history[existingIndex].count || 0) + 1
118
- history[existingIndex].lastUse = Date.now()
119
- const updatedItem = history.splice(existingIndex, 1)[0]
120
- history.unshift(updatedItem)
121
- } else {
122
- const historyItem = {
123
- ...item,
124
- id: generate(),
125
- bookmarkId,
126
- count: 1,
127
- lastUse: Date.now()
128
- }
129
- history.unshift(historyItem)
130
- }
131
-
132
- history.sort((a, b) => b.count - a.count || b.lastUse - a.lastUse)
133
-
134
- // Optional: Consider max history length
135
- const maxHistoryLength = store.config.maxHistoryLength || 50
136
- if (history.length > maxHistoryLength) {
137
- history.length = maxHistoryLength
138
- }
139
-
140
- store.setItems('history', history)
141
92
  }
142
93
 
143
94
  Store.prototype.openSetting = function () {
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  import {
6
- settingMap,
7
6
  openedSidebarKey,
8
7
  sidebarPinnedKey
9
8
  } from '../common/constants'
@@ -26,11 +25,6 @@ export default Store => {
26
25
  )
27
26
  }
28
27
 
29
- Store.prototype.setOpenedSideBar = function (bar) {
30
- ls.setItem(openedSidebarKey, bar)
31
- window.store.openedSideBar = bar
32
- }
33
-
34
28
  Store.prototype.handlePin = function (pinned) {
35
29
  const { store } = window
36
30
  const current = !store.pinned
@@ -42,7 +36,12 @@ export default Store => {
42
36
  window.store.onNewSsh()
43
37
  }
44
38
 
45
- Store.prototype.onClickHistory = function () {
46
- window.store.handleChangeSettingTab(settingMap.history)
39
+ Store.prototype.handleSidebarPanelTab = function (tab) {
40
+ window.store.sidebarPanelTab = tab
41
+ }
42
+
43
+ Store.prototype.setOpenedSideBar = function (v) {
44
+ ls.setItem(openedSidebarKey, v)
45
+ window.store.openedSideBar = v
47
46
  }
48
47
  }
@@ -2,7 +2,7 @@
2
2
  * sync data to github gist related
3
3
  */
4
4
 
5
- import { get, pick, debounce, findIndex } from 'lodash-es'
5
+ import { get, pick, debounce } from 'lodash-es'
6
6
  import copy from 'json-deep-copy'
7
7
  import {
8
8
  settingMap, packInfo, syncTypes, syncDataMaps
@@ -186,8 +186,8 @@ export default (Store) => {
186
186
  const order = await getData(`${n}:order`)
187
187
  if (order && order.length) {
188
188
  str.sort((a, b) => {
189
- const ai = findIndex(order, r => r === a.id)
190
- const bi = findIndex(order, r => r === b.id)
189
+ const ai = order.findIndex(r => r === a.id)
190
+ const bi = order.findIndex(r => r === b.id)
191
191
  return ai - bi
192
192
  })
193
193
  }
@@ -285,8 +285,8 @@ export default (Store) => {
285
285
  if (isJSON(strOrder)) {
286
286
  strOrder = JSON.parse(strOrder)
287
287
  arr.sort((a, b) => {
288
- const ai = findIndex(strOrder, r => r === a.id)
289
- const bi = findIndex(strOrder, r => r === b.id)
288
+ const ai = strOrder.findIndex(r => r === a.id)
289
+ const bi = strOrder.findIndex(r => r === b.id)
290
290
  return ai - bi
291
291
  })
292
292
  }
@@ -372,8 +372,8 @@ export default (Store) => {
372
372
  const order = await getData(`${n}:order`)
373
373
  if (order && order.length) {
374
374
  objs[n].sort((a, b) => {
375
- const ai = findIndex(order, r => r === a.id)
376
- const bi = findIndex(order, r => r === b.id)
375
+ const ai = order.findIndex(r => r === a.id)
376
+ const bi = order.findIndex(r => r === b.id)
377
377
  return ai - bi
378
378
  })
379
379
  }
@@ -2,16 +2,19 @@
2
2
  * tabs related functions
3
3
  */
4
4
 
5
- import { debounce } from 'lodash-es'
5
+ import { debounce, isEqual } from 'lodash-es'
6
6
  import {
7
7
  splitConfig,
8
8
  statusMap,
9
- paneMap
9
+ paneMap,
10
+ maxHistory
10
11
  } from '../common/constants'
11
12
  import * as ls from '../common/safe-local-storage'
12
13
  import deepCopy from 'json-deep-copy'
13
14
  import generate from '../common/id-with-stamp'
15
+ import uid from '../common/uid'
14
16
  import newTerm from '../common/new-terminal.js'
17
+ import { action } from 'manate'
15
18
 
16
19
  export default Store => {
17
20
  Store.prototype.getTabs = function () {
@@ -82,6 +85,7 @@ export default Store => {
82
85
  }
83
86
 
84
87
  const oldTab = tabs[index]
88
+ const oldBatch = oldTab.batch
85
89
 
86
90
  // Create copy of old tab with new ID
87
91
  const newTab = {
@@ -92,6 +96,7 @@ export default Store => {
92
96
 
93
97
  // Add new tab at next index
94
98
  tabs.splice(index + 1, 0, newTab)
99
+ store.updateHistory(newTab)
95
100
 
96
101
  // Remove old tab
97
102
  tabs.splice(index, 1)
@@ -102,7 +107,7 @@ export default Store => {
102
107
  }
103
108
 
104
109
  // Update batch current tab ID if needed
105
- const batchProp = `activeTabId${oldTab.batch}`
110
+ const batchProp = `activeTabId${oldBatch}`
106
111
  if (store[batchProp] === tabId) {
107
112
  store[batchProp] = newTab.id
108
113
  }
@@ -128,6 +133,7 @@ export default Store => {
128
133
 
129
134
  // Insert the duplicated tab after the source tab
130
135
  tabs.splice(targetIndex + 1, 0, duplicatedTab)
136
+ store.updateHistory(duplicatedTab)
131
137
 
132
138
  // Set the duplicated tab as current
133
139
  store.activeTabId = duplicatedTab.id
@@ -307,6 +313,7 @@ export default Store => {
307
313
  store[`activeTabId${batchNum}`] = newTab.id
308
314
  store.activeTabId = newTab.id
309
315
  store.currentLayoutBatch = batchNum
316
+ store.updateHistory(newTab)
310
317
  }
311
318
 
312
319
  Store.prototype.clickNextTab = debounce(function () {
@@ -380,7 +387,7 @@ export default Store => {
380
387
 
381
388
  // If layout hasn't changed, do nothing
382
389
  if (prevLayout === layout) {
383
- return
390
+ return store.focus()
384
391
  }
385
392
 
386
393
  // Update layout related properties
@@ -413,4 +420,65 @@ export default Store => {
413
420
  }
414
421
  store.focus()
415
422
  }
423
+
424
+ Store.prototype.changeActiveTabId = function (id) {
425
+ const { store } = window
426
+ const { tabs } = store
427
+ const tab = tabs.find(t => t.id === id)
428
+ if (!tab) {
429
+ return
430
+ }
431
+ store.activeTabId = id
432
+ store[`activeTabId${tab.batch}`] = id
433
+ store.focus()
434
+ }
435
+
436
+ Store.prototype.updateHistory = function (tab) {
437
+ if (!tab.type && !tab.host) {
438
+ return
439
+ }
440
+ const { store } = window
441
+ const tabPropertiesExcludes = [
442
+ 'id',
443
+ 'from',
444
+ 'srcId',
445
+ 'status',
446
+ 'pane',
447
+ 'batch'
448
+ ]
449
+ const { history } = store
450
+ const index = history.findIndex(d => {
451
+ for (const key in tab) {
452
+ if (tabPropertiesExcludes.includes(key)) {
453
+ continue
454
+ }
455
+ if (!isEqual(d.tab[key], tab[key])) {
456
+ return false
457
+ }
458
+ }
459
+ return true
460
+ })
461
+ if (index === -1) {
462
+ const copiedTab = deepCopy(tab)
463
+ tabPropertiesExcludes.forEach(d => {
464
+ delete copiedTab[d]
465
+ })
466
+ return history.unshift({
467
+ tab: copiedTab,
468
+ time: Date.now(),
469
+ count: 1,
470
+ id: uid()
471
+ })
472
+ }
473
+ const match = history[index]
474
+ match.count = (match.count || 0) + 1
475
+ match.time = Date.now()
476
+ action(function () {
477
+ const [m] = history.splice(index, 1)
478
+ history.unshift(m)
479
+ if (history.length > maxHistory) {
480
+ history.pop()
481
+ }
482
+ })()
483
+ }
416
484
  }
@@ -4,20 +4,14 @@
4
4
 
5
5
  export default Store => {
6
6
  Store.prototype.clearTransferHistory = function () {
7
- window.store.setItems('transferHistory', [])
7
+ window.store.transferHistory = []
8
8
  }
9
9
 
10
10
  Store.prototype.getTransferHistory = function () {
11
- return window.store.getItems('transferHistory')
11
+ return window.store.transferHistory
12
12
  }
13
13
 
14
14
  Store.prototype.addTransferHistory = function (item) {
15
- const { store } = window
16
- const transferHistory = store.getItems('transferHistory')
17
- transferHistory.unshift(item)
18
- store.setItems(
19
- 'transferHistory',
20
- transferHistory
21
- )
15
+ window.store.transferHistory.unshift(item)
22
16
  }
23
17
  }