@electerm/electerm-react 2.3.151 → 2.3.176

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 (56) hide show
  1. package/client/common/constants.js +4 -2
  2. package/client/common/db.js +2 -1
  3. package/client/common/download.jsx +1 -1
  4. package/client/common/error-handler.jsx +1 -1
  5. package/client/common/fetch.jsx +1 -1
  6. package/client/common/init-setting-item.js +7 -0
  7. package/client/components/common/modal.jsx +89 -0
  8. package/client/components/common/modal.styl +77 -0
  9. package/client/components/common/notification-with-details.jsx +34 -0
  10. package/client/components/file-transfer/conflict-resolve.jsx +2 -1
  11. package/client/components/file-transfer/transfer-speed-format.js +6 -0
  12. package/client/components/file-transfer/transfer.jsx +5 -2
  13. package/client/components/file-transfer/transports-action-store.jsx +14 -1
  14. package/client/components/main/connection-hopping-warnning.jsx +1 -1
  15. package/client/components/main/main.jsx +2 -0
  16. package/client/components/quick-commands/qm.styl +0 -10
  17. package/client/components/quick-commands/quick-command-item.jsx +2 -5
  18. package/client/components/quick-commands/quick-commands-box.jsx +12 -23
  19. package/client/components/setting-panel/setting-common.jsx +4 -3
  20. package/client/components/setting-panel/setting-modal.jsx +2 -1
  21. package/client/components/setting-panel/start-session-select.jsx +146 -21
  22. package/client/components/setting-panel/text-bg-modal.jsx +15 -4
  23. package/client/components/setting-sync/setting-sync-form.jsx +1 -1
  24. package/client/components/sftp/file-info-modal.jsx +2 -1
  25. package/client/components/sftp/file-item.jsx +2 -0
  26. package/client/components/sftp/sftp-entry.jsx +1 -1
  27. package/client/components/sftp/sftp.styl +1 -1
  28. package/client/components/sidebar/info-modal.jsx +53 -34
  29. package/client/components/sidebar/info.styl +0 -7
  30. package/client/components/ssh-config/ssh-config-load-notify.jsx +1 -1
  31. package/client/components/tabs/index.jsx +6 -58
  32. package/client/components/tabs/layout-menu.jsx +75 -0
  33. package/client/components/tabs/layout-select.jsx +60 -0
  34. package/client/components/tabs/tabs.styl +64 -0
  35. package/client/components/tabs/workspace-save-modal.jsx +117 -0
  36. package/client/components/tabs/workspace-select.jsx +79 -0
  37. package/client/components/terminal/attach-addon-custom.js +7 -1
  38. package/client/components/terminal/terminal-interactive.jsx +2 -1
  39. package/client/components/terminal/terminal.jsx +1 -2
  40. package/client/components/text-editor/text-editor.jsx +2 -1
  41. package/client/components/tree-list/move-item-modal.jsx +2 -1
  42. package/client/components/vnc/vnc-session.jsx +2 -2
  43. package/client/components/widgets/widget-control.jsx +12 -6
  44. package/client/components/widgets/widget-form.jsx +16 -18
  45. package/client/components/widgets/widget-instance.jsx +44 -9
  46. package/client/components/widgets/widget-notification-with-details.jsx +34 -0
  47. package/client/css/basic.styl +3 -1
  48. package/client/css/includes/box.styl +2 -2
  49. package/client/store/common.js +9 -5
  50. package/client/store/init-state.js +4 -0
  51. package/client/store/load-data.js +15 -6
  52. package/client/store/mcp-handler.js +640 -0
  53. package/client/store/store.js +4 -0
  54. package/client/store/widgets.js +4 -0
  55. package/client/store/workspace.js +108 -0
  56. package/package.json +1 -1
@@ -0,0 +1,108 @@
1
+ /**
2
+ * workspace related functions
3
+ */
4
+
5
+ import {
6
+ settingMap
7
+ } from '../common/constants'
8
+ import getInitItem from '../common/init-setting-item'
9
+ import generate from '../common/uid'
10
+
11
+ export default Store => {
12
+ /**
13
+ * Get current workspace state (layout + tabs for each batch)
14
+ */
15
+ Store.prototype.getCurrentWorkspaceState = function () {
16
+ const { store } = window
17
+ const { layout, tabs } = store
18
+ // Group tabs by batch and get bookmark srcIds
19
+ const tabsByBatch = {}
20
+ for (const tab of tabs) {
21
+ const batch = tab.batch || 0
22
+ if (!tabsByBatch[batch]) {
23
+ tabsByBatch[batch] = []
24
+ }
25
+ // Store srcId (bookmark id) if available, otherwise store basic connection info
26
+ if (tab.srcId) {
27
+ tabsByBatch[batch].push({
28
+ srcId: tab.srcId
29
+ })
30
+ }
31
+ }
32
+ return {
33
+ layout,
34
+ tabsByBatch
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Save current workspace
40
+ */
41
+ Store.prototype.saveWorkspace = function (name, id = null) {
42
+ const { store } = window
43
+ const state = store.getCurrentWorkspaceState()
44
+ const workspace = {
45
+ id: id || generate(),
46
+ name,
47
+ ...state,
48
+ createdAt: Date.now(),
49
+ updatedAt: Date.now()
50
+ }
51
+ if (id) {
52
+ // Update existing
53
+ store.editItem(id, workspace, settingMap.workspaces)
54
+ } else {
55
+ // Add new
56
+ store.addItem(workspace, settingMap.workspaces)
57
+ }
58
+ return workspace
59
+ }
60
+
61
+ /**
62
+ * Load a workspace - set layout and open tabs
63
+ */
64
+ Store.prototype.loadWorkspace = function (workspaceId) {
65
+ const { store } = window
66
+ const workspace = store.workspaces.find(w => w.id === workspaceId)
67
+ if (!workspace) {
68
+ return
69
+ }
70
+ const { layout, tabsByBatch } = workspace
71
+
72
+ // Close all existing tabs first
73
+ store.removeTabs(() => true)
74
+
75
+ // Set layout
76
+ store.setLayout(layout)
77
+ // Open tabs for each batch
78
+ for (const [batchStr, tabInfos] of Object.entries(tabsByBatch)) {
79
+ const batch = parseInt(batchStr, 10)
80
+ for (const tabInfo of tabInfos) {
81
+ if (tabInfo.srcId) {
82
+ // Open from bookmark
83
+ window.openTabBatch = batch
84
+ store.onSelectBookmark(tabInfo.srcId)
85
+ }
86
+ }
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Delete a workspace
92
+ */
93
+ Store.prototype.deleteWorkspace = function (id) {
94
+ window.store.delItem({ id }, settingMap.workspaces)
95
+ }
96
+
97
+ /**
98
+ * Open workspace settings
99
+ */
100
+ Store.prototype.openWorkspaceSettings = function () {
101
+ const { store } = window
102
+ store.storeAssign({
103
+ settingTab: settingMap.workspaces
104
+ })
105
+ store.setSettingItem(getInitItem([], settingMap.workspaces))
106
+ store.openSettingModal()
107
+ }
108
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "2.3.151",
3
+ "version": "2.3.176",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",