mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 19:29:56 +00:00
[published libraries] mobile: redesign (#3891)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import { Dropdown, DropdownToggle, DropdownItem } from 'reactstrap';
|
||||
import PropTypes from 'prop-types';
|
||||
import moment from 'moment';
|
||||
import { siteRoot } from '../../utils/constants';
|
||||
import { siteRoot, gettext } from '../../utils/constants';
|
||||
// import { seafileAPI } from '../../utils/seafile-api';
|
||||
// import Toast from '../toast';
|
||||
import ModalPortal from '../modal-portal';
|
||||
@@ -23,6 +24,7 @@ class WikiListItem extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isOpMenuOpen: false, // for mobile
|
||||
isShowDeleteDialog: false,
|
||||
// isRenameing: false,
|
||||
highlight: false,
|
||||
@@ -30,6 +32,12 @@ class WikiListItem extends Component {
|
||||
};
|
||||
}
|
||||
|
||||
toggleOpMenu = () => {
|
||||
this.setState({
|
||||
isOpMenuOpen: !this.state.isOpMenuOpen
|
||||
});
|
||||
}
|
||||
|
||||
// clickMenuToggle = (e) => {
|
||||
// e.preventDefault();
|
||||
// this.onMenuToggle(e);
|
||||
@@ -130,8 +138,7 @@ class WikiListItem extends Component {
|
||||
let fileIconUrl = Utils.getDefaultLibIconUrl(false);
|
||||
let deleteIcon = `action-icon sf2-icon-x3 ${this.state.highlight ? '' : 'invisible'}`;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
const desktopItem = (
|
||||
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}>
|
||||
<td><img src={fileIconUrl} width="24" alt="" /></td>
|
||||
<td className="name">
|
||||
@@ -147,6 +154,39 @@ class WikiListItem extends Component {
|
||||
<span className={deleteIcon} onClick={this.onDeleteToggle}></span>
|
||||
</td>
|
||||
</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 &&
|
||||
<ModalPortal>
|
||||
<WikiDeleteDialog
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import MediaQuery from 'react-responsive';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import WikiListItem from './wiki-list-item';
|
||||
import LibsMobileThead from '../libs-mobile-thead';
|
||||
|
||||
const propTypes = {
|
||||
data: PropTypes.object.isRequired,
|
||||
@@ -35,23 +35,20 @@ class WikiListView extends Component {
|
||||
} else if (errorMsg) {
|
||||
return <p className="error text-center">{errorMsg}</p>;
|
||||
} else {
|
||||
return (
|
||||
<table>
|
||||
const desktopThead = (
|
||||
<thead>
|
||||
<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>
|
||||
);
|
||||
return (
|
||||
<table className={window.innerWidth >= 768 ? '' : 'table-thead-hidden'}>
|
||||
{window.innerWidth >= 768 ? desktopThead : <LibsMobileThead />}
|
||||
<tbody>
|
||||
{wikis.map((wiki, index) => {
|
||||
return (
|
||||
|
@@ -4,6 +4,7 @@
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.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>
|
||||
</MediaQuery>
|
||||
<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>
|
||||
</Fragment>}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user