mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-15 23:00:57 +00:00
use Link instead A tag
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Link } from '@reach/router';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils.js';
|
||||
import { serviceURL, gettext, orgID } from '../../utils/constants';
|
||||
import { serviceURL, siteRoot, gettext, orgID } from '../../utils/constants';
|
||||
import OrgDepartmentsList from './org-departments-list';
|
||||
import ModalPortal from '../../components/modal-portal';
|
||||
import AddMemberDialog from '../../components/dialog/org-add-member-dialog';
|
||||
@@ -84,6 +85,13 @@ class OrgDepartmentItem extends React.Component {
|
||||
this.listOrgMembers(groupID);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.groupID !== nextProps.groupID) {
|
||||
this.listOrgGroupRepo(nextProps.groupID);
|
||||
this.listOrgMembers(nextProps.groupID);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { members, repos } = this.state;
|
||||
const groupID = this.props.groupID;
|
||||
@@ -94,14 +102,12 @@ class OrgDepartmentItem extends React.Component {
|
||||
<div className="fleft">
|
||||
<h3 className="sf-heading">
|
||||
{groupID ?
|
||||
<a href={serviceURL + '/org/departmentadmin/'}>{gettext('Departments')}</a>
|
||||
<Link to={siteRoot + 'org/departmentadmin/'}>{gettext('Departments')}</Link>
|
||||
: <span>{gettext('Departments')}</span>
|
||||
}
|
||||
{this.state.ancestorGroups.map(ancestor => {
|
||||
let newHref = serviceURL + '/org/departmentadmin/groups/' + ancestor.id + '/';
|
||||
return (
|
||||
<span key={ancestor.id}>{' / '}<a href={newHref}>{ancestor.name}</a></span>
|
||||
);
|
||||
let newHref = siteRoot + 'org/departmentadmin/groups/' + ancestor.id + '/';
|
||||
return <span key={ancestor.id}>{' / '}<Link to={newHref}>{ancestor.name}</Link></span>;
|
||||
})}
|
||||
{groupID && <span>{' / '}{this.state.groupName}</span>}
|
||||
</h3>
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import moment from 'moment';
|
||||
import { Link } from '@reach/router';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { serviceURL, gettext, orgID, lang } from '../../utils/constants';
|
||||
import { serviceURL, siteRoot, gettext, orgID, lang } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils.js';
|
||||
import ModalPortal from '../../components/modal-portal';
|
||||
import AddDepartDialog from '../../components/dialog/org-add-department-dialog';
|
||||
@@ -25,9 +26,9 @@ class OrgDepartmentsList extends React.Component {
|
||||
};
|
||||
}
|
||||
|
||||
listDepartGroups = () => {
|
||||
if (this.props.groupID) {
|
||||
seafileAPI.orgAdminListGroupInfo(orgID, this.props.groupID, true).then(res => {
|
||||
listDepartGroups = (groupID) => {
|
||||
if (groupID) {
|
||||
seafileAPI.orgAdminListGroupInfo(orgID, groupID, true).then(res => {
|
||||
this.setState({ groups: res.data.groups });
|
||||
});
|
||||
} else {
|
||||
@@ -53,11 +54,17 @@ class OrgDepartmentsList extends React.Component {
|
||||
}
|
||||
|
||||
onDepartChanged = () => {
|
||||
this.listDepartGroups();
|
||||
this.listDepartGroups(this.props.groupID);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.listDepartGroups();
|
||||
this.listDepartGroups(this.props.groupID);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.props.groupID !== nextProps.groupID) {
|
||||
this.listDepartGroups(nextProps.groupID);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -165,10 +172,10 @@ class GroupItem extends React.Component {
|
||||
render() {
|
||||
const group = this.props.group;
|
||||
const highlight = this.state.highlight;
|
||||
const newHref = serviceURL + '/org/departmentadmin/groups/' + group.id + '/';
|
||||
const newHref = siteRoot+ 'org/departmentadmin/groups/' + group.id + '/';
|
||||
return (
|
||||
<tr className={highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
||||
<td><a href={newHref} onClick={this.changeOrgGroup}>{group.name}</a></td>
|
||||
<td><Link to={newHref}>{group.name}</Link></td>
|
||||
<td>{moment(group.created_at).fromNow()}</td>
|
||||
<td onClick={this.props.showSetGroupQuotaDialog.bind(this, group.id)}>
|
||||
{Utils.bytesToSize(group.quota)}{' '}
|
||||
|
Reference in New Issue
Block a user