import React from 'react'; import PropTypes from 'prop-types'; import { Link } from '@reach/router'; import { gettext, siteRoot } from '../utils/constants'; import { seafileAPI } from '../utils/seafile-api'; import { Badge } from 'reactstrap'; import { canViewOrg } from '../utils/constants'; const propTypes = { currentTab: PropTypes.string.isRequired, }; class MainSideNav extends React.Component { constructor(props) { super(props); let currentTab = this.props.currentTab || ''; this.state = { groupsExtended: false, sharedExtended: false, closeSideBar:false, groupItems: [], currentTab: currentTab, }; this.listHeight = 24; //for caculate tabheight this.groupsHeight = 0; this.adminHeight = 0; } grpsExtend = () => { this.setState({ groupsExtended: !this.state.groupsExtended, }); this.loadGroups(); } shExtend = () => { this.setState({ sharedExtended: !this.state.sharedExtended, }); } loadGroups = () => { let _this = this; seafileAPI.listGroups().then(res =>{ let data = res.data.groups; this.groupsHeight = (data.length + 1) * _this.listHeight; _this.setState({ groupItems: data }); }); } tabItemClick = (param) => { this.setState({ currentTab: param }); } renderSharedGroups() { let style = {height: 0}; if (this.state.groupsExtended) { style = {height: this.groupsHeight}; } return (