mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
Mobile visit item (#4779)
* [mobile] my libs: improved 'visit repo' * [mobile] dir view: improved 'visit dirent' * [mobile] shared with me: improved 'visit repo' * [mobile] group, groups, shared with all: improved 'visit repo' * [mobile] starred: improved 'visit item'
This commit is contained in:
@@ -171,8 +171,10 @@ class DirentListItem extends React.Component {
|
|||||||
|
|
||||||
onItemClick = (e) => {
|
onItemClick = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const dirent = this.props.dirent;
|
const dirent = this.props.dirent;
|
||||||
|
if (this.state.isRenameing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Utils.imageCheck(dirent.name)) {
|
if (Utils.imageCheck(dirent.name)) {
|
||||||
this.props.showImagePopup(dirent);
|
this.props.showImagePopup(dirent);
|
||||||
} else {
|
} else {
|
||||||
@@ -664,19 +666,19 @@ class DirentListItem extends React.Component {
|
|||||||
);
|
);
|
||||||
const mobileItem = (
|
const mobileItem = (
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td onClick={this.onItemClick}>
|
||||||
<div className="dir-icon">
|
<div className="dir-icon">
|
||||||
{dirent.encoded_thumbnail_src ?
|
{dirent.encoded_thumbnail_src ?
|
||||||
<img src={`${siteRoot}${dirent.encoded_thumbnail_src}`} className="thumbnail cursor-pointer" onClick={this.onItemClick} alt="" /> :
|
<img src={`${siteRoot}${dirent.encoded_thumbnail_src}`} className="thumbnail cursor-pointer" alt="" /> :
|
||||||
<img src={iconUrl} width="24" alt="" />
|
<img src={iconUrl} width="24" alt="" />
|
||||||
}
|
}
|
||||||
{dirent.is_locked && <img className="locked" src={mediaUrl + 'img/file-locked-32.png'} alt={gettext('locked')} title={lockedInfo}/>}
|
{dirent.is_locked && <img className="locked" src={mediaUrl + 'img/file-locked-32.png'} alt={gettext('locked')} title={lockedInfo}/>}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td onClick={this.onItemClick}>
|
||||||
{this.state.isRenameing ?
|
{this.state.isRenameing ?
|
||||||
<Rename hasSuffix={dirent.type !== 'dir'} name={dirent.name} onRenameConfirm={this.onRenameConfirm} onRenameCancel={this.onRenameCancel} /> :
|
<Rename hasSuffix={dirent.type !== 'dir'} name={dirent.name} onRenameConfirm={this.onRenameConfirm} onRenameCancel={this.onRenameCancel} /> :
|
||||||
<a href={dirent.type === 'dir' ? dirHref : fileHref} onClick={this.onItemClick}>{dirent.name}</a>
|
<a href={dirent.type === 'dir' ? dirHref : fileHref}>{dirent.name}</a>
|
||||||
}
|
}
|
||||||
<br />
|
<br />
|
||||||
{dirent.size && <span className="item-meta-info">{dirent.size}</span>}
|
{dirent.size && <span className="item-meta-info">{dirent.size}</span>}
|
||||||
|
@@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap';
|
import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap';
|
||||||
import { Link } from '@reach/router';
|
import { Link, navigate } from '@reach/router';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import { gettext, siteRoot, isPro, username, folderPermEnabled, isSystemStaff, enableResetEncryptedRepoPassword, isEmailConfigured } from '../../utils/constants';
|
import { gettext, siteRoot, isPro, username, folderPermEnabled, isSystemStaff, enableResetEncryptedRepoPassword, isEmailConfigured } from '../../utils/constants';
|
||||||
import ModalPortal from '../../components/modal-portal';
|
import ModalPortal from '../../components/modal-portal';
|
||||||
@@ -478,15 +478,22 @@ class SharedRepoListItem extends React.Component {
|
|||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
visitRepo = () => {
|
||||||
|
if (!this.state.isRenaming) {
|
||||||
|
navigate(this.repoURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
renderMobileUI = () => {
|
renderMobileUI = () => {
|
||||||
let { iconUrl, iconTitle, libPath } = this.getRepoComputeParams();
|
let { iconUrl, iconTitle, libPath } = this.getRepoComputeParams();
|
||||||
let { repo } = this.props;
|
let { repo } = this.props;
|
||||||
|
this.repoURL = libPath;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
|
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
|
||||||
<td><img src={iconUrl} title={iconTitle} width="24" alt={iconTitle}/></td>
|
<td onClick={this.visitRepo}><img src={iconUrl} title={iconTitle} width="24" alt={iconTitle}/></td>
|
||||||
<td>
|
<td onClick={this.visitRepo}>
|
||||||
{this.state.isRenaming ?
|
{this.state.isRenaming ?
|
||||||
<Rename name={repo.repo_name} onRenameConfirm={this.onRenameConfirm} onRenameCancel={this.onRenameCancel} /> :
|
<Rename name={repo.repo_name} onRenameConfirm={this.onRenameConfirm} onRenameCancel={this.onRenameCancel} /> :
|
||||||
<Link to={libPath}>{repo.repo_name}</Link>
|
<Link to={libPath}>{repo.repo_name}</Link>
|
||||||
|
@@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import MediaQuery from 'react-responsive';
|
import MediaQuery from 'react-responsive';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Link } from '@reach/router';
|
import { Link, navigate } from '@reach/router';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import { gettext, siteRoot, storages } from '../../utils/constants';
|
import { gettext, siteRoot, storages } from '../../utils/constants';
|
||||||
@@ -116,6 +116,12 @@ class MylibRepoListItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
visitRepo = () => {
|
||||||
|
if (!this.state.isRenaming && this.props.repo.repo_name) {
|
||||||
|
navigate(this.repoURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onRepoClick = () => {
|
onRepoClick = () => {
|
||||||
this.props.onRepoClick(this.props.repo);
|
this.props.onRepoClick(this.props.repo);
|
||||||
}
|
}
|
||||||
@@ -308,12 +314,12 @@ class MylibRepoListItem extends React.Component {
|
|||||||
let repo = this.props.repo;
|
let repo = this.props.repo;
|
||||||
let iconUrl = Utils.getLibIconUrl(repo);
|
let iconUrl = Utils.getLibIconUrl(repo);
|
||||||
let iconTitle = Utils.getLibIconTitle(repo);
|
let iconTitle = Utils.getLibIconTitle(repo);
|
||||||
let repoURL = `${siteRoot}library/${repo.repo_id}/${Utils.encodePath(repo.repo_name)}/`;
|
let repoURL = this.repoURL = `${siteRoot}library/${repo.repo_id}/${Utils.encodePath(repo.repo_name)}/`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave} onClick={this.onRepoClick}>
|
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave} onClick={this.onRepoClick}>
|
||||||
<td><img src={iconUrl} title={iconTitle} alt={iconTitle} width="24" /></td>
|
<td onClick={this.visitRepo}><img src={iconUrl} title={iconTitle} alt={iconTitle} width="24" /></td>
|
||||||
<td>
|
<td onClick={this.visitRepo}>
|
||||||
{this.state.isRenaming && (
|
{this.state.isRenaming && (
|
||||||
<Rename
|
<Rename
|
||||||
name={repo.repo_name}
|
name={repo.repo_name}
|
||||||
|
@@ -3,7 +3,7 @@ import { Dropdown, DropdownToggle, DropdownItem } from 'reactstrap';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import cookie from 'react-cookies';
|
import cookie from 'react-cookies';
|
||||||
import { Link } from '@reach/router';
|
import { Link, navigate } from '@reach/router';
|
||||||
import { gettext, siteRoot, isPro } from '../../utils/constants';
|
import { gettext, siteRoot, isPro } from '../../utils/constants';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
@@ -194,6 +194,10 @@ class Item extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
visitRepo = () => {
|
||||||
|
navigate(this.repoURL);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.unshared) {
|
if (this.state.unshared) {
|
||||||
return null;
|
return null;
|
||||||
@@ -208,7 +212,7 @@ class Item extends Component {
|
|||||||
let iconVisibility = this.state.showOpIcon ? '' : ' invisible';
|
let iconVisibility = this.state.showOpIcon ? '' : ' invisible';
|
||||||
let shareIconClassName = 'op-icon sf2-icon-share repo-share-btn' + iconVisibility;
|
let shareIconClassName = 'op-icon sf2-icon-share repo-share-btn' + iconVisibility;
|
||||||
let leaveShareIconClassName = 'op-icon sf2-icon-x3' + iconVisibility;
|
let leaveShareIconClassName = 'op-icon sf2-icon-x3' + iconVisibility;
|
||||||
let shareRepoUrl =`${siteRoot}library/${data.repo_id}/${Utils.encodePath(data.repo_name)}/`;
|
let shareRepoUrl = this.repoURL = `${siteRoot}library/${data.repo_id}/${Utils.encodePath(data.repo_name)}/`;
|
||||||
const desktopItem = (
|
const desktopItem = (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<tr onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut}>
|
<tr onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut}>
|
||||||
@@ -249,8 +253,8 @@ class Item extends Component {
|
|||||||
const mobileItem = (
|
const mobileItem = (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<tr onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut}>
|
<tr onMouseOver={this.handleMouseOver} onMouseOut={this.handleMouseOut}>
|
||||||
<td><img src={data.icon_url} title={data.icon_title} alt={data.icon_title} width="24" /></td>
|
<td onClick={this.visitRepo}><img src={data.icon_url} title={data.icon_title} alt={data.icon_title} width="24" /></td>
|
||||||
<td>
|
<td onClick={this.visitRepo}>
|
||||||
<Link to={shareRepoUrl}>{data.repo_name}</Link><br />
|
<Link to={shareRepoUrl}>{data.repo_name}</Link><br />
|
||||||
<span className="item-meta-info" title={data.owner_contact_email}>{data.owner_name}</span>
|
<span className="item-meta-info" title={data.owner_contact_email}>{data.owner_name}</span>
|
||||||
<span className="item-meta-info">{data.size}</span>
|
<span className="item-meta-info">{data.size}</span>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Dropdown, DropdownToggle, DropdownItem } from 'reactstrap';
|
import { Dropdown, DropdownToggle, DropdownItem } from 'reactstrap';
|
||||||
import { Link } from '@reach/router';
|
import { Link, navigate } from '@reach/router';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
@@ -170,6 +170,15 @@ class Item extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
visitItem = () => {
|
||||||
|
const data = this.props.data;
|
||||||
|
if (data.is_dir) {
|
||||||
|
navigate(data.dirent_view_url);
|
||||||
|
} else {
|
||||||
|
window.open(data.dirent_view_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
if (this.state.unstarred) {
|
if (this.state.unstarred) {
|
||||||
@@ -206,14 +215,14 @@ class Item extends Component {
|
|||||||
|
|
||||||
const mobileItem = (
|
const mobileItem = (
|
||||||
<tr>
|
<tr>
|
||||||
<td className="text-center">
|
<td className="text-center" onClick={this.visitItem}>
|
||||||
{
|
{
|
||||||
data.thumbnail_url ?
|
data.thumbnail_url ?
|
||||||
<img className="thumbnail" src={data.thumbnail_url} alt="" /> :
|
<img className="thumbnail" src={data.thumbnail_url} alt="" /> :
|
||||||
<img src={data.item_icon_url} alt={gettext('icon')} width="24" />
|
<img src={data.item_icon_url} alt={gettext('icon')} width="24" />
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td onClick={this.visitItem}>
|
||||||
{ data.is_dir ?
|
{ data.is_dir ?
|
||||||
<Link to={data.dirent_view_url}>{data.obj_name}</Link> :
|
<Link to={data.dirent_view_url}>{data.obj_name}</Link> :
|
||||||
<a className="normal" href={data.dirent_view_url} target="_blank">{data.obj_name}</a>
|
<a className="normal" href={data.dirent_view_url} target="_blank">{data.obj_name}</a>
|
||||||
|
Reference in New Issue
Block a user