mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-19 07:27:56 +00:00
Draft optimized (#2409)
* repair drafts * repair naming error * optimized code * sentence error
This commit is contained in:
parent
3273900056
commit
5cffd4cb69
@ -9,7 +9,7 @@ const propTypes = {
|
|||||||
isItemFreezed: PropTypes.bool.isRequired,
|
isItemFreezed: PropTypes.bool.isRequired,
|
||||||
onMenuToggleClick: PropTypes.func.isRequired,
|
onMenuToggleClick: PropTypes.func.isRequired,
|
||||||
}
|
}
|
||||||
class ListItem extends React.Component {
|
class DraftListItem extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -77,6 +77,6 @@ class ListItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListItem.propTypes = propTypes;
|
DraftListItem.propTypes = propTypes;
|
||||||
|
|
||||||
export default ListItem;
|
export default DraftListItem;
|
@ -9,7 +9,7 @@ const propTypes = {
|
|||||||
onPublishHandler: PropTypes.func.isRequired
|
onPublishHandler: PropTypes.func.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
class ListMenu extends React.Component {
|
class DraftListMenu extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let style = '';
|
let style = '';
|
||||||
@ -28,6 +28,6 @@ class ListMenu extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListMenu.propTypes = propTypes;
|
DraftListMenu.propTypes = propTypes;
|
||||||
|
|
||||||
export default ListMenu;
|
export default DraftListMenu;
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { gettext } from '../constants';
|
import { gettext } from '../constants';
|
||||||
import ListItem from './list-item';
|
import DraftListItem from './draft-list-item';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
isItemFreezed: PropTypes.bool.isRequired,
|
isItemFreezed: PropTypes.bool.isRequired,
|
||||||
@ -9,7 +9,7 @@ const propTypes = {
|
|||||||
onMenuToggleClick: PropTypes.func.isRequired,
|
onMenuToggleClick: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ListView extends React.Component {
|
class DraftListView extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let drafts = this.props.draftList;
|
let drafts = this.props.draftList;
|
||||||
@ -21,14 +21,14 @@ class ListView extends React.Component {
|
|||||||
<th style={{width: '4%'}}>{/*img*/}</th>
|
<th style={{width: '4%'}}>{/*img*/}</th>
|
||||||
<th style={{width: '46%'}}>{gettext('Name')}</th>
|
<th style={{width: '46%'}}>{gettext('Name')}</th>
|
||||||
<th style={{width: '20%'}}>{gettext('Owner')}</th>
|
<th style={{width: '20%'}}>{gettext('Owner')}</th>
|
||||||
<th style={{width: '20%'}}>{gettext('Update time')}</th>
|
<th style={{width: '20%'}}>{gettext('Last Update')}</th>
|
||||||
<th style={{width: '10%'}}></th>
|
<th style={{width: '10%'}}></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{ drafts && drafts.map((draft) => {
|
{ drafts && drafts.map((draft) => {
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<DraftListItem
|
||||||
key={draft.id}
|
key={draft.id}
|
||||||
draft={draft}
|
draft={draft}
|
||||||
onMenuToggleClick={this.props.onMenuToggleClick}
|
onMenuToggleClick={this.props.onMenuToggleClick}
|
||||||
@ -43,6 +43,6 @@ class ListView extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView.propTypes = propTypes;
|
DraftListView.propTypes = propTypes;
|
||||||
|
|
||||||
export default ListView;
|
export default DraftListView;
|
@ -4,17 +4,17 @@ export const keyCodes = {
|
|||||||
tab: 9,
|
tab: 9,
|
||||||
up: 38,
|
up: 38,
|
||||||
down: 40
|
down: 40
|
||||||
}
|
};
|
||||||
|
|
||||||
export function bytesToSize(bytes) {
|
export function bytesToSize(bytes) {
|
||||||
if (typeof(bytes) == 'undefined') return ' '
|
if (typeof(bytes) == 'undefined') return ' ';
|
||||||
|
|
||||||
if(bytes < 0) return '--'
|
if(bytes < 0) return '--';
|
||||||
const sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']
|
const sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
|
||||||
|
|
||||||
if (bytes === 0) return bytes + ' ' + sizes[0]
|
if (bytes === 0) return bytes + ' ' + sizes[0];
|
||||||
|
|
||||||
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1000)), 10)
|
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1000)), 10);
|
||||||
if (i === 0) return bytes + ' ' + sizes[i]
|
if (i === 0) return bytes + ' ' + sizes[i];
|
||||||
return (bytes / (1000 ** i)).toFixed(1) + ' ' + sizes[i]
|
return (bytes / (1000 ** i)).toFixed(1) + ' ' + sizes[i];
|
||||||
}
|
}
|
||||||
|
@ -145,8 +145,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.empty-tip h2 {
|
.empty-tip h2 {
|
||||||
|
font-size: 1.25rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
color: #222;
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end tip */
|
/* end tip */
|
||||||
|
|
||||||
/* begin more component */
|
/* begin more component */
|
||||||
|
@ -3,7 +3,6 @@ import ReactDOM from 'react-dom';
|
|||||||
import editUtilties from './utils/editor-utilties';
|
import editUtilties from './utils/editor-utilties';
|
||||||
import { filePath } from './components/constants';
|
import { filePath } from './components/constants';
|
||||||
import URLDecorator from './utils/url-decorator';
|
import URLDecorator from './utils/url-decorator';
|
||||||
import { processor } from '@seafile/seafile-editor/src/lib/seafile-markdown2html';
|
|
||||||
import SidePanel from './pages/file-history/side-panel';
|
import SidePanel from './pages/file-history/side-panel';
|
||||||
import MainPanel from './pages/file-history/main-panel';
|
import MainPanel from './pages/file-history/main-panel';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -2,8 +2,8 @@ import React from 'react';
|
|||||||
import { gettext } from '../../components/constants';
|
import { gettext } from '../../components/constants';
|
||||||
import editUtilties from '../../utils/editor-utilties';
|
import editUtilties from '../../utils/editor-utilties';
|
||||||
import Loading from '../../components/loading';
|
import Loading from '../../components/loading';
|
||||||
import ListView from '../../components/list-view/list-view';
|
import DraftListView from '../../components/draft-list-view/draft-list-view';
|
||||||
import ListMenu from '../../components/list-view/list-menu';
|
import DraftListMenu from '../../components/draft-list-view/draft-list-menu';
|
||||||
|
|
||||||
class DraftsView extends React.Component {
|
class DraftsView extends React.Component {
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class DraftsView extends React.Component {
|
|||||||
<div className="cur-view-content" style={{padding: 0}}>
|
<div className="cur-view-content" style={{padding: 0}}>
|
||||||
{this.state.isLoadingDraft && <Loading /> }
|
{this.state.isLoadingDraft && <Loading /> }
|
||||||
{(!this.state.isLoadingDraft && this.state.draftList.length !==0) &&
|
{(!this.state.isLoadingDraft && this.state.draftList.length !==0) &&
|
||||||
<ListView
|
<DraftListView
|
||||||
draftList={this.state.draftList}
|
draftList={this.state.draftList}
|
||||||
isItemFreezed={this.state.isItemFreezed}
|
isItemFreezed={this.state.isItemFreezed}
|
||||||
onMenuToggleClick={this.onMenuToggleClick}
|
onMenuToggleClick={this.onMenuToggleClick}
|
||||||
@ -95,11 +95,12 @@ class DraftsView extends React.Component {
|
|||||||
}
|
}
|
||||||
{(!this.state.isLoadingDraft && this.state.draftList.length === 0) &&
|
{(!this.state.isLoadingDraft && this.state.draftList.length === 0) &&
|
||||||
<div className="message empty-tip">
|
<div className="message empty-tip">
|
||||||
<h2>{gettext('There is no draft file existing')}</h2>
|
<h2>{gettext('No draft yet')}</h2>
|
||||||
|
<p>{gettext('Draft is a way to let you collaborate with others on files. You can create a draft from a file, edit the draft and then ask for a review. The original file will be updated only after the draft be reviewed.')}</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{this.state.isMenuShow &&
|
{this.state.isMenuShow &&
|
||||||
<ListMenu
|
<DraftListMenu
|
||||||
isMenuShow={this.state.isMenuShow}
|
isMenuShow={this.state.isMenuShow}
|
||||||
currentDraft={this.state.currentDraft}
|
currentDraft={this.state.currentDraft}
|
||||||
menuPosition={this.state.menuPosition}
|
menuPosition={this.state.menuPosition}
|
||||||
|
@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import Prism from 'prismjs';
|
import Prism from 'prismjs';
|
||||||
import Loading from '../../components/loading';
|
import Loading from '../../components/loading';
|
||||||
import CommonToolbar from '../../components/toolbar/common-toolbar';
|
import CommonToolbar from '../../components/toolbar/common-toolbar';
|
||||||
import DiffViewer from '@seafile/seafile-editor/dist/diff-viewer/diff-viewer'
|
import DiffViewer from '@seafile/seafile-editor/dist/diff-viewer/diff-viewer';
|
||||||
import '../../css/initial-style.css';
|
import '../../css/initial-style.css';
|
||||||
|
|
||||||
require('@seafile/seafile-editor/src/lib/code-hight-package');
|
require('@seafile/seafile-editor/src/lib/code-hight-package');
|
||||||
|
@ -622,11 +622,13 @@ define([
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
beforeSend: Common.prepareCSRFToken,
|
beforeSend: Common.prepareCSRFToken,
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
var msg = gettext("New Success.");
|
var siteRoot = window.app.config.siteRoot;
|
||||||
Common.feedback(msg, 'success');
|
var repoID = res.draft_repo_id;
|
||||||
|
var filePath = res.draft_file_path;
|
||||||
|
window.location.href= siteRoot + 'lib/' + repoID + '/file' + filePath + '?mode=edit';
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
var err_msg = gettext("The draft is already exist.");
|
var err_msg = gettext("The draft already exists.");
|
||||||
Common.feedback(err_msg, 'error');
|
Common.feedback(err_msg, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user