@electerm/electerm-react 1.60.18 → 1.60.29
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/common/clipboard.js +1 -14
- package/client/common/constants.js +0 -43
- package/client/common/data-compare.js +55 -0
- package/client/common/default-setting.js +2 -10
- package/client/common/resolve.js +18 -22
- package/client/common/sftp.js +0 -3
- package/client/components/ai/ai-chat.jsx +30 -6
- package/client/components/ai/ai-config.jsx +17 -6
- package/client/components/batch-op/batch-op.jsx +3 -24
- package/client/components/bookmark-form/bookmark-group-tree-format.js +7 -9
- package/client/components/bookmark-form/form-ssh-common.jsx +0 -2
- package/client/components/bookmark-form/ssh-form.jsx +8 -41
- package/client/components/bookmark-form/tree-delete.jsx +6 -15
- package/client/components/common/animate-text.jsx +3 -4
- package/client/components/common/drag-handle.jsx +59 -45
- package/client/components/common/drag-handle.styl +2 -1
- package/client/components/common/input-auto-focus.jsx +29 -63
- package/client/components/common/ref.js +24 -0
- package/client/components/footer/batch-input.jsx +1 -6
- package/client/components/footer/footer-entry.jsx +13 -16
- package/client/components/footer/footer.styl +0 -5
- package/client/components/icons/ai-icon.jsx +17 -0
- package/client/components/icons/ai-icon.styl +3 -0
- package/client/components/layout/layout-item.jsx +14 -0
- package/client/components/main/main.jsx +8 -19
- package/client/components/main/upgrade.jsx +13 -25
- package/client/components/profile/profile-form-elem.jsx +1 -2
- package/client/components/quick-commands/on-drop.js +1 -12
- package/client/components/quick-commands/quick-command-transport-mod.jsx +3 -13
- package/client/components/quick-commands/quick-commands-form-elem.jsx +1 -2
- package/client/components/rdp/rdp-session.jsx +4 -4
- package/client/components/session/session.jsx +9 -11
- package/client/components/setting-panel/on-tree-drop.js +4 -35
- package/client/components/setting-panel/setting-common.jsx +4 -1
- package/client/components/setting-panel/setting-modal.jsx +7 -5
- package/client/components/setting-panel/tab-settings.jsx +0 -1
- package/client/components/setting-sync/setting-sync.jsx +0 -1
- package/client/components/sftp/address-bookmark-item.jsx +1 -15
- package/client/components/sftp/confirm-modal-store.jsx +2 -2
- package/client/components/sftp/{file-mode-modal.jsx → file-info-modal.jsx} +137 -37
- package/client/components/sftp/file-item.jsx +156 -192
- package/client/components/sftp/file-table-header.jsx +98 -0
- package/client/components/sftp/list-table-ui.jsx +125 -416
- package/client/components/sftp/sftp-entry.jsx +102 -128
- package/client/components/sftp/sftp.styl +6 -22
- package/client/components/sftp/transfer-conflict-store.jsx +8 -12
- package/client/components/sftp/transport-action-store.jsx +7 -15
- package/client/components/shortcuts/shortcut-control.jsx +72 -3
- package/client/components/shortcuts/shortcut-handler.js +0 -1
- package/client/components/side-panel-r/side-panel-r.jsx +7 -4
- package/client/components/sidebar/history.jsx +3 -0
- package/client/components/sidebar/index.jsx +1 -1
- package/client/components/sidebar/info-modal.jsx +3 -0
- package/client/components/sidebar/side-panel.jsx +7 -4
- package/client/components/sidebar/sidebar-panel.jsx +1 -1
- package/client/components/sidebar/sidebar.styl +3 -3
- package/client/components/sys-menu/icons-map.jsx +52 -0
- package/client/components/{context-menu → sys-menu}/menu-btn.jsx +33 -45
- package/client/components/sys-menu/sys-menu.jsx +163 -0
- package/client/components/{context-menu/context-menu.styl → sys-menu/sys-menu.styl} +2 -11
- package/client/components/tabs/index.jsx +5 -97
- package/client/components/tabs/tab.jsx +121 -73
- package/client/components/tabs/tabs.styl +4 -1
- package/client/components/terminal/term-search.jsx +16 -28
- package/client/components/terminal/terminal-interactive.jsx +0 -2
- package/client/components/terminal/{index.jsx → terminal.jsx} +110 -240
- package/client/components/terminal-info/base.jsx +21 -46
- package/client/components/terminal-info/terminal-info.jsx +3 -0
- package/client/components/text-editor/text-editor.jsx +38 -53
- package/client/components/theme/theme-form.jsx +0 -2
- package/client/components/tree-list/bookmark-toolbar.jsx +23 -47
- package/client/components/tree-list/bookmark-transport.jsx +2 -90
- package/client/components/tree-list/move-item-modal.jsx +101 -0
- package/client/components/tree-list/tree-list-item.jsx +6 -8
- package/client/components/tree-list/tree-list.jsx +48 -273
- package/client/components/vnc/vnc-session.jsx +5 -3
- package/client/store/app-upgrade.js +2 -5
- package/client/store/bookmark-group.js +74 -28
- package/client/store/common.js +36 -54
- package/client/store/event.js +4 -37
- package/client/store/init-state.js +9 -12
- package/client/store/item.js +34 -39
- package/client/store/load-data.js +5 -1
- package/client/store/quick-command.js +2 -12
- package/client/store/session.js +6 -7
- package/client/store/setting.js +3 -7
- package/client/store/sidebar.js +2 -8
- package/client/store/store.js +0 -20
- package/client/store/system-menu.js +1 -2
- package/client/store/tab.js +29 -1
- package/client/store/terminal-theme.js +0 -4
- package/client/store/watch.js +26 -4
- package/package.json +1 -1
- package/client/common/post-msg.js +0 -3
- package/client/components/common/native-input.jsx +0 -30
- package/client/components/context-menu/context-menu.jsx +0 -339
- package/client/components/sftp/file-props-modal.jsx +0 -210
- package/client/store/context-menu.js +0 -23
- /package/client/components/{context-menu → sys-menu}/boomarks.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/history.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/icon-holder.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/sub-tab-menu.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/tabs.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/zoom.jsx +0 -0
package/client/store/watch.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import createTitle from '../common/create-title'
|
|
6
6
|
import { autoRun } from 'manate'
|
|
7
|
-
import { update, dbNamesForWatch } from '../common/db'
|
|
7
|
+
import { update, remove, dbNamesForWatch } from '../common/db'
|
|
8
8
|
import {
|
|
9
9
|
sftpDefaultSortSettingKey,
|
|
10
10
|
checkedKeysLsKey,
|
|
@@ -15,6 +15,9 @@ import {
|
|
|
15
15
|
} from '../common/constants'
|
|
16
16
|
import * as ls from '../common/safe-local-storage'
|
|
17
17
|
import { debounce, isEmpty } from 'lodash-es'
|
|
18
|
+
import deepCopy from 'json-deep-copy'
|
|
19
|
+
import { refsStatic } from '../components/common/ref'
|
|
20
|
+
import dataCompare from '../common/data-compare'
|
|
18
21
|
|
|
19
22
|
export default store => {
|
|
20
23
|
// autoRun(() => {
|
|
@@ -35,15 +38,34 @@ export default store => {
|
|
|
35
38
|
|
|
36
39
|
for (const name of dbNamesForWatch) {
|
|
37
40
|
autoRun(async () => {
|
|
41
|
+
const old = refsStatic.get('oldState-' + name)
|
|
42
|
+
const n = store.getItems(name)
|
|
43
|
+
const { updated, added, removed } = dataCompare(
|
|
44
|
+
old,
|
|
45
|
+
n
|
|
46
|
+
)
|
|
47
|
+
for (const item of removed) {
|
|
48
|
+
await remove(name, item.id)
|
|
49
|
+
}
|
|
50
|
+
for (const item of updated) {
|
|
51
|
+
await update(item.id, item, name, false)
|
|
52
|
+
}
|
|
53
|
+
store.batchDbAdd(added.map(d => {
|
|
54
|
+
return {
|
|
55
|
+
db: name,
|
|
56
|
+
obj: d
|
|
57
|
+
}
|
|
58
|
+
}))
|
|
38
59
|
await update(
|
|
39
60
|
`${name}:order`,
|
|
40
|
-
|
|
61
|
+
(n || []).map(d => d.id)
|
|
41
62
|
)
|
|
63
|
+
refsStatic.add('oldState-' + name, deepCopy(n) || [])
|
|
42
64
|
await store.updateLastDataUpdateTime()
|
|
43
65
|
if (store.config.autoSync) {
|
|
44
66
|
await store.uploadSettingAll()
|
|
45
67
|
}
|
|
46
|
-
return store[
|
|
68
|
+
return store[name]
|
|
47
69
|
}).start()
|
|
48
70
|
}
|
|
49
71
|
|
|
@@ -90,7 +112,7 @@ export default store => {
|
|
|
90
112
|
|
|
91
113
|
autoRun(() => {
|
|
92
114
|
ls.setItemJSON(localAddrBookmarkLsKey, store.addressBookmarksLocal)
|
|
93
|
-
return store.
|
|
115
|
+
return store.addressBookmarksLocal
|
|
94
116
|
}).start()
|
|
95
117
|
|
|
96
118
|
autoRun(() => {
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* input with auto focus
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react'
|
|
6
|
-
import './native-input.styl'
|
|
7
|
-
|
|
8
|
-
export default function InputNative (props) {
|
|
9
|
-
const { value, type, onChange, onPressEnter, addonAfter = null, ...rest } = props
|
|
10
|
-
return (
|
|
11
|
-
<span
|
|
12
|
-
className='ant-input-group-wrapper'
|
|
13
|
-
data-id={props['data-id']}
|
|
14
|
-
>
|
|
15
|
-
<span className='ant-input-wrapper ant-input-group'>
|
|
16
|
-
<input
|
|
17
|
-
class='ant-input native-input'
|
|
18
|
-
type='text'
|
|
19
|
-
value={value}
|
|
20
|
-
onChange={onChange}
|
|
21
|
-
onPressEnter={onPressEnter}
|
|
22
|
-
{...rest}
|
|
23
|
-
/>
|
|
24
|
-
</span>
|
|
25
|
-
<span class='ant-input-group-addon'>
|
|
26
|
-
{addonAfter}
|
|
27
|
-
</span>
|
|
28
|
-
</span>
|
|
29
|
-
)
|
|
30
|
-
}
|
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* context menu
|
|
3
|
-
*/
|
|
4
|
-
import { PureComponent } from 'react'
|
|
5
|
-
import './context-menu.styl'
|
|
6
|
-
import classnames from 'classnames'
|
|
7
|
-
import {
|
|
8
|
-
contextMenuHeight,
|
|
9
|
-
contextMenuPaddingTop,
|
|
10
|
-
contextMenuWidth,
|
|
11
|
-
commonActions
|
|
12
|
-
} from '../../common/constants'
|
|
13
|
-
import {
|
|
14
|
-
Popconfirm
|
|
15
|
-
} from 'antd'
|
|
16
|
-
import postMessage from '../../common/post-msg'
|
|
17
|
-
import { noop } from 'lodash-es'
|
|
18
|
-
import History from './history'
|
|
19
|
-
import Bookmark from './boomarks'
|
|
20
|
-
import Tabs from './tabs'
|
|
21
|
-
import Zoom from './zoom'
|
|
22
|
-
import IconHolder from './icon-holder'
|
|
23
|
-
import {
|
|
24
|
-
CodeOutlined,
|
|
25
|
-
BorderHorizontalOutlined,
|
|
26
|
-
SearchOutlined,
|
|
27
|
-
SelectOutlined,
|
|
28
|
-
SwitcherOutlined,
|
|
29
|
-
CheckOutlined,
|
|
30
|
-
CloudDownloadOutlined,
|
|
31
|
-
CloudUploadOutlined,
|
|
32
|
-
ArrowRightOutlined,
|
|
33
|
-
CheckSquareOutlined,
|
|
34
|
-
CloseCircleOutlined,
|
|
35
|
-
ContainerOutlined,
|
|
36
|
-
CopyOutlined,
|
|
37
|
-
EditOutlined,
|
|
38
|
-
EnterOutlined,
|
|
39
|
-
FileAddOutlined,
|
|
40
|
-
FileExcelOutlined,
|
|
41
|
-
FolderAddOutlined,
|
|
42
|
-
InfoCircleOutlined,
|
|
43
|
-
LockOutlined,
|
|
44
|
-
ReloadOutlined
|
|
45
|
-
} from '@ant-design/icons'
|
|
46
|
-
|
|
47
|
-
const e = window.translate
|
|
48
|
-
|
|
49
|
-
export default class ContextMenu extends PureComponent {
|
|
50
|
-
state = {
|
|
51
|
-
items: [],
|
|
52
|
-
id: '',
|
|
53
|
-
pos: {
|
|
54
|
-
left: 0,
|
|
55
|
-
top: 0
|
|
56
|
-
},
|
|
57
|
-
className: 'context-menu'
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
componentDidMount () {
|
|
61
|
-
window.addEventListener('message', e => {
|
|
62
|
-
const {
|
|
63
|
-
type,
|
|
64
|
-
data
|
|
65
|
-
} = e.data || {}
|
|
66
|
-
if (
|
|
67
|
-
type === commonActions.closeContextMenu
|
|
68
|
-
) {
|
|
69
|
-
this.closeContextMenu()
|
|
70
|
-
} else if (type === commonActions.openContextMenu) {
|
|
71
|
-
this.setOnCloseEvent()
|
|
72
|
-
this.setState(data)
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
setOnCloseEvent = () => {
|
|
78
|
-
const dom = document
|
|
79
|
-
.querySelector('.ant-drawer')
|
|
80
|
-
if (dom) {
|
|
81
|
-
dom.addEventListener('click', this.onTriggerClose)
|
|
82
|
-
}
|
|
83
|
-
document
|
|
84
|
-
.getElementById('outside-context')
|
|
85
|
-
.addEventListener('click', this.onTriggerClose)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
onTriggerClose = () => {
|
|
89
|
-
this.closeContextMenu()
|
|
90
|
-
const dom = document
|
|
91
|
-
.querySelector('.ant-drawer')
|
|
92
|
-
if (dom) {
|
|
93
|
-
dom.removeEventListener('click', this.onTriggerClose)
|
|
94
|
-
}
|
|
95
|
-
document
|
|
96
|
-
.getElementById('outside-context')
|
|
97
|
-
.removeEventListener('click', this.onTriggerClose)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
icons = {
|
|
101
|
-
CodeOutlined,
|
|
102
|
-
BorderHorizontalOutlined,
|
|
103
|
-
SearchOutlined,
|
|
104
|
-
SelectOutlined,
|
|
105
|
-
SwitcherOutlined,
|
|
106
|
-
IconHolder,
|
|
107
|
-
CheckOutlined,
|
|
108
|
-
CloudDownloadOutlined,
|
|
109
|
-
CloudUploadOutlined,
|
|
110
|
-
ArrowRightOutlined,
|
|
111
|
-
CheckSquareOutlined,
|
|
112
|
-
CloseCircleOutlined,
|
|
113
|
-
ContainerOutlined,
|
|
114
|
-
CopyOutlined,
|
|
115
|
-
EditOutlined,
|
|
116
|
-
EnterOutlined,
|
|
117
|
-
FileAddOutlined,
|
|
118
|
-
FileExcelOutlined,
|
|
119
|
-
FolderAddOutlined,
|
|
120
|
-
InfoCircleOutlined,
|
|
121
|
-
LockOutlined,
|
|
122
|
-
ReloadOutlined
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
modules = {
|
|
126
|
-
History,
|
|
127
|
-
Bookmark,
|
|
128
|
-
Tabs,
|
|
129
|
-
Zoom
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
closeContextMenu = () => {
|
|
133
|
-
this.setState({
|
|
134
|
-
id: '',
|
|
135
|
-
items: []
|
|
136
|
-
})
|
|
137
|
-
postMessage({
|
|
138
|
-
action: commonActions.closeContextMenuAfter
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
computePos = () => {
|
|
143
|
-
const {
|
|
144
|
-
pos,
|
|
145
|
-
items
|
|
146
|
-
} = this.state
|
|
147
|
-
const { length } = items
|
|
148
|
-
const count = length
|
|
149
|
-
? items.filter(c => c.type !== 'hr').length
|
|
150
|
-
: 3
|
|
151
|
-
const countHr = length
|
|
152
|
-
? items.filter(c => c.type === 'hr').length
|
|
153
|
-
: 3
|
|
154
|
-
let {
|
|
155
|
-
left,
|
|
156
|
-
top
|
|
157
|
-
} = pos
|
|
158
|
-
const height = count * contextMenuHeight + contextMenuPaddingTop * 2 + countHr * 1
|
|
159
|
-
const maxHeight = Math.max(
|
|
160
|
-
window.innerHeight - top,
|
|
161
|
-
top
|
|
162
|
-
)
|
|
163
|
-
const shouldScroll = maxHeight < height
|
|
164
|
-
const startTop = top > window.innerHeight / 2
|
|
165
|
-
const realHeight = Math.min(maxHeight, height)
|
|
166
|
-
if (startTop) {
|
|
167
|
-
top = top - realHeight
|
|
168
|
-
}
|
|
169
|
-
if (window.innerWidth < left + contextMenuWidth + 10) {
|
|
170
|
-
left = left - contextMenuWidth
|
|
171
|
-
}
|
|
172
|
-
return {
|
|
173
|
-
pos: {
|
|
174
|
-
left: left + 'px',
|
|
175
|
-
top: top + 'px',
|
|
176
|
-
height: realHeight + 'px'
|
|
177
|
-
},
|
|
178
|
-
realHeight,
|
|
179
|
-
shouldScroll
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
onClick = (e, item) => {
|
|
184
|
-
const {
|
|
185
|
-
disabled,
|
|
186
|
-
func,
|
|
187
|
-
args,
|
|
188
|
-
noCloseMenu
|
|
189
|
-
} = item
|
|
190
|
-
if (disabled) {
|
|
191
|
-
return
|
|
192
|
-
}
|
|
193
|
-
postMessage({
|
|
194
|
-
action: commonActions.clickContextMenu,
|
|
195
|
-
id: this.state.id,
|
|
196
|
-
args,
|
|
197
|
-
func
|
|
198
|
-
})
|
|
199
|
-
if (!noCloseMenu) {
|
|
200
|
-
this.closeContextMenu()
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
renderSubText = (subText) => {
|
|
205
|
-
return subText
|
|
206
|
-
? (<span className='context-sub-text'>{subText}</span>)
|
|
207
|
-
: null
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
renderSubMenu = (submenu) => {
|
|
211
|
-
if (!submenu) {
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
const Mod = this.modules[submenu]
|
|
215
|
-
return (
|
|
216
|
-
<Mod {...this.props} />
|
|
217
|
-
)
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
renderItem = (item, i) => {
|
|
221
|
-
const {
|
|
222
|
-
disabled,
|
|
223
|
-
icon,
|
|
224
|
-
text,
|
|
225
|
-
noAutoClose,
|
|
226
|
-
requireConfirm,
|
|
227
|
-
confirmTitle,
|
|
228
|
-
subText,
|
|
229
|
-
className,
|
|
230
|
-
type,
|
|
231
|
-
module,
|
|
232
|
-
submenu
|
|
233
|
-
} = item
|
|
234
|
-
if (type === 'hr') {
|
|
235
|
-
return <hr />
|
|
236
|
-
}
|
|
237
|
-
const baseCls = 'context-item'
|
|
238
|
-
if (module && this.modules[module]) {
|
|
239
|
-
const Mod = this.modules[module]
|
|
240
|
-
return (
|
|
241
|
-
<div className={baseCls}>
|
|
242
|
-
<Mod {...this.props} />
|
|
243
|
-
</div>
|
|
244
|
-
)
|
|
245
|
-
}
|
|
246
|
-
let iconElem = null
|
|
247
|
-
if (icon && this.icons[icon]) {
|
|
248
|
-
const Icon = this.icons[icon]
|
|
249
|
-
iconElem = <Icon />
|
|
250
|
-
}
|
|
251
|
-
const cls = classnames(
|
|
252
|
-
baseCls,
|
|
253
|
-
{
|
|
254
|
-
disabled
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
'no-auto-close-context': noAutoClose
|
|
258
|
-
},
|
|
259
|
-
className,
|
|
260
|
-
{
|
|
261
|
-
'with-sub-menu': submenu
|
|
262
|
-
}
|
|
263
|
-
)
|
|
264
|
-
const act = requireConfirm || submenu
|
|
265
|
-
? noop
|
|
266
|
-
: (e) => this.onClick(e, item)
|
|
267
|
-
const unit = (
|
|
268
|
-
<div
|
|
269
|
-
key={`context-item-${i}-${text}`}
|
|
270
|
-
className={cls}
|
|
271
|
-
onClick={act}
|
|
272
|
-
>
|
|
273
|
-
{iconElem}{iconElem ? ' ' : ''}{text}
|
|
274
|
-
{
|
|
275
|
-
this.renderSubText(subText)
|
|
276
|
-
}
|
|
277
|
-
{
|
|
278
|
-
this.renderSubMenu(submenu)
|
|
279
|
-
}
|
|
280
|
-
</div>
|
|
281
|
-
)
|
|
282
|
-
if (!requireConfirm) {
|
|
283
|
-
return unit
|
|
284
|
-
}
|
|
285
|
-
const title = (
|
|
286
|
-
<div className='wordbreak'>{confirmTitle}</div>
|
|
287
|
-
)
|
|
288
|
-
return (
|
|
289
|
-
<Popconfirm
|
|
290
|
-
cancelText={e('cancel')}
|
|
291
|
-
key={`context-item-${i}-${text}`}
|
|
292
|
-
okText={e('ok')}
|
|
293
|
-
title={title}
|
|
294
|
-
onConfirm={(e) => this.onClick(e, item)}
|
|
295
|
-
>
|
|
296
|
-
{unit}
|
|
297
|
-
</Popconfirm>
|
|
298
|
-
)
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
renderItems = () => {
|
|
302
|
-
return this.state.items.map(this.renderItem)
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
render () {
|
|
306
|
-
const { id, className } = this.state
|
|
307
|
-
if (!id) {
|
|
308
|
-
return null
|
|
309
|
-
}
|
|
310
|
-
const {
|
|
311
|
-
pos,
|
|
312
|
-
shouldScroll,
|
|
313
|
-
realHeight
|
|
314
|
-
} = this.computePos()
|
|
315
|
-
const cls = classnames(
|
|
316
|
-
className,
|
|
317
|
-
id ? 'show' : 'hide',
|
|
318
|
-
shouldScroll ? 'scroll' : ''
|
|
319
|
-
)
|
|
320
|
-
const innerProps = {
|
|
321
|
-
className: 'context-menu-inner',
|
|
322
|
-
style: {
|
|
323
|
-
height: (realHeight - contextMenuPaddingTop * 2) + 'px'
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return (
|
|
327
|
-
<div
|
|
328
|
-
className={cls}
|
|
329
|
-
style={pos}
|
|
330
|
-
>
|
|
331
|
-
<div
|
|
332
|
-
{...innerProps}
|
|
333
|
-
>
|
|
334
|
-
{this.renderItems()}
|
|
335
|
-
</div>
|
|
336
|
-
</div>
|
|
337
|
-
)
|
|
338
|
-
}
|
|
339
|
-
}
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* file props
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { useState, useEffect } from 'react'
|
|
6
|
-
import {
|
|
7
|
-
Modal,
|
|
8
|
-
Button
|
|
9
|
-
} from 'antd'
|
|
10
|
-
import {
|
|
11
|
-
commonActions,
|
|
12
|
-
isWin,
|
|
13
|
-
typeMap
|
|
14
|
-
} from '../../common/constants'
|
|
15
|
-
import resolve from '../../common/resolve'
|
|
16
|
-
import { mode2permission } from '../../common/mode2permission'
|
|
17
|
-
import time from '../../common/time'
|
|
18
|
-
import renderPermission from './permission-render'
|
|
19
|
-
import FileIcon from './file-icon'
|
|
20
|
-
import fs from '../../common/fs'
|
|
21
|
-
import postMsg from '../../common/post-msg'
|
|
22
|
-
import { filesize } from 'filesize'
|
|
23
|
-
import { runCmd } from '../terminal/terminal-apis'
|
|
24
|
-
|
|
25
|
-
const e = window.translate
|
|
26
|
-
const formatTime = time
|
|
27
|
-
|
|
28
|
-
export default function FileInfoModal () {
|
|
29
|
-
const [state, setState] = useState({
|
|
30
|
-
loading: false
|
|
31
|
-
})
|
|
32
|
-
function onClose () {
|
|
33
|
-
setState({})
|
|
34
|
-
}
|
|
35
|
-
function onEvent (e) {
|
|
36
|
-
const {
|
|
37
|
-
action,
|
|
38
|
-
data
|
|
39
|
-
} = e.data || {}
|
|
40
|
-
if (action === commonActions.showFileInfoModal) {
|
|
41
|
-
setState(old => {
|
|
42
|
-
return {
|
|
43
|
-
...old,
|
|
44
|
-
...data,
|
|
45
|
-
size: 0
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
window.addEventListener('message', onEvent)
|
|
52
|
-
}, [])
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
postMsg({
|
|
55
|
-
action: commonActions.updateStore,
|
|
56
|
-
value: !!state.visible,
|
|
57
|
-
prop: 'showEditor'
|
|
58
|
-
})
|
|
59
|
-
}, [state.visible])
|
|
60
|
-
const {
|
|
61
|
-
visible,
|
|
62
|
-
file,
|
|
63
|
-
tab,
|
|
64
|
-
uidTree = {},
|
|
65
|
-
gidTree = {},
|
|
66
|
-
loading
|
|
67
|
-
} = state
|
|
68
|
-
if (!visible) {
|
|
69
|
-
return null
|
|
70
|
-
}
|
|
71
|
-
const {
|
|
72
|
-
name,
|
|
73
|
-
size,
|
|
74
|
-
owner,
|
|
75
|
-
group,
|
|
76
|
-
accessTime,
|
|
77
|
-
modifyTime,
|
|
78
|
-
isDirectory,
|
|
79
|
-
isSymbolicLink,
|
|
80
|
-
path,
|
|
81
|
-
mode,
|
|
82
|
-
type
|
|
83
|
-
} = file
|
|
84
|
-
const {
|
|
85
|
-
host,
|
|
86
|
-
port,
|
|
87
|
-
username
|
|
88
|
-
} = tab
|
|
89
|
-
const iconType = isDirectory ? 'folder' : 'file'
|
|
90
|
-
const ps = {
|
|
91
|
-
open: visible,
|
|
92
|
-
width: 500,
|
|
93
|
-
title: e(iconType) + ` ${e('attributes')}`,
|
|
94
|
-
footer: null,
|
|
95
|
-
onCancel: onClose
|
|
96
|
-
}
|
|
97
|
-
const fp = resolve(path, name)
|
|
98
|
-
const ffp = type === typeMap.local
|
|
99
|
-
? fp
|
|
100
|
-
: `${username}@${host}:${port}:${fp}`
|
|
101
|
-
const perms = mode2permission(mode)
|
|
102
|
-
function setLoading (loading) {
|
|
103
|
-
setState(old => {
|
|
104
|
-
return {
|
|
105
|
-
...old,
|
|
106
|
-
loading
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
function renderSize () {
|
|
111
|
-
if (isDirectory) {
|
|
112
|
-
return state.size || 0
|
|
113
|
-
}
|
|
114
|
-
return size
|
|
115
|
-
}
|
|
116
|
-
function getSize (str = '') {
|
|
117
|
-
if (isWin) {
|
|
118
|
-
const s = (str.stdout || '').split('\n').find(s => s.trim().startsWith('Sum'))
|
|
119
|
-
return s ? filesize(parseInt((s.split(':')[1]).trim(), 10)) : 0
|
|
120
|
-
} else {
|
|
121
|
-
return str.split(/\s+/)[0]
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async function calcLocal (folder) {
|
|
125
|
-
const cmd = isWin
|
|
126
|
-
? `Get-ChildItem -Recurse '${folder}' | Measure-Object -Property Length -Sum`
|
|
127
|
-
: `du -sh '${folder}'`
|
|
128
|
-
const func = isWin ? 'runWinCmd' : 'run'
|
|
129
|
-
const res = await fs[func](cmd).catch(window.store.onError)
|
|
130
|
-
return getSize(res)
|
|
131
|
-
}
|
|
132
|
-
async function calcRemote (folder) {
|
|
133
|
-
const cmd = `du -sh '${folder}'`
|
|
134
|
-
const r = await runCmd(
|
|
135
|
-
state.pid,
|
|
136
|
-
state.sessionId,
|
|
137
|
-
cmd
|
|
138
|
-
).catch(window.store.onError)
|
|
139
|
-
return r ? r.split(/\s+/)[0] : 0
|
|
140
|
-
}
|
|
141
|
-
async function calc () {
|
|
142
|
-
setLoading(true)
|
|
143
|
-
const size = type === typeMap.local
|
|
144
|
-
? await calcLocal(fp)
|
|
145
|
-
: await calcRemote(fp)
|
|
146
|
-
setState(old => {
|
|
147
|
-
return {
|
|
148
|
-
...old,
|
|
149
|
-
loading: false,
|
|
150
|
-
size
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
}
|
|
154
|
-
function renderCalc () {
|
|
155
|
-
if (isDirectory) {
|
|
156
|
-
return (
|
|
157
|
-
<Button
|
|
158
|
-
onClick={calc}
|
|
159
|
-
loading={loading}
|
|
160
|
-
disabled={loading}
|
|
161
|
-
className='mg1l'
|
|
162
|
-
>
|
|
163
|
-
{e('calculate')}
|
|
164
|
-
</Button>
|
|
165
|
-
)
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return (
|
|
169
|
-
<Modal
|
|
170
|
-
{...ps}
|
|
171
|
-
>
|
|
172
|
-
<div className='file-props-wrap relative'>
|
|
173
|
-
<FileIcon
|
|
174
|
-
className='file-icon'
|
|
175
|
-
file={file}
|
|
176
|
-
height={50}
|
|
177
|
-
/>
|
|
178
|
-
<div className='file-props'>
|
|
179
|
-
<p className='bold'>{e(iconType)} {e('name')}:</p>
|
|
180
|
-
<p className='pd1b'>
|
|
181
|
-
{
|
|
182
|
-
isSymbolicLink
|
|
183
|
-
? <sup className='color-blue symbolic-link-icon'>*</sup>
|
|
184
|
-
: null
|
|
185
|
-
}
|
|
186
|
-
{name}
|
|
187
|
-
</p>
|
|
188
|
-
<p className='bold'>{e('fullPath')}:</p>
|
|
189
|
-
<p className='pd1b'>{ffp}</p>
|
|
190
|
-
<p className='bold'>{e('size')}:</p>
|
|
191
|
-
<p className='pd1b'>{renderSize()}{renderCalc()}</p>
|
|
192
|
-
<p className='bold'>{e('accessTime')}:</p>
|
|
193
|
-
<p className='pd1b'>{formatTime(accessTime)}</p>
|
|
194
|
-
<p className='bold'>{e('modifyTime')}:</p>
|
|
195
|
-
<p className='pd1b'>{formatTime(modifyTime)}</p>
|
|
196
|
-
<p className='bold'>{e('owner')}</p>
|
|
197
|
-
<p className='pd1b'>{uidTree['' + owner]}</p>
|
|
198
|
-
<p className='bold'>{e('group')}</p>
|
|
199
|
-
<p className='pd1b'>{gidTree['' + group]}</p>
|
|
200
|
-
<p className='bold'>{e('mode')}:</p>
|
|
201
|
-
<div className='pd1b'>
|
|
202
|
-
{
|
|
203
|
-
perms.map(renderPermission)
|
|
204
|
-
}
|
|
205
|
-
</div>
|
|
206
|
-
</div>
|
|
207
|
-
</div>
|
|
208
|
-
</Modal>
|
|
209
|
-
)
|
|
210
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* context menu related functions
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import postMessage from '../common/post-msg'
|
|
6
|
-
import {
|
|
7
|
-
commonActions
|
|
8
|
-
} from '../common/constants'
|
|
9
|
-
|
|
10
|
-
export default Store => {
|
|
11
|
-
Store.prototype.openContextMenu = function (data) {
|
|
12
|
-
postMessage({
|
|
13
|
-
data,
|
|
14
|
-
type: commonActions.openContextMenu
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Store.prototype.closeContextMenu = function () {
|
|
19
|
-
postMessage({
|
|
20
|
-
action: commonActions.closeContextMenu
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|