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

Merge branch '7.0'

This commit is contained in:
plt
2019-08-25 13:25:37 +08:00
21 changed files with 92 additions and 142 deletions

View File

@@ -69,7 +69,7 @@ class App extends Component {
} }
componentWillMount() { componentWillMount() {
if (window.screen.width <= 768) { if (!Utils.isDesktop()) {
this.setState({ this.setState({
isSidePanelClosed: true isSidePanelClosed: true
}); });
@@ -166,7 +166,7 @@ class App extends Component {
let { currentTab, pathPrefix } = this.state; let { currentTab, pathPrefix } = this.state;
window.history.replaceState({currentTab: currentTab, pathPrefix: pathPrefix}, null); window.history.replaceState({currentTab: currentTab, pathPrefix: pathPrefix}, null);
}); });
if (window.screen.width <= 768 && !this.state.isSidePanelClosed) { if (!Utils.isDesktop() && !this.state.isSidePanelClosed) {
this.setState({ isSidePanelClosed: true }); this.setState({ isSidePanelClosed: true });
} }
} }

View File

@@ -15,12 +15,12 @@ class SortOptions extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.sortOptions = [ this.sortOptions = [
{id: 'sort-option-1', value: 'name-asc', text: gettext('By name ascending')}, {value: 'name-asc', text: gettext('By name ascending')},
{id: 'sort-option-2', value: 'name-desc', text: gettext('By name descending')}, {value: 'name-desc', text: gettext('By name descending')},
{id: 'sort-option-3', value: 'size-asc', text: gettext('By size ascending')}, {value: 'size-asc', text: gettext('By size ascending')},
{id: 'sort-option-4', value: 'size-desc', text: gettext('By size descending')}, {value: 'size-desc', text: gettext('By size descending')},
{id: 'sort-option-5', value: 'time-asc', text: gettext('By time ascending')}, {value: 'time-asc', text: gettext('By time ascending')},
{id: 'sort-option-6', value: 'time-desc', text: gettext('By time descending')} {value: 'time-desc', text: gettext('By time descending')}
]; ];
const { sortBy, sortOrder } = this.props; const { sortBy, sortOrder } = this.props;
this.state = { this.state = {
@@ -49,8 +49,8 @@ class SortOptions extends React.Component {
{this.sortOptions.map((item, index) => { {this.sortOptions.map((item, index) => {
return ( return (
<Fragment key={index}> <Fragment key={index}>
<input id={item.id} className="align-middle" type="radio" name="sort-options" value={item.value} checked={this.state.currentOption == item.value} onChange={this.switchOption} /> <input id={`option-${index}`} className="align-middle" type="radio" name="sort-option" value={item.value} checked={this.state.currentOption == item.value} onChange={this.switchOption} />
<label htmlFor={item.id} className="align-middle m-2">{item.text}</label><br /> <label htmlFor={`option-${index}`} className="align-middle m-2">{item.text}</label><br />
</Fragment> </Fragment>
); );
})} })}

View File

@@ -43,7 +43,7 @@ class FileUploader extends React.Component {
isUploadProgressDialogShow: false, isUploadProgressDialogShow: false,
isUploadRemindDialogShow: false, isUploadRemindDialogShow: false,
currentResumableFile: null, currentResumableFile: null,
uploadBitrate: '0', uploadBitrate: 0,
allFilesUploaded: false, allFilesUploaded: false,
}; };
@@ -74,6 +74,7 @@ class FileUploader extends React.Component {
generateUniqueIdentifier: this.generateUniqueIdentifier, generateUniqueIdentifier: this.generateUniqueIdentifier,
forceChunkSize: true, forceChunkSize: true,
maxChunkRetries: 3, maxChunkRetries: 3,
minFileSize: 0,
}); });
this.resumable.assignBrowse(this.uploadInput.current, true); this.resumable.assignBrowse(this.uploadInput.current, true);
@@ -410,7 +411,7 @@ class FileUploader extends React.Component {
setHeaders = (resumableFile, resumable) => { setHeaders = (resumableFile, resumable) => {
let offset = resumable.offset; let offset = resumable.offset;
let chunkSize = resumable.getOpt('chunkSize'); let chunkSize = resumable.getOpt('chunkSize');
let fileSize = resumableFile.size; let fileSize = resumableFile.size === 0 ? 1 : resumableFile.size;
let startByte = offset !== 0 ? offset * chunkSize : 0; let startByte = offset !== 0 ? offset * chunkSize : 0;
let endByte = Math.min(fileSize, (offset + 1) * chunkSize) - 1; let endByte = Math.min(fileSize, (offset + 1) * chunkSize) - 1;
@@ -594,7 +595,6 @@ class FileUploader extends React.Component {
var firedRetry = false; var firedRetry = false;
resumableFile.resumableObj.on('chunkingComplete', () => { resumableFile.resumableObj.on('chunkingComplete', () => {
if(!firedRetry) { if(!firedRetry) {
console.log(path);
seafileAPI.getFileUploadedBytes(repoID, path, fileName).then(res => { seafileAPI.getFileUploadedBytes(repoID, path, fileName).then(res => {
let uploadedBytes = res.data.uploadedBytes; let uploadedBytes = res.data.uploadedBytes;
let blockSize = parseInt(resumableUploadFileBlockSize) * 1024 * 1024 || 1024 * 1024; let blockSize = parseInt(resumableUploadFileBlockSize) * 1024 * 1024 || 1024 * 1024;

View File

@@ -5,7 +5,7 @@ import UploadListItem from './upload-list-item';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
const propTypes = { const propTypes = {
uploadBitrate: PropTypes.string.isRequired, uploadBitrate: PropTypes.number.isRequired,
totalProgress: PropTypes.number.isRequired, totalProgress: PropTypes.number.isRequired,
retryFileList: PropTypes.array.isRequired, retryFileList: PropTypes.array.isRequired,
uploadFileList: PropTypes.array.isRequired, uploadFileList: PropTypes.array.isRequired,

View File

@@ -475,7 +475,7 @@ class SharedRepoListItem extends React.Component {
} }
render() { render() {
if (window.innerWidth >= 768) { if (Utils.isDesktop()) {
return this.renderPCUI(); return this.renderPCUI();
} else { } else {
return this.renderMobileUI(); return this.renderMobileUI();

View File

@@ -141,7 +141,7 @@ class SharedRepoListView extends React.Component {
} }
render() { render() {
if (window.innerWidth >= 768) { if (Utils.isDesktop()) {
return this.renderPCUI(); return this.renderPCUI();
} else { } else {
return this.renderMobileUI(); return this.renderMobileUI();

View File

@@ -32,9 +32,7 @@ class GroupsToolbar extends React.Component {
</Button> </Button>
</MediaQuery> </MediaQuery>
<MediaQuery query="(max-width: 767.8px)"> <MediaQuery query="(max-width: 767.8px)">
<Button color="btn btn-secondary operation-item my-1" onClick={this.props.toggleAddGroupModal}> <span className="sf2-icon-plus mobile-toolbar-icon" title={gettext('New Group')} onClick={this.props.toggleAddGroupModal}></span>
<i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('New Group')}
</Button>
</MediaQuery> </MediaQuery>
</div> </div>
)} )}

View File

@@ -1,9 +1,9 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import MediaQuery from 'react-responsive';
import CommonToolbar from './common-toolbar'; import CommonToolbar from './common-toolbar';
import { Button } from 'reactstrap'; import { Button } from 'reactstrap';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils';
const propTypes = { const propTypes = {
onShowSidePanel: PropTypes.func.isRequired, onShowSidePanel: PropTypes.func.isRequired,
@@ -24,7 +24,7 @@ class InvitationsToolbar extends React.Component {
<div className="cur-view-toolbar"> <div className="cur-view-toolbar">
<span title="Side Nav Menu" onClick={onShowSidePanel} className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none"> <span title="Side Nav Menu" onClick={onShowSidePanel} className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none">
</span> </span>
{window.innerWidth >= 768 ? ( {Utils.isDesktop() ? (
<div className="operation"> <div className="operation">
<Button color="btn btn-secondary operation-item" onClick={toggleInvitePeopleDialog}> <Button color="btn btn-secondary operation-item" onClick={toggleInvitePeopleDialog}>
<i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('Invite People')} <i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('Invite People')}

View File

@@ -1,6 +1,6 @@
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import MediaQuery from 'react-responsive'; import { Utils } from '../../utils/utils';
import { Link } from '@reach/router'; import { Link } from '@reach/router';
import { siteRoot, gettext } from '../../utils/constants'; import { siteRoot, gettext } from '../../utils/constants';
import ModalPortal from '../modal-portal'; import ModalPortal from '../modal-portal';
@@ -8,7 +8,6 @@ import CreateRepoDialog from '../dialog/create-repo-dialog';
import { DropdownToggle, Dropdown, DropdownMenu, DropdownItem } from 'reactstrap'; import { DropdownToggle, Dropdown, DropdownMenu, DropdownItem } from 'reactstrap';
const propTypes = { const propTypes = {
// isOwnLibrary: PropTypes.bool.isRequired,
libraryType: PropTypes.string.isRequired, libraryType: PropTypes.string.isRequired,
onCreateRepo: PropTypes.func.isRequired, onCreateRepo: PropTypes.func.isRequired,
onShowSidePanel: PropTypes.func.isRequired, onShowSidePanel: PropTypes.func.isRequired,
@@ -42,28 +41,25 @@ class RepoViewToolbar extends React.Component {
<Fragment> <Fragment>
<div className="cur-view-toolbar"> <div className="cur-view-toolbar">
<span className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none" title="Side Nav Menu" onClick={this.props.onShowSidePanel}></span> <span className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none" title="Side Nav Menu" onClick={this.props.onShowSidePanel}></span>
<MediaQuery query="(min-width: 768px)"> {Utils.isDesktop() ? (
<div className="operation"> <div className="operation">
<button className="btn btn-secondary operation-item" title={gettext('New Library')} onClick={this.onCreateToggle}> <button className="btn btn-secondary operation-item" title={gettext('New Library')} onClick={this.onCreateToggle}>
<i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('New Library')} <i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('New Library')}
</button> </button>
{this.props.libraryType !== 'group' && ( <Dropdown isOpen={this.state.isOpen} toggle={this.toggleMore}>
<Dropdown isOpen={this.state.isOpen} toggle={this.toggleMore}> <DropdownToggle className='btn btn-secondary operation-item'>
<DropdownToggle className='btn btn-secondary operation-item'> {gettext('More')}
{gettext('More')} </DropdownToggle>
</DropdownToggle> <DropdownMenu>
<DropdownMenu> <DropdownItem className="link-dropdown-container">
<DropdownItem className="link-dropdown-container"> <Link className="link-dropdown-item" to={siteRoot + 'my-libs/deleted/'}>{gettext('Deleted Libraries')}</Link>
<Link className="link-dropdown-item" to={siteRoot + 'my-libs/deleted/'}>{gettext('Deleted Libraries')}</Link> </DropdownItem>
</DropdownItem> </DropdownMenu>
</DropdownMenu> </Dropdown>
</Dropdown>
)}
</div> </div>
</MediaQuery> ) : (
<MediaQuery query="(max-width: 767.8px)">
<span className="sf2-icon-plus mobile-toolbar-icon" title={gettext('New Library')} onClick={this.onCreateToggle}></span> <span className="sf2-icon-plus mobile-toolbar-icon" title={gettext('New Library')} onClick={this.onCreateToggle}></span>
</MediaQuery> )}
</div> </div>
{this.state.isCreateRepoDialogShow && ( {this.state.isCreateRepoDialogShow && (
<ModalPortal> <ModalPortal>

View File

@@ -3,14 +3,13 @@ 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, gettext } from '../../utils/constants'; import { siteRoot, gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils';
// 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';
import WikiDeleteDialog from '../dialog/wiki-delete-dialog'; import WikiDeleteDialog from '../dialog/wiki-delete-dialog';
// import Rename from '../rename'; // import Rename from '../rename';
import { Utils } from '../../utils/utils';
const propTypes = { const propTypes = {
wiki: PropTypes.object.isRequired, wiki: PropTypes.object.isRequired,
// renameWiki: PropTypes.func.isRequired, // renameWiki: PropTypes.func.isRequired,
@@ -186,7 +185,7 @@ class WikiListItem extends Component {
return ( return (
<Fragment> <Fragment>
{window.innerWidth >= 768 ? desktopItem : mobileItem} {Utils.isDesktop() ? desktopItem : mobileItem}
{this.state.isShowDeleteDialog && {this.state.isShowDeleteDialog &&
<ModalPortal> <ModalPortal>
<WikiDeleteDialog <WikiDeleteDialog

View File

@@ -1,6 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import WikiListItem from './wiki-list-item'; import WikiListItem from './wiki-list-item';
import LibsMobileThead from '../libs-mobile-thead'; import LibsMobileThead from '../libs-mobile-thead';
@@ -35,6 +36,7 @@ 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 isDesktop = Utils.isDesktop();
const desktopThead = ( const desktopThead = (
<thead> <thead>
<tr> <tr>
@@ -47,8 +49,8 @@ class WikiListView extends Component {
</thead> </thead>
); );
return ( return (
<table className={window.innerWidth >= 768 ? '' : 'table-thead-hidden'}> <table className={isDesktop ? '' : 'table-thead-hidden'}>
{window.innerWidth >= 768 ? desktopThead : <LibsMobileThead />} {isDesktop ? desktopThead : <LibsMobileThead />}
<tbody> <tbody>
{wikis.map((wiki, index) => { {wikis.map((wiki, index) => {
return ( return (

View File

@@ -18,11 +18,10 @@ const contentPropTypes = {
items: PropTypes.array.isRequired, items: PropTypes.array.isRequired,
}; };
const isDesktop = window.innerWidth >= 768;
class FileActivitiesContent extends Component { class FileActivitiesContent extends Component {
render() { render() {
const isDesktop = Utils.isDesktop();
let { items, isLoadingMore } = this.props; let { items, isLoadingMore } = this.props;
const desktopThead = ( const desktopThead = (
@@ -56,6 +55,7 @@ class FileActivitiesContent extends Component {
return ( return (
<ActivityItem <ActivityItem
key={index} key={index}
isDesktop={isDesktop}
item={item} item={item}
index={index} index={index}
items={items} items={items}
@@ -94,6 +94,7 @@ class ActivityItem extends Component {
} }
render() { render() {
const isDesktop = this.props.isDesktop;
let {item, index, items} = this.props; let {item, index, items} = this.props;
let op, details, moreDetails = false; let op, details, moreDetails = false;
let userProfileURL = `${siteRoot}profile/${encodeURIComponent(item.author_email)}/`; let userProfileURL = `${siteRoot}profile/${encodeURIComponent(item.author_email)}/`;

View File

@@ -404,9 +404,13 @@ class GroupView extends React.Component {
<span className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none" title="Side Nav Menu" onClick={this.props.onShowSidePanel}></span> <span className="sf2-icon-menu side-nav-toggle hidden-md-up d-md-none" title="Side Nav Menu" onClick={this.props.onShowSidePanel}></span>
<div className="operation"> <div className="operation">
{((!isDepartmentGroup && canAddRepo) || (isDepartmentGroup && isStaff)) && ( {((!isDepartmentGroup && canAddRepo) || (isDepartmentGroup && isStaff)) && (
Utils.isDesktop() ? (
<button className="btn btn-secondary operation-item" title={gettext('New Library')} onClick={this.onCreateRepoToggle}> <button className="btn btn-secondary operation-item" title={gettext('New Library')} onClick={this.onCreateRepoToggle}>
<i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('New Library')} <i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('New Library')}
</button> </button>
) : (
<span className="sf2-icon-plus mobile-toolbar-icon" title={gettext('New Library')} onClick={this.onCreateRepoToggle}></span>
)
)} )}
</div> </div>
</div> </div>
@@ -509,7 +513,7 @@ class GroupView extends React.Component {
</ul> </ul>
</div> </div>
</Popover> </Popover>
{(window.innerWidth < 768) && <span className="sf3-font sf3-font-sort action-icon" onClick={this.toggleSortOptionsDialog}></span>} {(!Utils.isDesktop() && this.state.repoList.length > 0) && <span className="sf3-font sf3-font-sort action-icon" onClick={this.toggleSortOptionsDialog}></span>}
{this.state.isSortOptionsDialogOpen && {this.state.isSortOptionsDialogOpen &&
<SortOptionsDialog <SortOptionsDialog
toggleDialog={this.toggleSortOptionsDialog} toggleDialog={this.toggleSortOptionsDialog}

View File

@@ -44,37 +44,21 @@ class Content extends Component {
</thead> </thead>
); );
const isDesktop = Utils.isDesktop();
return items.length ? ( return items.length ? (
<table className={`table-hover ${window.innerWidth >= 768 ? '': 'table-thead-hidden'}`}> <table className={`table-hover ${isDesktop ? '': 'table-thead-hidden'}`}>
{window.innerWidth >= 768 ? desktopThead : mobileThead} {isDesktop ? desktopThead : mobileThead}
<TableBody items={items} /> <tbody>
{items.map((item, index) => {
return <Item key={index} data={item} isDesktop={isDesktop} />;
})}
</tbody>
</table> </table>
): emptyTip; ): emptyTip;
} }
} }
} }
class TableBody extends Component {
constructor(props) {
super(props);
this.state = {
items: this.props.items
};
}
render() {
let listLinkedDevices = this.state.items.map(function(item, index) {
return <Item key={index} data={item} />;
}, this);
return (
<tbody>{listLinkedDevices}</tbody>
);
}
}
class Item extends Component { class Item extends Component {
constructor(props) { constructor(props) {
@@ -113,15 +97,11 @@ class Item extends Component {
this.setState({ this.setState({
unlinked: true unlinked: true
}); });
let msg_s = gettext('Successfully unlink %(name)s.'); let msg_s = gettext('Successfully unlinked %(name)s.');
msg_s = msg_s.replace('%(name)s', data.device_name); msg_s = msg_s.replace('%(name)s', data.device_name);
toaster.success(msg_s); toaster.success(msg_s);
}).catch((error) => { }).catch((error) => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
if (errMessage === gettext('Error')) {
errMessage = gettext('Failed to unlink %(name)s');
errMessage = errMessage.replace('%(name)s', data.device_name);
}
toaster.danger(errMessage); toaster.danger(errMessage);
}); });
} }
@@ -176,11 +156,7 @@ class Item extends Component {
</tr> </tr>
); );
if (window.innerWidth >= 768) { return this.props.isDesktop ? desktopItem : mobileItem;
return desktopItem;
} else {
return mobileItem;
}
} }
} }

View File

@@ -161,7 +161,7 @@ class MyLibraries extends Component {
<div className="cur-view-container"> <div className="cur-view-container">
<div className="cur-view-path align-items-center"> <div className="cur-view-path align-items-center">
<h3 className="sf-heading m-0">{gettext('My Libraries')}</h3> <h3 className="sf-heading m-0">{gettext('My Libraries')}</h3>
{(window.innerWidth < 768) && <span className="sf3-font sf3-font-sort action-icon" onClick={this.toggleSortOptionsDialog}></span>} {(!Utils.isDesktop() && this.state.repoList.length > 0) && <span className="sf3-font sf3-font-sort action-icon" onClick={this.toggleSortOptionsDialog}></span>}
</div> </div>
<div className="cur-view-content"> <div className="cur-view-content">
{this.state.isLoading && <Loading />} {this.state.isLoading && <Loading />}

View File

@@ -114,11 +114,9 @@ class MylibRepoListItem extends React.Component {
if (this.state.isStarred) { if (this.state.isStarred) {
seafileAPI.unstarItem(this.props.repo.repo_id, '/').then(() => { seafileAPI.unstarItem(this.props.repo.repo_id, '/').then(() => {
this.setState({isStarred: !this.state.isStarred}); this.setState({isStarred: !this.state.isStarred});
if (window.innerWidth < 768) {
const msg = gettext('Successfully unstarred {library_name_placeholder}.') const msg = gettext('Successfully unstarred {library_name_placeholder}.')
.replace('{library_name_placeholder}', repoName); .replace('{library_name_placeholder}', repoName);
toaster.success(msg); toaster.success(msg);
}
}).catch(error => { }).catch(error => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage); toaster.danger(errMessage);
@@ -126,11 +124,9 @@ class MylibRepoListItem extends React.Component {
} else { } else {
seafileAPI.starItem(this.props.repo.repo_id, '/').then(() => { seafileAPI.starItem(this.props.repo.repo_id, '/').then(() => {
this.setState({isStarred: !this.state.isStarred}); this.setState({isStarred: !this.state.isStarred});
if (window.innerWidth < 768) {
const msg = gettext('Successfully starred {library_name_placeholder}.') const msg = gettext('Successfully starred {library_name_placeholder}.')
.replace('{library_name_placeholder}', repoName); .replace('{library_name_placeholder}', repoName);
toaster.success(msg); toaster.success(msg);
}
}).catch(error => { }).catch(error => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage); toaster.danger(errMessage);

View File

@@ -74,10 +74,15 @@ class Content extends Component {
</thead> </thead>
); );
const isDesktop = Utils.isDesktop();
const table = ( const table = (
<table className={window.innerWidth >= 768 ? '' : 'table-thead-hidden'}> <table className={isDesktop ? '' : 'table-thead-hidden'}>
{window.innerWidth >= 768 ? desktopThead : <LibsMobileThead />} {isDesktop ? desktopThead : <LibsMobileThead />}
<TableBody items={items} /> <tbody>
{items.map((item, index) => {
return <Item key={index} data={item} isDesktop={isDesktop} />;
})}
</tbody>
</table> </table>
); );
@@ -95,24 +100,6 @@ Content.propTypes = {
sortItems: PropTypes.func.isRequired sortItems: PropTypes.func.isRequired
}; };
class TableBody extends Component {
render() {
let listItems = this.props.items.map(function(item, index) {
return <Item key={index} data={item} />;
}, this);
return (
<tbody>{listItems}</tbody>
);
}
}
TableBody.propTypes = {
items: PropTypes.array.isRequired
};
class Item extends Component { class Item extends Component {
constructor(props) { constructor(props) {
@@ -187,11 +174,9 @@ class Item extends Component {
if (this.state.isStarred) { if (this.state.isStarred) {
seafileAPI.unstarItem(this.props.data.repo_id, '/').then(() => { seafileAPI.unstarItem(this.props.data.repo_id, '/').then(() => {
this.setState({isStarred: !this.state.isStarred}); this.setState({isStarred: !this.state.isStarred});
if (window.innerWidth < 768) { const msg = gettext('Successfully unstarred {library_name_placeholder}.')
const msg = gettext('Successfully unstarred {library_name_placeholder}.') .replace('{library_name_placeholder}', repoName);
.replace('{library_name_placeholder}', repoName); toaster.success(msg);
toaster.success(msg);
}
}).catch(error => { }).catch(error => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage); toaster.danger(errMessage);
@@ -199,11 +184,9 @@ class Item extends Component {
} else { } else {
seafileAPI.starItem(this.props.data.repo_id, '/').then(() => { seafileAPI.starItem(this.props.data.repo_id, '/').then(() => {
this.setState({isStarred: !this.state.isStarred}); this.setState({isStarred: !this.state.isStarred});
if (window.innerWidth < 768) { const msg = gettext('Successfully starred {library_name_placeholder}.')
const msg = gettext('Successfully starred {library_name_placeholder}.') .replace('{library_name_placeholder}', repoName);
.replace('{library_name_placeholder}', repoName); toaster.success(msg);
toaster.success(msg);
}
}).catch(error => { }).catch(error => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage); toaster.danger(errMessage);
@@ -313,11 +296,12 @@ class Item extends Component {
</Fragment> </Fragment>
); );
return window.innerWidth >= 768 ? desktopItem : mobileItem; return this.props.isDesktop ? desktopItem : mobileItem;
} }
} }
Item.propTypes = { Item.propTypes = {
isDesktop: PropTypes.bool.isRequired,
data: PropTypes.object.isRequired data: PropTypes.object.isRequired
}; };
@@ -390,7 +374,7 @@ class SharedLibraries extends Component {
<div className="cur-view-container"> <div className="cur-view-container">
<div className="cur-view-path align-items-center"> <div className="cur-view-path align-items-center">
<h3 className="sf-heading m-0">{gettext('Shared with me')}</h3> <h3 className="sf-heading m-0">{gettext('Shared with me')}</h3>
{(window.innerWidth < 768) && <span className="sf3-font sf3-font-sort action-icon" onClick={this.toggleSortOptionsDialog}></span>} {(!Utils.isDesktop() && this.state.items.length > 0) && <span className="sf3-font sf3-font-sort action-icon" onClick={this.toggleSortOptionsDialog}></span>}
</div> </div>
<div className="cur-view-content"> <div className="cur-view-content">
<Content <Content

View File

@@ -195,13 +195,15 @@ class PublicSharedView extends React.Component {
<Dropdown isOpen={this.state.isCreateMenuShow} toggle={this.onAddRepoToggle}> <Dropdown isOpen={this.state.isCreateMenuShow} toggle={this.onAddRepoToggle}>
<MediaQuery query="(min-width: 768px)"> <MediaQuery query="(min-width: 768px)">
<DropdownToggle className='btn btn-secondary operation-item'> <DropdownToggle className='btn btn-secondary operation-item'>
<i className="fas fa-plus-square text-secondary"></i>{gettext('Add Library')} <i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('Add Library')}
</DropdownToggle> </DropdownToggle>
</MediaQuery> </MediaQuery>
<MediaQuery query="(max-width: 767.8px)"> <MediaQuery query="(max-width: 767.8px)">
<DropdownToggle className='btn btn-secondary operation-item my-1'> <DropdownToggle
<i className="fas fa-plus-square text-secondary mr-1"></i>{gettext('Add Library')} tag="span"
</DropdownToggle> className="sf2-icon-plus mobile-toolbar-icon"
title={gettext('Add Library')}
/>
</MediaQuery> </MediaQuery>
<DropdownMenu> <DropdownMenu>
<DropdownItem onClick={this.onSelectRepoToggle}>{gettext('Share existing libraries')}</DropdownItem> <DropdownItem onClick={this.onSelectRepoToggle}>{gettext('Share existing libraries')}</DropdownItem>
@@ -217,7 +219,7 @@ class PublicSharedView extends React.Component {
<div className="cur-view-container"> <div className="cur-view-container">
<div className="cur-view-path align-items-center"> <div className="cur-view-path align-items-center">
<h3 className="sf-heading m-0">{gettext('Shared with all')}</h3> <h3 className="sf-heading m-0">{gettext('Shared with all')}</h3>
{(window.innerWidth < 768) && <span className="sf3-font sf3-font-sort action-icon" onClick={this.toggleSortOptionsDialog}></span>} {(!Utils.isDesktop() && this.state.repoList.length > 0) && <span className="sf3-font sf3-font-sort action-icon" onClick={this.toggleSortOptionsDialog}></span>}
</div> </div>
<div className="cur-view-content"> <div className="cur-view-content">
{this.state.isLoading && <Loading />} {this.state.isLoading && <Loading />}

View File

@@ -46,9 +46,10 @@ class Content extends Component {
</thead> </thead>
); );
const isDesktop = Utils.isDesktop();
return items.length ? ( return items.length ? (
<table className={`table-hover ${window.innerWidth >= 768 ? '': 'table-thead-hidden'}`}> <table className={`table-hover ${isDesktop ? '': 'table-thead-hidden'}`}>
{window.innerWidth >= 768 ? desktopThead : mobileThead} {isDesktop ? desktopThead : mobileThead}
<TableBody items={items} /> <TableBody items={items} />
</table> </table>
) : emptyTip; ) : emptyTip;
@@ -240,11 +241,7 @@ class Item extends Component {
</tr> </tr>
); );
if (window.innerWidth >= 768) { return Utils.isDesktop() ? desktopItem : mobileItem;
return desktopItem;
} else {
return mobileItem;
}
} }
} }
@@ -260,7 +257,6 @@ class Starred extends Component {
componentDidMount() { componentDidMount() {
seafileAPI.listStarredItems().then((res) => { seafileAPI.listStarredItems().then((res) => {
//res: {data: Array(2), status: 200, statusText: "OK", headers: {…}, config: {…}, …}
this.setState({ this.setState({
loading: false, loading: false,
items: res.data.starred_item_list items: res.data.starred_item_list

View File

@@ -1,6 +1,5 @@
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import MediaQuery from 'react-responsive';
import { gettext, repoID, slug, siteRoot, username } from '../../utils/constants'; import { gettext, repoID, slug, siteRoot, username } from '../../utils/constants';
import CommonToolbar from '../../components/toolbar/common-toolbar'; import CommonToolbar from '../../components/toolbar/common-toolbar';
import WikiMarkdownViewer from '../../components/wiki-markdown-viewer'; import WikiMarkdownViewer from '../../components/wiki-markdown-viewer';
@@ -100,14 +99,11 @@ class MainPanel extends Component {
<Fragment> <Fragment>
<div className="cur-view-toolbar"> <div className="cur-view-toolbar">
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title="Side Nav Menu" onClick={this.onMenuClick}></span> <span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title="Side Nav Menu" onClick={this.onMenuClick}></span>
<MediaQuery query="(min-width: 768px)"> {this.props.permission == 'rw' && (
{this.props.permission === 'rw' && Utils.isDesktop() ?
<button className="btn btn-secondary operation-item" title="Edit" onClick={this.onEditClick}>{gettext('Edit')}</button>} <button className="btn btn-secondary operation-item" title={gettext('Edit')} onClick={this.onEditClick}>{gettext('Edit')}</button> :
</MediaQuery> <span className="fa fa-pencil-alt mobile-toolbar-icon" title={gettext('Edit')} onClick={this.onEditClick} style={{'font-size': '1.1rem'}}></span>
<MediaQuery query="(max-width: 767.8px)"> )}
{this.props.permission === 'rw' &&
<button className="btn btn-secondary operation-item my-1" title="Edit" onClick={this.onEditClick}>{gettext('Edit')}</button>}
</MediaQuery>
</div> </div>
<CommonToolbar <CommonToolbar
repoID={repoID} repoID={repoID}

View File

@@ -49,7 +49,7 @@ class Wiki extends Component {
} }
componentWillMount() { componentWillMount() {
if (window.screen.width <= 768) { if (!Utils.isDesktop()) {
this.setState({ closeSideBar: true }); this.setState({ closeSideBar: true });
} }
} }