1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-10-09 00:25:53 +00:00
Files
seahub/frontend/src/pages/sys-admin/repos/repos-nav.js

64 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-09-24 12:18:53 +08:00
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from '@gatsbyjs/reach-router';
2019-09-24 12:18:53 +08:00
import { siteRoot, gettext } from '../../../utils/constants';
import SortMenu from '../../../components/sort-menu';
2019-09-24 12:18:53 +08:00
const propTypes = {
currentItem: PropTypes.string.isRequired,
sortBy: PropTypes.string,
sortItems: PropTypes.func
2019-09-24 12:18:53 +08:00
};
class Nav extends React.Component {
constructor(props) {
super(props);
this.navItems = [
2024-07-18 11:58:42 +08:00
{ name: 'all', urlPart: 'all-libraries', text: gettext('All') },
{ name: 'wikis', urlPart: 'all-wikis', text: gettext('Wikis') },
2024-07-18 11:58:42 +08:00
{ name: 'system', urlPart: 'system-library', text: gettext('System') },
{ name: 'trash', urlPart: 'trash-libraries', text: gettext('Trash') }
2019-09-24 12:18:53 +08:00
];
this.sortOptions = [
{ value: 'file_count-desc', text: gettext('Descending by files') },
{ value: 'size-desc', text: gettext('Descending by size') }
];
2019-09-24 12:18:53 +08:00
}
onSelectSortOption = (item) => {
const [sortBy,] = item.value.split('-');
this.props.sortItems(sortBy);
};
2019-09-24 12:18:53 +08:00
render() {
const { currentItem, sortBy, sortOrder = 'desc' } = this.props;
const showSortIcon = currentItem == 'all' || currentItem == 'wikis';
2019-09-24 12:18:53 +08:00
return (
<div className="cur-view-path tab-nav-container">
<ul className="nav">
{this.navItems.map((item, index) => {
return (
<li className="nav-item" key={index}>
<Link to={`${siteRoot}sys/${item.urlPart}/`} className={`nav-link${currentItem == item.name ? ' active' : ''}`}>{item.text}</Link>
</li>
);
})}
</ul>
{showSortIcon &&
<SortMenu
sortBy={sortBy}
sortOrder={sortOrder}
sortOptions={this.sortOptions}
onSelectSortOption={this.onSelectSortOption}
/>
}
2019-09-24 12:18:53 +08:00
</div>
);
}
}
Nav.propTypes = propTypes;
export default Nav;