|
|
|
@ -40,8 +40,9 @@ class CodeRepositoryView extends Component {
|
|
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.treeExpanded = false;
|
|
|
|
|
this.state = {
|
|
|
|
|
autoExpandParent: true,
|
|
|
|
|
autoExpandParent: false,
|
|
|
|
|
expandedKeys: [],
|
|
|
|
|
|
|
|
|
|
addtionalSSHArray: [],
|
|
|
|
@ -52,24 +53,28 @@ class CodeRepositoryView extends Component {
|
|
|
|
|
const { game, challenge, hide_code, tabIndex, } = this.props
|
|
|
|
|
|
|
|
|
|
if ( // 初始化 或者 game切换
|
|
|
|
|
challenge.path && challenge.path.length && this.state.expandedKeys.length === 0 ||
|
|
|
|
|
!this.treeExpanded && challenge.path && challenge.path.length && this.state.expandedKeys.length === 0 ||
|
|
|
|
|
game && (!prevProps.game
|
|
|
|
|
|| prevProps.game.identifier !== this.props.game.identifier) ) {
|
|
|
|
|
const _path = challenge.multiPath ? challenge.path[0] : challenge.path;
|
|
|
|
|
let _ar = [];
|
|
|
|
|
const expandedKeys = [];
|
|
|
|
|
if (_path) {
|
|
|
|
|
_ar = _path.split('/')
|
|
|
|
|
_ar.length = _ar.length - 1
|
|
|
|
|
_ar.forEach( (item, index) => {
|
|
|
|
|
expandedKeys.push( index === 0 ? item : expandedKeys[index - 1] + '/' + item)
|
|
|
|
|
|
|
|
|
|
if (!this.treeExpanded) {
|
|
|
|
|
this.treeExpanded = true
|
|
|
|
|
const _path = challenge.multiPath ? challenge.path[0] : challenge.path;
|
|
|
|
|
let _ar = [];
|
|
|
|
|
const expandedKeys = [];
|
|
|
|
|
if (_path) {
|
|
|
|
|
_ar = _path.split('/')
|
|
|
|
|
_ar.length = _ar.length - 1
|
|
|
|
|
_ar.forEach( (item, index) => {
|
|
|
|
|
expandedKeys.push( index === 0 ? item : expandedKeys[index - 1] + '/' + item)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
expandedKeys.length = 1 // 没办法做到多级初始化,而且会引起点击其他子目录,加载当前文件目录的问题
|
|
|
|
|
// 初始化时无法展开到根节点 https://github.com/fis-components/rc-tree/issues/3
|
|
|
|
|
expandedKeys.length && this.setState({
|
|
|
|
|
expandedKeys,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
expandedKeys.length = 1 // 没办法做到多级初始化
|
|
|
|
|
// 初始化时无法展开到根节点 https://github.com/fis-components/rc-tree/issues/3
|
|
|
|
|
expandedKeys.length && this.setState({
|
|
|
|
|
expandedKeys,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (game && (!prevProps.game
|
|
|
|
|
|| prevProps.game.identifier !== this.props.game.identifier)) {
|
|
|
|
|