Skip to content

Commit a248b8a

Browse files
author
hackape
committed
Accept Merge Request #13: (yangzhen/ot -> ot)
Merge Request: 拖动文件到文件树时显示高亮 Created By: @杨臻 Accepted By: @hackape URL: https://codingcorp.coding.net/p/WebIDE-Frontend/git/merge/13
2 parents 71e28d0 + dc6f204 commit a248b8a

File tree

7 files changed

+54
-6
lines changed

7 files changed

+54
-6
lines changed

app/components/Accordion/Accordion.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AccordionGroup extends Component {
4848
{this.props.children.reduce((acc, component, index) => {
4949
acc.push(component)
5050
if (index < sectionCount - 1) {
51-
acc.push(<ResizeBar parentFlexDirection='column' />)
51+
acc.push(<ResizeBar parentFlexDirection='column' key={`resize_${index}`} />)
5252
}
5353
return acc
5454
}, [])}

app/components/DragAndDrop.jsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@ class DragAndDrop extends Component {
8989
x: 0,
9090
y: 0,
9191
}
92+
this.unhighlightDirNode()
9293
}
9394

95+
unhighlightDirNode = debounce(() => {
96+
if (this.highlightNode) {
97+
FileTreeActions.unhighlightDirNode(this.highlightNode)
98+
}
99+
}, 350)
100+
94101
handleDropOver = debounce((e) => {
95102
dnd.updateDroppables()
96103
const { source, droppables = [], meta } = dnd
@@ -119,7 +126,7 @@ class DragAndDrop extends Component {
119126

120127
default:
121128
}
122-
}, 1000)
129+
}, 400)
123130

124131
onDrop = (e) => {
125132
this.resetDragPos()
@@ -169,8 +176,26 @@ class DragAndDrop extends Component {
169176
dragTabOverFileTree (e, target) {
170177
const { id, DOMNode } = target
171178
const node = FileTreeState.entities.get(id)
172-
if (node.isDir && node.isFolded) {
173-
FileTreeActions.openNode(node)
179+
if (node.isDir) {
180+
if (node.isFolded) {
181+
FileTreeActions.openNode(node)
182+
}
183+
if (!node.isHighlighted) {
184+
if (this.highlightNode) {
185+
FileTreeActions.unhighlightDirNode(this.highlightNode)
186+
}
187+
this.highlightNode = node
188+
FileTreeActions.highlightDirNode(node)
189+
}
190+
} else {
191+
const parentNode = node.parent
192+
if (!parentNode.isHighlighted) {
193+
if (this.highlightNode) {
194+
FileTreeActions.unhighlightDirNode(this.highlightNode)
195+
}
196+
this.highlightNode = parentNode
197+
FileTreeActions.highlightDirNode(parentNode)
198+
}
174199
}
175200
}
176201

app/components/FileTree/actions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export const highlightDirNode = registerAction('filetree:highlight_dir_node',
4747
node => node.isDir && node.highlight()
4848
)
4949

50+
export const unhighlightDirNode = registerAction('filetree:unhighlight_dir_node',
51+
node => node.isDir && node.unhighlight()
52+
)
53+
5054
export const toggleNodeFold = registerAction('filetree:toggle_node_fold',
5155
(node, shouldBeFolded, deep) => ({ node, shouldBeFolded, deep }),
5256
({ node, shouldBeFolded = null, deep = false }) => {

app/containers/Initialize/index.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ class Initialize extends Component {
6060
{i18n`global.requestingCollaboration`}
6161
</div>
6262
)
63+
} else if (state.status === 'Expired') {
64+
errorInfo = null
65+
requestInfo = (
66+
<div className='request-info'>
67+
{i18n`global.requestCollaborationExpires`}
68+
</div>
69+
)
70+
info = (
71+
<div className='loading-info error'>
72+
{i18n`global.loadingWorkspaceDenied`}
73+
</div>
74+
)
6375
} else {
6476
info = (
6577
<div className='loading-info error'>

app/i18n/en_US/global.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"loadingWorkspaceDenied": "Loading workspace denied",
55
"requestCollaboration": "Request collaboration",
66
"requestCollaborationReject": "Your request has been rejected.",
7-
"requestingCollaboration": "You have requested collaboration"
7+
"requestingCollaboration": "You have requested collaboration",
8+
"requestCollaborationExpires": "The demo has already expired."
89
}

app/i18n/zh_CN/global.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"loadingWorkspaceDenied": "访问工作区未授权",
55
"requestCollaboration": "申请协作",
66
"requestCollaborationReject": "您的申请被拒绝了",
7-
"requestingCollaboration": "协作申请已经提交"
7+
"requestingCollaboration": "协作申请已经提交",
8+
"requestCollaborationExpires": "试用已经结束"
89
}

app/initialize.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ async function initialize () {
8787
initializeState.errorInfo = res.msg
8888
return false
8989
}
90+
} else if (res.durationStatus === 'Temporary' && res.ttl <= 0) {
91+
initializeState.errorCode = 403
92+
initializeState.status = 'Expired'
93+
return false
9094
}
95+
9196
extendObservable(config, res)
9297
if (config.project && config.project.name) { config.projectName = config.project.name }
9398
return true

0 commit comments

Comments
 (0)