diff --git a/frontend/src/components/file-chooser/file-chooser.js b/frontend/src/components/file-chooser/file-chooser.js index de973045c9e..dac329aa2f9 100644 --- a/frontend/src/components/file-chooser/file-chooser.js +++ b/frontend/src/components/file-chooser/file-chooser.js @@ -523,7 +523,6 @@ class FileChooser extends React.Component { <div className="list-view"> <RecentlyUsedListView recentlyUsedList={recentlyUsedList} - selectedRepo={selectedRepo} onDirentItemClick={this.onDirentItemClick} /> </div> diff --git a/frontend/src/components/file-chooser/recently-used-list-item.js b/frontend/src/components/file-chooser/recently-used-list-item.js index 005f1cbfa46..2c79bcfde04 100644 --- a/frontend/src/components/file-chooser/recently-used-list-item.js +++ b/frontend/src/components/file-chooser/recently-used-list-item.js @@ -1,10 +1,10 @@ import React from 'react'; -const RecentlyUsedListItem = ({ path, isSelected, onItemClick }) => { - const title = path.split('/').pop(); +const RecentlyUsedListItem = ({ item, isSelected, onItemClick }) => { + const title = item.path.split('/').pop(); const handleItemClick = () => { - onItemClick(path); + onItemClick(item.repo, item.path); }; return ( diff --git a/frontend/src/components/file-chooser/recently-used-list-view.js b/frontend/src/components/file-chooser/recently-used-list-view.js index 85a8a3fdabc..18ff113cfbd 100644 --- a/frontend/src/components/file-chooser/recently-used-list-view.js +++ b/frontend/src/components/file-chooser/recently-used-list-view.js @@ -1,22 +1,22 @@ import React, { useState } from 'react'; import RecentlyUsedListItem from './recently-used-list-item'; -const RecentlyUsedListView = ({ recentlyUsedList, selectedRepo, onDirentItemClick }) => { +const RecentlyUsedListView = ({ recentlyUsedList, onDirentItemClick }) => { const [selectedItem, setSelectedItem] = useState(null); - const onItemClick = (path) => { + const onItemClick = (repo, path) => { setSelectedItem(path); - onDirentItemClick(selectedRepo, path); + onDirentItemClick(repo, path); }; return ( <ul className="list-view-content file-chooser-item" > - {recentlyUsedList.length > 0 && recentlyUsedList.map((path, index) => { + {recentlyUsedList.length > 0 && recentlyUsedList.map((item, index) => { return ( <RecentlyUsedListItem key={index} - path={path} - isSelected={selectedItem === path} + item={item} + isSelected={selectedItem === item.path} onItemClick={onItemClick} /> ); diff --git a/frontend/src/pages/lib-content-view/lib-content-view.js b/frontend/src/pages/lib-content-view/lib-content-view.js index 55c1e8c6713..4425360bf55 100644 --- a/frontend/src/pages/lib-content-view/lib-content-view.js +++ b/frontend/src/pages/lib-content-view/lib-content-view.js @@ -715,16 +715,16 @@ class LibContentView extends React.Component { }); }; - updateRecentlyUsedRepos = (destPath) => { + updateRecentlyUsedRepos = (repo, destPath) => { const recentlyUsed = JSON.parse(localStorage.getItem('recently-used-list')) || []; - const updatedRecentlyUsed = [destPath, ...recentlyUsed.filter(path => path !== destPath)]; + const updatedRecentlyUsed = [{ repo: repo, path: destPath }, ...recentlyUsed.filter(item => item.path !== destPath)]; const seen = new Set(); - const filteredRecentlyUsed = updatedRecentlyUsed.filter(path => { - if (seen.has(path)) { + const filteredRecentlyUsed = updatedRecentlyUsed.filter(item => { + if (seen.has(item.path)) { return false; } else { - seen.add(path); + seen.add(item.path); return true; } }); @@ -775,7 +775,7 @@ class LibContentView extends React.Component { toaster.success(message); } - this.updateRecentlyUsedRepos(destDirentPath); + this.updateRecentlyUsedRepos(destRepo, destDirentPath); }).catch((error) => { if (!error.response.data.lib_need_decrypt) { @@ -1247,7 +1247,7 @@ class LibContentView extends React.Component { toaster.success(message); } - this.updateRecentlyUsedRepos(moveToDirentPath); + this.updateRecentlyUsedRepos(destRepo, moveToDirentPath); }).catch((error) => { if (!error.response.data.lib_need_decrypt) {