mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 08:28:11 +00:00
[dir view] added 'add md document' tip for empty library (#2668)
This commit is contained in:
@@ -172,6 +172,7 @@ class DirPanel extends React.Component {
|
|||||||
isDirentListLoading={this.props.isDirentListLoading}
|
isDirentListLoading={this.props.isDirentListLoading}
|
||||||
isAllItemSelected={this.props.isAllDirentSelected}
|
isAllItemSelected={this.props.isAllDirentSelected}
|
||||||
isRepoOwner={this.state.isRepoOwner}
|
isRepoOwner={this.state.isRepoOwner}
|
||||||
|
onAddFile={this.props.onAddFile}
|
||||||
onItemDetails={this.onItemDetails}
|
onItemDetails={this.onItemDetails}
|
||||||
onItemMove={this.props.onItemMove}
|
onItemMove={this.props.onItemMove}
|
||||||
onItemCopy={this.props.onItemCopy}
|
onItemCopy={this.props.onItemCopy}
|
||||||
|
@@ -1,8 +1,12 @@
|
|||||||
import React from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { gettext } from '../../utils/constants';
|
import { gettext } from '../../utils/constants';
|
||||||
import Loading from '../loading';
|
import Loading from '../loading';
|
||||||
import DirentListItem from './dirent-list-item';
|
import DirentListItem from './dirent-list-item';
|
||||||
|
import ModalPortal from '../modal-portal';
|
||||||
|
import CreateFile from '../../components/dialog/create-file-dialog';
|
||||||
|
|
||||||
|
import '../../css/tip-for-new-md.css';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
path: PropTypes.string.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
@@ -12,6 +16,7 @@ const propTypes = {
|
|||||||
isAllItemSelected: PropTypes.bool.isRequired,
|
isAllItemSelected: PropTypes.bool.isRequired,
|
||||||
isDirentListLoading: PropTypes.bool.isRequired,
|
isDirentListLoading: PropTypes.bool.isRequired,
|
||||||
direntList: PropTypes.array.isRequired,
|
direntList: PropTypes.array.isRequired,
|
||||||
|
onAddFile: PropTypes.func.isRequired,
|
||||||
onItemDelete: PropTypes.func.isRequired,
|
onItemDelete: PropTypes.func.isRequired,
|
||||||
onAllItemSelected: PropTypes.func.isRequired,
|
onAllItemSelected: PropTypes.func.isRequired,
|
||||||
onItemSelected: PropTypes.func.isRequired,
|
onItemSelected: PropTypes.func.isRequired,
|
||||||
@@ -29,6 +34,8 @@ class DirentListView extends React.Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
isItemFreezed: false,
|
isItemFreezed: false,
|
||||||
|
isCreateFileDialogShow: false,
|
||||||
|
fileType: ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +55,25 @@ class DirentListView extends React.Component {
|
|||||||
this.props.onItemDetails(dirent);
|
this.props.onItemDetails(dirent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCreateFileToggle = () => {
|
||||||
|
this.setState({
|
||||||
|
isCreateFileDialogShow: !this.state.isCreateFileDialogShow,
|
||||||
|
fileType: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onCreateMarkdownToggle = () => {
|
||||||
|
this.setState({
|
||||||
|
isCreateFileDialogShow: !this.state.isCreateFileDialogShow,
|
||||||
|
fileType: '.md'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onAddFile = (filePath, isDraft) => {
|
||||||
|
this.setState({isCreateFileDialogShow: false});
|
||||||
|
this.props.onAddFile(filePath, isDraft);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { direntList } = this.props;
|
const { direntList } = this.props;
|
||||||
|
|
||||||
@@ -55,6 +81,27 @@ class DirentListView extends React.Component {
|
|||||||
return (<Loading />);
|
return (<Loading />);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.props.path == '/' && !direntList.length) {
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<div className="tip-for-new-md d-flex">
|
||||||
|
<button className="big-new-md-button" onClick={this.onCreateMarkdownToggle}><span className="sf2-icon-plus add-md-icon"></span><br />{gettext('Markdown Document')}</button>
|
||||||
|
<p>{gettext('You can create online document using Markdown format easily. When creating a document, you can mark it as draft. After finishing the draft, you can ask others to review it. They can view the document history in the review page and leave comments on the document.')}</p>
|
||||||
|
</div>
|
||||||
|
{this.state.isCreateFileDialogShow && (
|
||||||
|
<ModalPortal>
|
||||||
|
<CreateFile
|
||||||
|
parentPath={this.props.path}
|
||||||
|
fileType={this.state.fileType}
|
||||||
|
onAddFile={this.onAddFile}
|
||||||
|
addFileCancel={this.onCreateFileToggle}
|
||||||
|
/>
|
||||||
|
</ModalPortal>
|
||||||
|
)}
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
12
frontend/src/css/tip-for-new-md.css
Normal file
12
frontend/src/css/tip-for-new-md.css
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
.tip-for-new-md {
|
||||||
|
padding: 5em 8em;
|
||||||
|
}
|
||||||
|
.big-new-md-button {
|
||||||
|
padding: .9em 2em 1em;
|
||||||
|
background: #eee;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-right: 1.5em;
|
||||||
|
}
|
||||||
|
.add-md-icon {
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
@@ -87,6 +87,7 @@
|
|||||||
.sf2-icon-close:before { content:"\e035"; }
|
.sf2-icon-close:before { content:"\e035"; }
|
||||||
.sf2-icon-two-columns:before { content:"\e036"; }
|
.sf2-icon-two-columns:before { content:"\e036"; }
|
||||||
.sf2-icon-tag:before {content:"\e037"}
|
.sf2-icon-tag:before {content:"\e037"}
|
||||||
|
.sf2-icon-plus:before { content: "\e027"; }
|
||||||
|
|
||||||
/* common class and element style*/
|
/* common class and element style*/
|
||||||
a { color:#eb8205; }
|
a { color:#eb8205; }
|
||||||
|
Reference in New Issue
Block a user