mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 10:50:24 +00:00
feat: add info icon into toolbar
This commit is contained in:
@@ -5,13 +5,20 @@ import { I18nextProvider } from 'react-i18next';
|
|||||||
import i18n from './_i18n/i18n-seafile-editor';
|
import i18n from './_i18n/i18n-seafile-editor';
|
||||||
import MarkdownEditor from './pages/markdown-editor';
|
import MarkdownEditor from './pages/markdown-editor';
|
||||||
import Loading from './components/loading';
|
import Loading from './components/loading';
|
||||||
|
import { CollaboratorsProvider, EnableMetadataProvider } from './metadata';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
|
const { repoID } = window.app.pageOptions;
|
||||||
|
|
||||||
ReactDom.render(
|
ReactDom.render(
|
||||||
<I18nextProvider i18n={ i18n } >
|
<I18nextProvider i18n={ i18n } >
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<MarkdownEditor />
|
<EnableMetadataProvider repoID={repoID} >
|
||||||
|
<CollaboratorsProvider repoID={repoID}>
|
||||||
|
<MarkdownEditor />
|
||||||
|
</CollaboratorsProvider>
|
||||||
|
</EnableMetadataProvider>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</I18nextProvider>,
|
</I18nextProvider>,
|
||||||
document.getElementById('root')
|
document.getElementById('root')
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { EXTERNAL_EVENTS, EventBus } from '@seafile/seafile-editor';
|
||||||
import { gettext, canGenerateShareLink, isPro, mediaUrl, canLockUnlockFile } from '../../../utils/constants';
|
import { gettext, canGenerateShareLink, isPro, mediaUrl, canLockUnlockFile } from '../../../utils/constants';
|
||||||
import ButtonGroup from './button-group';
|
import ButtonGroup from './button-group';
|
||||||
import ButtonItem from './button-item';
|
import ButtonItem from './button-item';
|
||||||
@@ -7,6 +8,10 @@ import CollabUsersButton from './collab-users-button';
|
|||||||
import MoreMenu from './more-menu';
|
import MoreMenu from './more-menu';
|
||||||
import FileInfo from './file-info';
|
import FileInfo from './file-info';
|
||||||
import Icon from '../../../components/icon';
|
import Icon from '../../../components/icon';
|
||||||
|
import EmbeddedFileDetails from '../../../components/dirent-detail/embedded-file-details';
|
||||||
|
import { seafileAPI } from '../../../utils/seafile-api';
|
||||||
|
import { Utils } from '../../../utils/utils';
|
||||||
|
import Dirent from '../../../../src/models/dirent';
|
||||||
|
|
||||||
import '../css/header-toolbar.css';
|
import '../css/header-toolbar.css';
|
||||||
|
|
||||||
@@ -37,6 +42,10 @@ class HeaderToolbar extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
currentDirent: null,
|
||||||
|
dirPath: '/',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadFile = () => {
|
downloadFile = () => {
|
||||||
@@ -53,6 +62,61 @@ class HeaderToolbar extends React.Component {
|
|||||||
window.location.href = editorApi.getParentDictionaryUrl();
|
window.location.href = editorApi.getParentDictionaryUrl();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.calculateDirPath();
|
||||||
|
this.getDirentList();
|
||||||
|
}
|
||||||
|
|
||||||
|
onArticleInfoToggle = () => {
|
||||||
|
const eventBus = EventBus.getInstance();
|
||||||
|
eventBus.dispatch(EXTERNAL_EVENTS.ON_ARTICLE_INFO_TOGGLE);
|
||||||
|
};
|
||||||
|
|
||||||
|
calculateDirPath = () => {
|
||||||
|
const { filePath } = window.app.pageOptions;
|
||||||
|
const dirPath = filePath.substring(0, filePath.lastIndexOf('/') || 0);
|
||||||
|
this.setState({ dirPath: dirPath || '/' });
|
||||||
|
};
|
||||||
|
|
||||||
|
getDirentList = () => {
|
||||||
|
const { repoID, filePath } = window.app.pageOptions;
|
||||||
|
return seafileAPI.listDir(repoID, this.state.dirPath, { 'with_thumbnail': true }).then(res => {
|
||||||
|
res.data.dirent_list.forEach(item => {
|
||||||
|
const dirent = new Dirent(item);
|
||||||
|
if (Utils.joinPath(item.parent_dir, item.name) === filePath) {
|
||||||
|
this.setState({ currentDirent: dirent });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch((err) => {
|
||||||
|
Utils.getErrorMsg(err, true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
onArticleInfoDetailToggle = () => {
|
||||||
|
const { repoID, filePath } = window.app.pageOptions;
|
||||||
|
const { currentDirent } = this.state;
|
||||||
|
const repoInfo = { permission: 'rw' };
|
||||||
|
|
||||||
|
const eventBus = EventBus.getInstance();
|
||||||
|
eventBus.dispatch(EXTERNAL_EVENTS.ON_ARTICLE_INFO_DETAIL_TOGGLE, {
|
||||||
|
component: EmbeddedFileDetails,
|
||||||
|
props: {
|
||||||
|
repoID: repoID,
|
||||||
|
repoInfo: repoInfo,
|
||||||
|
dirent: currentDirent,
|
||||||
|
path: filePath,
|
||||||
|
type: 'global',
|
||||||
|
onClose: this.onArticleInfoToggle,
|
||||||
|
width: 300,
|
||||||
|
component: {
|
||||||
|
headerComponent: {
|
||||||
|
closeIcon: (<i className="iconfont icon-x"></i>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { contentChanged, saving, isLocked, lockedByMe } = this.props;
|
let { contentChanged, saving, isLocked, lockedByMe } = this.props;
|
||||||
|
|
||||||
@@ -94,6 +158,17 @@ class HeaderToolbar extends React.Component {
|
|||||||
onMouseDown={this.props.toggleLockFile}
|
onMouseDown={this.props.toggleLockFile}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{canGenerateShareLink && (
|
||||||
|
<ButtonItem
|
||||||
|
id='info'
|
||||||
|
text={gettext('Info')}
|
||||||
|
icon='info'
|
||||||
|
onClick={() => {
|
||||||
|
this.onArticleInfoDetailToggle();
|
||||||
|
this.onArticleInfoToggle();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{canGenerateShareLink && (
|
{canGenerateShareLink && (
|
||||||
<ButtonItem
|
<ButtonItem
|
||||||
id='shareBtn'
|
id='shareBtn'
|
||||||
|
@@ -62,6 +62,7 @@
|
|||||||
canLockUnlockFile: {% if can_lock_unlock_file %}true{% else %}false{% endif %},
|
canLockUnlockFile: {% if can_lock_unlock_file %}true{% else %}false{% endif %},
|
||||||
canDownloadFile: {% if can_download_file %}true{% else %}false{% endif %},
|
canDownloadFile: {% if can_download_file %}true{% else %}false{% endif %},
|
||||||
fileDownloadURL: {% if file_download_url %}'{{ file_download_url|escapejs }}'{% else %}''{% endif %},
|
fileDownloadURL: {% if file_download_url %}'{{ file_download_url|escapejs }}'{% else %}''{% endif %},
|
||||||
|
enableMetadataManagement: {% if enable_metadata_management %} true {% else %} false {% endif %},
|
||||||
},
|
},
|
||||||
userInfo: {
|
userInfo: {
|
||||||
username: '{{ user.username }}',
|
username: '{{ user.username }}',
|
||||||
|
Reference in New Issue
Block a user