mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 03:11:07 +00:00
[published libraries] mobile: redesign (#3891)
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import React, { Component, Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
|
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 { siteRoot } from '../../utils/constants';
|
import { siteRoot, gettext } from '../../utils/constants';
|
||||||
// import { seafileAPI } from '../../utils/seafile-api';
|
// import { seafileAPI } from '../../utils/seafile-api';
|
||||||
// import Toast from '../toast';
|
// import Toast from '../toast';
|
||||||
import ModalPortal from '../modal-portal';
|
import ModalPortal from '../modal-portal';
|
||||||
@@ -23,6 +24,7 @@ class WikiListItem extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
|
isOpMenuOpen: false, // for mobile
|
||||||
isShowDeleteDialog: false,
|
isShowDeleteDialog: false,
|
||||||
// isRenameing: false,
|
// isRenameing: false,
|
||||||
highlight: false,
|
highlight: false,
|
||||||
@@ -30,6 +32,12 @@ class WikiListItem extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleOpMenu = () => {
|
||||||
|
this.setState({
|
||||||
|
isOpMenuOpen: !this.state.isOpMenuOpen
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// clickMenuToggle = (e) => {
|
// clickMenuToggle = (e) => {
|
||||||
// e.preventDefault();
|
// e.preventDefault();
|
||||||
// this.onMenuToggle(e);
|
// this.onMenuToggle(e);
|
||||||
@@ -130,23 +138,55 @@ class WikiListItem extends Component {
|
|||||||
let fileIconUrl = Utils.getDefaultLibIconUrl(false);
|
let fileIconUrl = Utils.getDefaultLibIconUrl(false);
|
||||||
let deleteIcon = `action-icon sf2-icon-x3 ${this.state.highlight ? '' : 'invisible'}`;
|
let deleteIcon = `action-icon sf2-icon-x3 ${this.state.highlight ? '' : 'invisible'}`;
|
||||||
|
|
||||||
return (
|
const desktopItem = (
|
||||||
<Fragment>
|
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
||||||
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
<td><img src={fileIconUrl} width="24" alt="" /></td>
|
||||||
<td><img src={fileIconUrl} width="24" alt="" /></td>
|
<td className="name">
|
||||||
<td className="name">
|
<a href={wiki.link}>{wiki.name}</a>
|
||||||
<a href={wiki.link}>{wiki.name}</a>
|
{/*this.state.isRenameing ?
|
||||||
{/*this.state.isRenameing ?
|
|
||||||
<Rename wiki={wiki} name={wiki.name} onRenameConfirm={this.onRenameConfirm} onRenameCancel={this.onRenameCancel}/> :
|
<Rename wiki={wiki} name={wiki.name} onRenameConfirm={this.onRenameConfirm} onRenameCancel={this.onRenameCancel}/> :
|
||||||
<a href={wiki.link}>{wiki.name}</a>
|
<a href={wiki.link}>{wiki.name}</a>
|
||||||
*/}
|
*/}
|
||||||
</td>
|
</td>
|
||||||
<td><a href={userProfileURL} target='_blank'>{wiki.owner_nickname}</a></td>
|
<td><a href={userProfileURL} target='_blank'>{wiki.owner_nickname}</a></td>
|
||||||
<td>{moment(wiki.updated_at).fromNow()}</td>
|
<td>{moment(wiki.updated_at).fromNow()}</td>
|
||||||
<td className="text-center cursor-pointer">
|
<td className="text-center cursor-pointer">
|
||||||
<span className={deleteIcon} onClick={this.onDeleteToggle}></span>
|
<span className={deleteIcon} onClick={this.onDeleteToggle}></span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
);
|
||||||
|
|
||||||
|
const mobileItem = (
|
||||||
|
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
||||||
|
<td><img src={fileIconUrl} width="24" alt="" /></td>
|
||||||
|
<td>
|
||||||
|
<a href={wiki.link}>{wiki.name}</a><br />
|
||||||
|
<a href={userProfileURL} target='_blank' className="item-meta-info">{wiki.owner_nickname}</a>
|
||||||
|
<span className="item-meta-info">{moment(wiki.updated_at).fromNow()}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Dropdown isOpen={this.state.isOpMenuOpen} toggle={this.toggleOpMenu}>
|
||||||
|
<DropdownToggle
|
||||||
|
tag="i"
|
||||||
|
className="sf-dropdown-toggle fa fa-ellipsis-v ml-0"
|
||||||
|
title={gettext('More Operations')}
|
||||||
|
data-toggle="dropdown"
|
||||||
|
aria-expanded={this.state.isOpMenuOpen}
|
||||||
|
/>
|
||||||
|
<div className={this.state.isOpMenuOpen ? '' : 'd-none'} onClick={this.toggleOpMenu}>
|
||||||
|
<div className="mobile-operation-menu-bg-layer"></div>
|
||||||
|
<div className="mobile-operation-menu">
|
||||||
|
<DropdownItem className="mobile-menu-item" onClick={this.onDeleteToggle}>{gettext('Unpublish')}</DropdownItem>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Dropdown>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
{window.innerWidth >= 768 ? desktopItem : mobileItem}
|
||||||
{this.state.isShowDeleteDialog &&
|
{this.state.isShowDeleteDialog &&
|
||||||
<ModalPortal>
|
<ModalPortal>
|
||||||
<WikiDeleteDialog
|
<WikiDeleteDialog
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import MediaQuery from 'react-responsive';
|
|
||||||
import { gettext } from '../../utils/constants';
|
import { gettext } from '../../utils/constants';
|
||||||
import WikiListItem from './wiki-list-item';
|
import WikiListItem from './wiki-list-item';
|
||||||
|
import LibsMobileThead from '../libs-mobile-thead';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
data: PropTypes.object.isRequired,
|
data: PropTypes.object.isRequired,
|
||||||
@@ -35,23 +35,20 @@ class WikiListView extends Component {
|
|||||||
} else if (errorMsg) {
|
} else if (errorMsg) {
|
||||||
return <p className="error text-center">{errorMsg}</p>;
|
return <p className="error text-center">{errorMsg}</p>;
|
||||||
} else {
|
} else {
|
||||||
|
const desktopThead = (
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th width="4%"></th>
|
||||||
|
<th width="36%">{gettext('Name')}</th>
|
||||||
|
<th width="25%">{gettext('Owner')}</th>
|
||||||
|
<th width="25%">{gettext('Last Update')}</th>
|
||||||
|
<th width="10%">{/* operation */}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<table>
|
<table className={window.innerWidth >= 768 ? '' : 'table-thead-hidden'}>
|
||||||
<thead>
|
{window.innerWidth >= 768 ? desktopThead : <LibsMobileThead />}
|
||||||
<tr>
|
|
||||||
<MediaQuery query="(min-width: 768px)">
|
|
||||||
<th width="4%"></th>
|
|
||||||
<th width="36%">{gettext('Name')}</th>
|
|
||||||
</MediaQuery>
|
|
||||||
<MediaQuery query="(max-width: 767.8px)">
|
|
||||||
<th width="10%"></th>
|
|
||||||
<th width="30%">{gettext('Name')}</th>
|
|
||||||
</MediaQuery>
|
|
||||||
<th width="25%">{gettext('Owner')}</th>
|
|
||||||
<th width="25%">{gettext('Last Update')}</th>
|
|
||||||
<th width="10%">{/* operation */}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{wikis.map((wiki, index) => {
|
{wikis.map((wiki, index) => {
|
||||||
return (
|
return (
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.border-left-show:before {
|
.border-left-show:before {
|
||||||
|
@@ -135,7 +135,7 @@ class Wikis extends Component {
|
|||||||
<Button className="btn btn-secondary operation-item" onClick={this.onSelectToggle}>{gettext('Publish a Library')}</Button>
|
<Button className="btn btn-secondary operation-item" onClick={this.onSelectToggle}>{gettext('Publish a Library')}</Button>
|
||||||
</MediaQuery>
|
</MediaQuery>
|
||||||
<MediaQuery query="(max-width: 767.8px)">
|
<MediaQuery query="(max-width: 767.8px)">
|
||||||
<Button className="btn btn-secondary operation-item my-1" onClick={this.onSelectToggle}>{gettext('Publish a Library')}</Button>
|
<span className="sf2-icon-plus mobile-toolbar-icon" title={gettext('Publish a Library')} onClick={this.onSelectToggle}></span>
|
||||||
</MediaQuery>
|
</MediaQuery>
|
||||||
</Fragment>}
|
</Fragment>}
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user