import React from 'react';
import PropTypes from 'prop-types';
import RepoListView from './repo-list-view';
import RecentlyUsedListView from './recently-used-list-view';
import { gettext } from '../../utils/constants';
export const MODE_TYPE_MAP = {
CURRENT_AND_OTHER_REPOS: 'current_repo_and_other_repos',
ONLY_CURRENT_LIBRARY: 'only_current_library',
ONLY_ALL_REPOS: 'only_all_repos',
ONLY_OTHER_LIBRARIES: 'only_other_libraries',
RECENTLY_USED: 'recently_used',
};
const RepoListWrapper = (props) => {
const {
mode, isShowFile, fileSuffixes, currentPath, isBrowsing, browsingPath, isCurrentRepoShow, currentRepoInfo, selectedRepo,
selectedPath, isOtherRepoShow, selectedItemInfo, repoList,
} = props;
const renderRecentlyUsed = () => {
const recentlyUsedList = JSON.parse(localStorage.getItem('recently-used-list')) || [];
return (
);
};
const onScroll = (event) => {
event.stopPropagation();
};
return (
{mode === MODE_TYPE_MAP.CURRENT_AND_OTHER_REPOS && (
<>
{gettext('Current Library')}
{(isCurrentRepoShow && currentRepoInfo) &&
}
{gettext('Other Libraries')}
{isOtherRepoShow &&
}
>
)}
{mode === MODE_TYPE_MAP.ONLY_CURRENT_LIBRARY && (
)}
{mode === MODE_TYPE_MAP.ONLY_ALL_REPOS && (
)}
{mode === MODE_TYPE_MAP.ONLY_OTHER_LIBRARIES && (
)}
{mode === MODE_TYPE_MAP.RECENTLY_USED && renderRecentlyUsed()}
);
};
RepoListWrapper.propTypes = {
mode: PropTypes.string,
currentPath: PropTypes.string,
isShowFile: PropTypes.bool,
fileSuffixes: PropTypes.array,
isBrowsing: PropTypes.bool,
browsingPath: PropTypes.string,
selectedItemInfo: PropTypes.object,
currentRepoInfo: PropTypes.object,
selectedRepo: PropTypes.object,
isCurrentRepoShow: PropTypes.bool,
isOtherRepoShow: PropTypes.bool,
selectedPath: PropTypes.string,
repoList: PropTypes.array,
onCurrentRepoToggle: PropTypes.func,
onOtherRepoToggle: PropTypes.func,
handleClickRepo: PropTypes.func,
handleClickDirent: PropTypes.func,
};
RepoListWrapper.defaultProps = {
isShowFile: false,
fileSuffixes: [],
};
export default RepoListWrapper;