mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 17:02:47 +00:00
Feat: code
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
.sdoc-revision .sdoc-revision-header .sdoc-revision-header-right {
|
.sdoc-revision .sdoc-revision-header .sdoc-revision-header-right {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-width: 100px;
|
min-width: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sdoc-revision .sdoc-revision-content {
|
.sdoc-revision .sdoc-revision-content {
|
||||||
|
@@ -11,10 +11,11 @@ import { seafileAPI } from '../../utils/seafile-api';
|
|||||||
|
|
||||||
import '../../css/layout.css';
|
import '../../css/layout.css';
|
||||||
import '../../css/sdoc-revision.css';
|
import '../../css/sdoc-revision.css';
|
||||||
|
import toaster from '../../components/toast';
|
||||||
|
|
||||||
const { serviceURL, avatarURL, siteRoot } = window.app.config;
|
const { serviceURL, avatarURL, siteRoot } = window.app.config;
|
||||||
const { username, name } = window.app.pageOptions;
|
const { username, name } = window.app.pageOptions;
|
||||||
const { repoID, fileName, filePath, docUuid, assetsUrl, fileDownloadLink, originFileDownloadLink, isPublished } = window.sdocRevision;
|
const { repoID, fileName, filePath, docUuid, assetsUrl, fileDownloadLink, originFileDownloadLink } = window.sdocRevision;
|
||||||
|
|
||||||
window.seafile = {
|
window.seafile = {
|
||||||
repoID,
|
repoID,
|
||||||
@@ -60,13 +61,21 @@ class SdocRevision extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edit = (event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
event.nativeEvent.stopImmediatePropagation();
|
||||||
|
window.location.href = `${siteRoot}lib/${repoID}/file${filePath}`;
|
||||||
|
}
|
||||||
|
|
||||||
publishRevision = (event) => {
|
publishRevision = (event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.nativeEvent.stopImmediatePropagation();
|
event.nativeEvent.stopImmediatePropagation();
|
||||||
seafileAPI.sdocPublishRevision(docUuid).then(res => {
|
seafileAPI.sdocPublishRevision(docUuid).then(res => {
|
||||||
console.log(res)
|
const { origin_file_path } = res.data;
|
||||||
|
window.location.href = `${siteRoot}lib/${repoID}/file${origin_file_path}`;
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log(error);
|
const errorMessage = Utils.getErrorMsg(error, false);
|
||||||
|
toaster.danger(gettext(errorMessage));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +83,7 @@ class SdocRevision extends React.Component {
|
|||||||
const { isLoading, errorMessage, revisionContent, originContent } = this.state;
|
const { isLoading, errorMessage, revisionContent, originContent } = this.state;
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="sdoc-revision-viewer d-flex align-items-center justify-content-center">
|
<div className="sdoc-revision-viewer h-100 d-flex align-items-center justify-content-center">
|
||||||
<Loading />
|
<Loading />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -82,7 +91,7 @@ class SdocRevision extends React.Component {
|
|||||||
|
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
return (
|
return (
|
||||||
<div className="sdoc-revision-viewer d-flex align-items-center justify-content-center">
|
<div className="sdoc-revision-viewer h-100 d-flex align-items-center justify-content-center">
|
||||||
{gettext(errorMessage)}
|
{gettext(errorMessage)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -97,18 +106,22 @@ class SdocRevision extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { isLoading, errorMessage } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sdoc-revision d-flex h-100 w-100 o-hidden">
|
<div className="sdoc-revision d-flex h-100 w-100 o-hidden">
|
||||||
<div className="sdoc-revision-container d-flex flex-column">
|
<div className="sdoc-revision-container d-flex flex-column">
|
||||||
<div className="sdoc-revision-header pt-2 pb-2 pl-4 pr-4 d-flex justify-content-between w-100 o-hidden">
|
<div className="sdoc-revision-header pl-4 pr-4 d-flex justify-content-between w-100 o-hidden">
|
||||||
<div className={classnames('sdoc-revision-header-left d-flex align-items-center o-hidden')}>
|
<div className={classnames('sdoc-revision-header-left h-100 d-flex align-items-center o-hidden')}>
|
||||||
<GoBack />
|
<GoBack />
|
||||||
<div className="file-name text-truncate">{fileName}</div>
|
<div className="file-name text-truncate">{fileName}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="sdoc-revision-header-right">
|
<div className="sdoc-revision-header-right h-100 d-flex align-items-center">
|
||||||
<Button color="success"></Button>
|
{(!isLoading && !errorMessage) && (
|
||||||
{!isPublished && (
|
<>
|
||||||
|
<Button color="success" className="mr-4" onClick={this.edit}>{gettext('Edit')}</Button>
|
||||||
<Button color="success" onClick={this.publishRevision}>{gettext('Publish')}</Button>
|
<Button color="success" onClick={this.publishRevision}>{gettext('Publish')}</Button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -11,6 +11,7 @@ const { username, name } = window.app.userInfo;
|
|||||||
const {
|
const {
|
||||||
repoID, repoName, parentDir, filePerm,
|
repoID, repoName, parentDir, filePerm,
|
||||||
docPath, docName, docUuid, seadocAccessToken, seadocServerUrl, assetsUrl,
|
docPath, docName, docUuid, seadocAccessToken, seadocServerUrl, assetsUrl,
|
||||||
|
isSdocRevision, isPublished,
|
||||||
} = window.app.pageOptions;
|
} = window.app.pageOptions;
|
||||||
|
|
||||||
window.seafile = {
|
window.seafile = {
|
||||||
@@ -32,6 +33,8 @@ window.seafile = {
|
|||||||
assetsUrl,
|
assetsUrl,
|
||||||
isShowInternalLink: true,
|
isShowInternalLink: true,
|
||||||
isStarIconShown: true, // for star/unstar
|
isStarIconShown: true, // for star/unstar
|
||||||
|
isSdocRevision,
|
||||||
|
isPublished,
|
||||||
revisionURL: Utils.generateRevisionURL(siteRoot, repoID, docPath),
|
revisionURL: Utils.generateRevisionURL(siteRoot, repoID, docPath),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user