diff --git a/frontend/src/components/dialog/select-dirent-body.js b/frontend/src/components/dialog/select-dirent-body.js index eb2ad438e2..7af034bca8 100644 --- a/frontend/src/components/dialog/select-dirent-body.js +++ b/frontend/src/components/dialog/select-dirent-body.js @@ -42,7 +42,6 @@ class SelectDirentBody extends React.Component { try { const res = await seafileAPI.getRepoInfo(this.props.repoID); const repoInfo = new RepoInfo(res.data); - this.props.setSelectedPath('/'); this.setState({ currentRepoInfo: repoInfo, selectedRepo: repoInfo, @@ -60,9 +59,6 @@ class SelectDirentBody extends React.Component { const repoList = repos.filter((repo) => repo.permission === 'rw' && repo.repo_id !== this.props.repoID); const sortedRepoList = Utils.sortRepos(repoList, 'name', 'asc'); const selectedRepo = sortedRepoList.find((repo) => repo.repo_id === this.props.repoID); - const path = this.props.path.substring(0, this.props.path.length - 1); - - this.props.setSelectedPath(path); this.setState({ repoList: sortedRepoList, selectedRepo: selectedRepo || this.state.selectedRepo, @@ -92,10 +88,6 @@ class SelectDirentBody extends React.Component { }); }; - selectPath = (path) => { - this.props.setSelectedPath(path); - }; - setBrowsingPath = (path) => { this.setState({ browsingPath: path }); }; @@ -158,7 +150,7 @@ class SelectDirentBody extends React.Component { onDirentItemClick={this.onDirentItemClick} selectSearchedItem={this.selectSearchedItem} selectRepo={this.onSelectSearchedRepo} - selectPath={this.selectPath} + setSelectedPath={this.props.setSelectedPath} setBrowsingPath={this.setBrowsingPath} /> )} diff --git a/frontend/src/components/file-chooser/searcher/index.js b/frontend/src/components/file-chooser/searcher/index.js index f4f9e3eec7..e94c24652f 100644 --- a/frontend/src/components/file-chooser/searcher/index.js +++ b/frontend/src/components/file-chooser/searcher/index.js @@ -20,7 +20,7 @@ export const SearchStatus = { BROWSING: 'browsing', }; -const Searcher = ({ searchStatus, onUpdateSearchStatus, onDirentItemClick, selectSearchedItem, selectRepo, selectPath, setBrowsingPath }) => { +const Searcher = ({ searchStatus, onUpdateSearchStatus, onDirentItemClick, selectSearchedItem, selectRepo, setSelectedPath, setBrowsingPath }) => { const [inputValue, setInputValue] = useState(''); const [isResultsPopoverOpen, setIsResultsPopoverOpen] = useState(false); const [searchResults, setSearchResults] = useState([]); @@ -125,7 +125,7 @@ const Searcher = ({ searchStatus, onUpdateSearchStatus, onDirentItemClick, selec const repoInfo = new RepoInfo(res.data); const path = item.path.substring(0, item.path.length - 1); selectRepo(repoInfo); - selectPath(path); + setSelectedPath(path); setBrowsingPath(item.path.substring(0, item.path.length - 1)); }).catch(err => { const errMessage = Utils.getErrorMsg(err); @@ -199,7 +199,7 @@ Searcher.propTypes = { onDirentItemClick: PropTypes.func, selectSearchedItem: PropTypes.func, selectRepo: PropTypes.func, - selectPath: PropTypes.func, + setSelectedPath: PropTypes.func, setBrowsingPath: PropTypes.func, };