1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-10 19:29:56 +00:00

add-external

This commit is contained in:
yinjianfei
2024-01-06 14:17:43 +08:00
parent 736a3a18f1
commit ae49bed70f
2 changed files with 74 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
import React, { Fragment } from 'react';
import { SimpleEditor } from '@seafile/sdoc-editor';
import ExternalOperations from './external-operations';
import { seafileAPI } from '../../../utils/seafile-api';
import Dirent from '../../../models/dirent';
import { Utils } from '../../../utils/utils';
export default class SdocEditor extends React.Component {
@@ -10,12 +12,14 @@ export default class SdocEditor extends React.Component {
const { isStarred, isSdocDraft } = window.app.pageOptions;
this.state = {
isStarred: isStarred,
isDraft: isSdocDraft
isDraft: isSdocDraft,
direntList: []
};
}
componentDidMount() {
this.onSetFavicon();
this.getDirentList();
}
toggleStar = (isStarred) => {
@@ -39,9 +43,36 @@ export default class SdocEditor extends React.Component {
this.onSetFavicon('_notification');
};
getDirPath = () => {
const { docPath } = window.seafile;
const index = docPath.lastIndexOf('/');
if (index) {
return docPath.slice(0, index);
}
return '/';
};
getDirentList = () => {
const { repoID } = window.seafile;
const path = this.getDirPath();
seafileAPI.listDir(repoID, path, {'with_thumbnail': true}).then(res => {
let direntList = [];
res.data.dirent_list.forEach(item => {
let dirent = new Dirent(item);
direntList.push(dirent);
});
this.setState({
direntList: direntList
});
}).catch((err) => {
Utils.getErrorMsg(err, true);
});
};
render() {
const { repoID, docPath, docName, docPerm } = window.seafile;
const { isStarred, isDraft } = this.state;
const { isStarred, isDraft, direntList } = this.state;
const dirPath = this.getDirPath();
return (
<Fragment>
<SimpleEditor isStarred={isStarred} isDraft={isDraft} />
@@ -51,6 +82,8 @@ export default class SdocEditor extends React.Component {
docName={docName}
docPerm={docPerm}
isStarred={isStarred}
direntList={direntList}
dirPath={dirPath}
toggleStar={this.toggleStar}
unmarkDraft={this.unmarkDraft}
onNewNotification={this.onNewNotification}