@electerm/electerm-react 1.60.16 → 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} +126 -248
- 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
|
@@ -6,8 +6,7 @@ import { PureComponent } from 'react'
|
|
|
6
6
|
import TextEditorForm from './text-editor-form'
|
|
7
7
|
import { Spin, Modal } from 'antd'
|
|
8
8
|
import resolve from '../../common/resolve'
|
|
9
|
-
import {
|
|
10
|
-
import postMsg from '../../common/post-msg'
|
|
9
|
+
import { refsStatic, refs } from '../common/ref'
|
|
11
10
|
|
|
12
11
|
const e = window.translate
|
|
13
12
|
|
|
@@ -21,44 +20,32 @@ export default class TextEditor extends PureComponent {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
componentDidMount () {
|
|
24
|
-
|
|
23
|
+
refsStatic.add('text-editor', this)
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
setStateProxy = (state, cb) => {
|
|
28
27
|
if (state && typeof state.file !== 'undefined') {
|
|
29
|
-
|
|
30
|
-
action: commonActions.updateStore,
|
|
31
|
-
value: !!state.file,
|
|
32
|
-
prop: 'showEditor'
|
|
33
|
-
})
|
|
28
|
+
window.store.showEditor = !!state.file
|
|
34
29
|
}
|
|
35
30
|
return this.setState(state, cb)
|
|
36
31
|
}
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
data
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
} else if (action === commonActions.loadTextEditorText) {
|
|
53
|
-
this.setStateProxy(data)
|
|
54
|
-
} else if (action === commonActions.editWithSystemEditorDone) {
|
|
55
|
-
let cb = this.doSubmit
|
|
56
|
-
if (data.text === this.state.text) {
|
|
57
|
-
delete data.text
|
|
58
|
-
cb = undefined
|
|
59
|
-
}
|
|
60
|
-
this.setStateProxy(data, cb)
|
|
33
|
+
openEditor = (data) => {
|
|
34
|
+
this.setStateProxy(data)
|
|
35
|
+
if (data.id && data.file) {
|
|
36
|
+
this.fetchText(data)
|
|
37
|
+
} else if (data.id === '') {
|
|
38
|
+
this.cancel()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
editWithSystemEditorDone = (data) => {
|
|
43
|
+
let cb = this.doSubmit
|
|
44
|
+
if (data.text === this.state.text) {
|
|
45
|
+
delete data.text
|
|
46
|
+
cb = undefined
|
|
61
47
|
}
|
|
48
|
+
this.setStateProxy(data, cb)
|
|
62
49
|
}
|
|
63
50
|
|
|
64
51
|
fetchText = async ({
|
|
@@ -76,11 +63,14 @@ export default class TextEditor extends PureComponent {
|
|
|
76
63
|
this.setStateProxy({
|
|
77
64
|
path: p
|
|
78
65
|
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
const fileRef = refs.get(id)
|
|
67
|
+
if (!fileRef) {
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
const text = await fileRef.fetchEditorText(p, type)
|
|
71
|
+
this.setStateProxy({
|
|
72
|
+
text,
|
|
73
|
+
loading: false
|
|
84
74
|
})
|
|
85
75
|
}
|
|
86
76
|
|
|
@@ -106,15 +96,11 @@ export default class TextEditor extends PureComponent {
|
|
|
106
96
|
type,
|
|
107
97
|
mode
|
|
108
98
|
} = file
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
mode,
|
|
115
|
-
type,
|
|
116
|
-
noClose: force
|
|
117
|
-
})
|
|
99
|
+
const fileRef = refs.get(id)
|
|
100
|
+
if (!fileRef) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
await fileRef.onSubmitEditFile(mode, type, path, res.text, force)
|
|
118
104
|
}
|
|
119
105
|
|
|
120
106
|
editWith = () => {
|
|
@@ -124,11 +110,11 @@ export default class TextEditor extends PureComponent {
|
|
|
124
110
|
const {
|
|
125
111
|
id, text
|
|
126
112
|
} = this.state
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
113
|
+
const fileRef = refs.get(id)
|
|
114
|
+
if (!fileRef) {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
fileRef.editWithSystemEditor(text)
|
|
132
118
|
}
|
|
133
119
|
|
|
134
120
|
cancel = () => {
|
|
@@ -136,9 +122,8 @@ export default class TextEditor extends PureComponent {
|
|
|
136
122
|
id: '',
|
|
137
123
|
file: null
|
|
138
124
|
})
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
})
|
|
125
|
+
const fileRef = refs.get(this.state.id)
|
|
126
|
+
fileRef?.removeFileEditEvent()
|
|
142
127
|
}
|
|
143
128
|
|
|
144
129
|
render () {
|
|
@@ -227,7 +227,6 @@ export default function ThemeForm (props) {
|
|
|
227
227
|
themeName,
|
|
228
228
|
themeText: convertThemeToText(props.formData)
|
|
229
229
|
}
|
|
230
|
-
const { autofocustrigger } = props.store
|
|
231
230
|
const isDefaultTheme = id === defaultTheme.id || id === defaultThemeLight.id
|
|
232
231
|
const disabled = readonly || isDefaultTheme
|
|
233
232
|
const switchTxt = editor === 'theme-editor-txt' ? e('editWithColorPicker') : e('editWithTextEditor')
|
|
@@ -259,7 +258,6 @@ export default function ThemeForm (props) {
|
|
|
259
258
|
<InputAutoFocus
|
|
260
259
|
selectall='yes'
|
|
261
260
|
disabled={disabled}
|
|
262
|
-
autofocustrigger={autofocustrigger}
|
|
263
261
|
/>
|
|
264
262
|
</FormItem>
|
|
265
263
|
<FormItem
|
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
import { Button, Space, Dropdown, Upload } from 'antd'
|
|
11
11
|
import copy from 'json-deep-copy'
|
|
12
12
|
import time from '../../common/time'
|
|
13
|
-
import { find, uniq
|
|
13
|
+
import { find, uniq } from 'lodash-es'
|
|
14
14
|
import { fixBookmarks } from '../../common/db-fix'
|
|
15
15
|
import download from '../../common/download'
|
|
16
|
+
import { action } from 'manate'
|
|
16
17
|
|
|
17
18
|
const e = window.translate
|
|
18
19
|
|
|
@@ -26,7 +27,7 @@ export default function BookmarkToolbar (props) {
|
|
|
26
27
|
bookmarkGroups,
|
|
27
28
|
bookmarks
|
|
28
29
|
} = props
|
|
29
|
-
const beforeUpload = async (file) => {
|
|
30
|
+
const beforeUpload = action(async (file) => {
|
|
30
31
|
const { store } = window
|
|
31
32
|
const txt = await window.fs.readFile(file.path)
|
|
32
33
|
try {
|
|
@@ -37,70 +38,45 @@ export default function BookmarkToolbar (props) {
|
|
|
37
38
|
} = content
|
|
38
39
|
const bookmarkGroups0 = copy(bookmarkGroups)
|
|
39
40
|
const bookmarks0 = copy(bookmarks)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const updates = []
|
|
55
|
-
bookmarks1.forEach(bg => {
|
|
56
|
-
if (!bmTree[bg.id]) {
|
|
57
|
-
bookmarks.push(bg)
|
|
58
|
-
add.push(bg)
|
|
59
|
-
dbAdd.push({
|
|
60
|
-
db: 'bookmarks',
|
|
61
|
-
obj: bg
|
|
62
|
-
})
|
|
41
|
+
|
|
42
|
+
// Using Map instead of reduce
|
|
43
|
+
const bmTree = new Map(
|
|
44
|
+
bookmarks0.map(bookmark => [bookmark.id, bookmark])
|
|
45
|
+
)
|
|
46
|
+
const bmgTree = new Map(
|
|
47
|
+
bookmarkGroups0.map(group => [group.id, group])
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
const fixed = fixBookmarks(bookmarks1)
|
|
51
|
+
|
|
52
|
+
fixed.forEach(bg => {
|
|
53
|
+
if (!bmTree.has(bg.id)) {
|
|
54
|
+
store.bookmarks.push(bg)
|
|
63
55
|
}
|
|
64
56
|
})
|
|
57
|
+
|
|
65
58
|
bookmarkGroups1.forEach(bg => {
|
|
66
|
-
if (!bmgTree
|
|
67
|
-
bookmarkGroups.push(bg)
|
|
68
|
-
dbAdd.push({
|
|
69
|
-
db: 'bookmarkGroups',
|
|
70
|
-
obj: bg
|
|
71
|
-
})
|
|
59
|
+
if (!bmgTree.has(bg.id)) {
|
|
60
|
+
store.bookmarkGroups.push(bg)
|
|
72
61
|
} else {
|
|
73
62
|
const bg1 = find(
|
|
74
|
-
bookmarkGroups,
|
|
63
|
+
store.bookmarkGroups,
|
|
75
64
|
b => b.id === bg.id
|
|
76
65
|
)
|
|
77
|
-
const old = copy(bg1.bookmarkIds)
|
|
78
66
|
bg1.bookmarkIds = uniq(
|
|
79
67
|
[
|
|
80
68
|
...bg1.bookmarkIds,
|
|
81
69
|
...bg.bookmarkIds
|
|
82
70
|
]
|
|
83
71
|
)
|
|
84
|
-
if (!isEqual(bg1.bookmarkIds, old)) {
|
|
85
|
-
updates.push({
|
|
86
|
-
id: bg1.id,
|
|
87
|
-
db: 'bookmarkGroups',
|
|
88
|
-
update: {
|
|
89
|
-
bookmarkIds: bg1.bookmarkIds
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
72
|
}
|
|
94
73
|
})
|
|
95
|
-
store.setBookmarkGroups(bookmarkGroups)
|
|
96
|
-
store.setBookmarks(fixBookmarks(bookmarks))
|
|
97
|
-
store.batchDbAdd(dbAdd)
|
|
98
|
-
store.batchDbUpdate(updates)
|
|
99
74
|
} catch (e) {
|
|
100
75
|
store.onError(e)
|
|
101
76
|
}
|
|
102
77
|
return false
|
|
103
|
-
}
|
|
78
|
+
})
|
|
79
|
+
|
|
104
80
|
const handleDownload = () => {
|
|
105
81
|
const txt = JSON.stringify({
|
|
106
82
|
bookmarkGroups: copy(bookmarkGroups),
|
|
@@ -9,101 +9,13 @@ import {
|
|
|
9
9
|
EditOutlined
|
|
10
10
|
} from '@ant-design/icons'
|
|
11
11
|
import { Upload, Button } from 'antd'
|
|
12
|
-
import download from '../../common/download'
|
|
13
|
-
import time from '../../common/time'
|
|
14
|
-
import copy from 'json-deep-copy'
|
|
15
|
-
import { find, uniq, isEqual } from 'lodash-es'
|
|
16
|
-
import { fixBookmarks } from '../../common/db-fix'
|
|
17
12
|
|
|
18
13
|
const e = window.translate
|
|
19
14
|
|
|
20
15
|
export default class BookmarkTransport extends PureComponent {
|
|
21
|
-
beforeUpload = async (file) => {
|
|
22
|
-
const { store } = window
|
|
23
|
-
const txt = await window.fs.readFile(file.path)
|
|
24
|
-
try {
|
|
25
|
-
const content = JSON.parse(txt)
|
|
26
|
-
const {
|
|
27
|
-
bookmarkGroups: bookmarkGroups1,
|
|
28
|
-
bookmarks: bookmarks1
|
|
29
|
-
} = content
|
|
30
|
-
const { props } = this
|
|
31
|
-
const bookmarkGroups = copy(props.bookmarkGroups)
|
|
32
|
-
const bookmarks = copy(props.bookmarks)
|
|
33
|
-
const bmTree = bookmarks.reduce((p, v) => {
|
|
34
|
-
return {
|
|
35
|
-
...p,
|
|
36
|
-
[v.id]: v
|
|
37
|
-
}
|
|
38
|
-
}, {})
|
|
39
|
-
const bmgTree = bookmarkGroups.reduce((p, v) => {
|
|
40
|
-
return {
|
|
41
|
-
...p,
|
|
42
|
-
[v.id]: v
|
|
43
|
-
}
|
|
44
|
-
}, {})
|
|
45
|
-
const add = []
|
|
46
|
-
const dbAdd = []
|
|
47
|
-
const updates = []
|
|
48
|
-
bookmarks1.forEach(bg => {
|
|
49
|
-
if (!bmTree[bg.id]) {
|
|
50
|
-
bookmarks.push(bg)
|
|
51
|
-
add.push(bg)
|
|
52
|
-
dbAdd.push({
|
|
53
|
-
db: 'bookmarks',
|
|
54
|
-
obj: bg
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
bookmarkGroups1.forEach(bg => {
|
|
59
|
-
if (!bmgTree[bg.id]) {
|
|
60
|
-
bookmarkGroups.push(bg)
|
|
61
|
-
dbAdd.push({
|
|
62
|
-
db: 'bookmarkGroups',
|
|
63
|
-
obj: bg
|
|
64
|
-
})
|
|
65
|
-
} else {
|
|
66
|
-
const bg1 = find(
|
|
67
|
-
bookmarkGroups,
|
|
68
|
-
b => b.id === bg.id
|
|
69
|
-
)
|
|
70
|
-
const old = copy(bg1.bookmarkIds)
|
|
71
|
-
bg1.bookmarkIds = uniq(
|
|
72
|
-
[
|
|
73
|
-
...bg1.bookmarkIds,
|
|
74
|
-
...bg.bookmarkIds
|
|
75
|
-
]
|
|
76
|
-
)
|
|
77
|
-
if (!isEqual(bg1.bookmarkIds, old)) {
|
|
78
|
-
updates.push({
|
|
79
|
-
id: bg1.id,
|
|
80
|
-
db: 'bookmarkGroups',
|
|
81
|
-
update: {
|
|
82
|
-
bookmarkIds: bg1.bookmarkIds
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
store.setBookmarkGroups(bookmarkGroups)
|
|
89
|
-
store.setBookmarks(fixBookmarks(bookmarks))
|
|
90
|
-
store.batchDbAdd(dbAdd)
|
|
91
|
-
store.batchDbUpdate(updates)
|
|
92
|
-
} catch (e) {
|
|
93
|
-
store.onError(e)
|
|
94
|
-
}
|
|
95
|
-
return false
|
|
96
|
-
}
|
|
16
|
+
beforeUpload = async (file) => {}
|
|
97
17
|
|
|
98
|
-
handleDownload = () => {
|
|
99
|
-
const { bookmarkGroups, bookmarks } = this.props
|
|
100
|
-
const txt = JSON.stringify({
|
|
101
|
-
bookmarkGroups: copy(bookmarkGroups),
|
|
102
|
-
bookmarks: copy(bookmarks)
|
|
103
|
-
}, null, 2)
|
|
104
|
-
const stamp = time(undefined, 'YYYY-MM-DD-HH-mm-ss')
|
|
105
|
-
download('bookmarks-' + stamp + '.json', txt)
|
|
106
|
-
}
|
|
18
|
+
handleDownload = () => {}
|
|
107
19
|
|
|
108
20
|
handleToggleEdit = () => {
|
|
109
21
|
window.store.bookmarkSelectMode = true
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// render bookmark select, use antd tree select
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
import buildGroupData from '../bookmark-form/bookmark-group-tree-format'
|
|
4
|
+
import { TreeSelect, Modal, Button } from 'antd'
|
|
5
|
+
const e = window.translate
|
|
6
|
+
|
|
7
|
+
export default function MoveItemModal (props) {
|
|
8
|
+
const [groupId, setGroupId] = useState(undefined)
|
|
9
|
+
const {
|
|
10
|
+
openMoveModal,
|
|
11
|
+
moveItem,
|
|
12
|
+
moveItemIsGroup,
|
|
13
|
+
bookmarkGroups
|
|
14
|
+
} = props
|
|
15
|
+
if (!openMoveModal) {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
const data = buildGroupData(bookmarkGroups, moveItem.id)
|
|
19
|
+
function onSelect () {
|
|
20
|
+
const {
|
|
21
|
+
bookmarkGroups
|
|
22
|
+
} = window.store
|
|
23
|
+
const groupMap = new Map(bookmarkGroups.map(d => [d.id, d]))
|
|
24
|
+
const group = groupMap.get(groupId)
|
|
25
|
+
if (!group) {
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
// Find and update the original parent group
|
|
29
|
+
const currentParentGroup = bookmarkGroups.find(bg => {
|
|
30
|
+
if (moveItemIsGroup) {
|
|
31
|
+
return (bg.bookmarkGroupIds || []).includes(moveItem.id)
|
|
32
|
+
}
|
|
33
|
+
return (bg.bookmarkIds || []).includes(moveItem.id)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// Remove from original parent if found
|
|
37
|
+
if (currentParentGroup) {
|
|
38
|
+
if (moveItemIsGroup) {
|
|
39
|
+
currentParentGroup.bookmarkGroupIds = currentParentGroup.bookmarkGroupIds.filter(
|
|
40
|
+
id => id !== moveItem.id
|
|
41
|
+
)
|
|
42
|
+
} else {
|
|
43
|
+
currentParentGroup.bookmarkIds = currentParentGroup.bookmarkIds.filter(
|
|
44
|
+
id => id !== moveItem.id
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (moveItemIsGroup) {
|
|
49
|
+
group.bookmarkGroupIds = [
|
|
50
|
+
moveItem.id,
|
|
51
|
+
...(group.bookmarkGroupIds || [])
|
|
52
|
+
]
|
|
53
|
+
} else {
|
|
54
|
+
group.bookmarkIds = [
|
|
55
|
+
moveItem.id,
|
|
56
|
+
...(group.bookmarkIds || [])
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
props.onCancelMoveItem()
|
|
60
|
+
}
|
|
61
|
+
const modalProps = {
|
|
62
|
+
open: openMoveModal,
|
|
63
|
+
title: e('moveTo'),
|
|
64
|
+
footer: null,
|
|
65
|
+
onCancel: props.onCancelMoveItem
|
|
66
|
+
}
|
|
67
|
+
const treeProps = {
|
|
68
|
+
treeData: data,
|
|
69
|
+
onChange: setGroupId,
|
|
70
|
+
placeholder: e('moveTo'),
|
|
71
|
+
showSearch: true,
|
|
72
|
+
value: groupId,
|
|
73
|
+
popupMatchSelectWidth: false,
|
|
74
|
+
treeDefaultExpandAll: true,
|
|
75
|
+
className: 'width-100'
|
|
76
|
+
}
|
|
77
|
+
return (
|
|
78
|
+
<Modal {...modalProps}>
|
|
79
|
+
<div className='pd1'>
|
|
80
|
+
<TreeSelect
|
|
81
|
+
{...treeProps}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
<div className='pd1'>
|
|
85
|
+
<Button
|
|
86
|
+
type='primary'
|
|
87
|
+
onClick={onSelect}
|
|
88
|
+
disabled={!groupId}
|
|
89
|
+
>
|
|
90
|
+
{e('ok')}
|
|
91
|
+
</Button>
|
|
92
|
+
<Button
|
|
93
|
+
onClick={props.onCancelMoveItem}
|
|
94
|
+
className='mg1l'
|
|
95
|
+
>
|
|
96
|
+
{e('cancel')}
|
|
97
|
+
</Button>
|
|
98
|
+
</div>
|
|
99
|
+
</Modal>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
EditOutlined,
|
|
9
9
|
FolderAddOutlined,
|
|
10
10
|
FolderOpenOutlined,
|
|
11
|
-
|
|
11
|
+
RightSquareOutlined
|
|
12
12
|
} from '@ant-design/icons'
|
|
13
13
|
import {
|
|
14
14
|
Popconfirm,
|
|
@@ -49,13 +49,13 @@ export default memo(function TreeListItem (props) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
const renderOperationBtn = (item, isGroup) => {
|
|
52
|
-
if (props.staticList) {
|
|
52
|
+
if (props.staticList || props.item.id === defaultBookmarkGroupId) {
|
|
53
53
|
return null
|
|
54
54
|
}
|
|
55
55
|
return (
|
|
56
|
-
<
|
|
56
|
+
<RightSquareOutlined
|
|
57
57
|
className='pointer tree-control-btn'
|
|
58
|
-
onClick={
|
|
58
|
+
onClick={openMoveModal}
|
|
59
59
|
/>
|
|
60
60
|
)
|
|
61
61
|
}
|
|
@@ -64,8 +64,8 @@ export default memo(function TreeListItem (props) {
|
|
|
64
64
|
props.openAll(props.item)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const
|
|
68
|
-
props.
|
|
67
|
+
const openMoveModal = (e) => {
|
|
68
|
+
props.openMoveModal(e, props.item, props.isGroup)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const handleEditItem = (e) => {
|
|
@@ -176,7 +176,6 @@ export default memo(function TreeListItem (props) {
|
|
|
176
176
|
props.onDragLeave(e)
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
// sort quick commands array when drop, so that the dragged item will be placed at the right position, e.target.getAttribute('data-id') would target item id, e.dataTransfer.getData('idDragged') would target dragged item id, then set window.store.quickCommands use window.store.setItems
|
|
180
179
|
const onDrop = e => {
|
|
181
180
|
props.onDrop(e)
|
|
182
181
|
}
|
|
@@ -210,7 +209,6 @@ export default memo(function TreeListItem (props) {
|
|
|
210
209
|
const propsAll = {
|
|
211
210
|
className: cls,
|
|
212
211
|
title: titleAll,
|
|
213
|
-
onContextMenu: handleContextMenu,
|
|
214
212
|
draggable: true,
|
|
215
213
|
'data-item-id': item.id,
|
|
216
214
|
'data-parent-id': props.parentId,
|