1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00
* star repo

* file_icon_url -> item_icon_url

* add UserStarredFiles.objects.get_starred_repos_by_user()
This commit is contained in:
lian
2019-02-26 14:14:00 +08:00
committed by Daniel Pan
parent ac989da25a
commit d22e600442
12 changed files with 141 additions and 35 deletions

View File

@@ -8,6 +8,7 @@ import { gettext, siteRoot, isPro, username, folderPermEnabled, isSystemStaff }
import ModalPotal from '../../components/modal-portal';
import ShareDialog from '../../components/dialog/share-dialog';
import Rename from '../rename';
import { seafileAPI } from '../../utils/seafile-api';
const propTypes = {
currentGroup: PropTypes.object,
@@ -31,6 +32,7 @@ class SharedRepoListItem extends React.Component {
isItemMenuShow: false,
isShowSharedDialog: false,
isRenaming: false,
isStarred: this.props.repo.starred,
};
this.isDeparementOnwerGroupMember = false;
}
@@ -323,6 +325,18 @@ class SharedRepoListItem extends React.Component {
return null;
}
onStarRepo = () => {
if (this.state.isStarred) {
seafileAPI.unStarItem(this.props.repo.repo_id, '/').then(() => {
this.setState({isStarred: !this.state.isStarred});
});
} else {
seafileAPI.starItem(this.props.repo.repo_id, '/').then(() => {
this.setState({isStarred: !this.state.isStarred});
})
}
}
renderPCUI = () => {
let { iconUrl, iconTitle, libPath } = this.getRepoComputeParams();
let { repo } = this.props;
@@ -332,6 +346,10 @@ class SharedRepoListItem extends React.Component {
return (
<Fragment>
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
<td className="text-center">
{!this.state.isStarred && <i className="far fa-star star-empty cursor-pointer" onClick={this.onStarRepo}></i>}
{this.state.isStarred && <i className="fas fa-star cursor-pointer" onClick={this.onStarRepo}></i>}
</td>
<td><img src={iconUrl} title={repo.iconTitle} alt={iconTitle} width="24" /></td>
<td>
{this.state.isRenaming ?

View File

@@ -104,8 +104,9 @@ class SharedRepoListView extends React.Component {
<table className={isShowTableThread ? '' : 'table-thead-hidden'}>
<thead>
<tr>
<th width="4%"></th>
<th width="4%"><span className="sr-only">{gettext('Library Type')}</span></th>
<th width="40%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
<th width="36%"><a className="d-block table-sort-op" href="#" onClick={this.sortByName}>{gettext('Name')} {sortByName && sortIcon}</a></th>
<th width="12%"><span className="sr-only">{gettext('Actions')}</span></th>
<th width={'14%'}>{gettext('Size')}</th>
<th width={'14%'}><a className="d-block table-sort-op" href="#" onClick={this.sortByTime}>{gettext('Last Update')} {sortByTime && sortIcon}</a></th>