diff --git a/frontend/src/css/sdoc-revision.css b/frontend/src/css/sdoc-revision.css index ac46fffb7d..53f1972780 100644 --- a/frontend/src/css/sdoc-revision.css +++ b/frontend/src/css/sdoc-revision.css @@ -20,7 +20,7 @@ .sdoc-revision .sdoc-revision-header .sdoc-revision-header-right { height: 100%; - min-width: 100px; + min-width: fit-content; } .sdoc-revision .sdoc-revision-content { diff --git a/frontend/src/pages/sdoc-revision/index.js b/frontend/src/pages/sdoc-revision/index.js index 0b6f3fc28a..d1faeee084 100644 --- a/frontend/src/pages/sdoc-revision/index.js +++ b/frontend/src/pages/sdoc-revision/index.js @@ -11,10 +11,11 @@ import { seafileAPI } from '../../utils/seafile-api'; import '../../css/layout.css'; import '../../css/sdoc-revision.css'; +import toaster from '../../components/toast'; const { serviceURL, avatarURL, siteRoot } = window.app.config; 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 = { 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) => { event.stopPropagation(); event.nativeEvent.stopImmediatePropagation(); 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 => { - 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; if (isLoading) { return ( -
+
); @@ -82,7 +91,7 @@ class SdocRevision extends React.Component { if (errorMessage) { return ( -
+
{gettext(errorMessage)}
); @@ -97,18 +106,22 @@ class SdocRevision extends React.Component { } render() { + const { isLoading, errorMessage } = this.state; + return (
-
-
+
+
{fileName}
-
- - {!isPublished && ( - +
+ {(!isLoading && !errorMessage) && ( + <> + + + )}
diff --git a/frontend/src/view-file-sdoc.js b/frontend/src/view-file-sdoc.js index f81c3a88ea..5e238973c0 100644 --- a/frontend/src/view-file-sdoc.js +++ b/frontend/src/view-file-sdoc.js @@ -11,6 +11,7 @@ const { username, name } = window.app.userInfo; const { repoID, repoName, parentDir, filePerm, docPath, docName, docUuid, seadocAccessToken, seadocServerUrl, assetsUrl, + isSdocRevision, isPublished, } = window.app.pageOptions; window.seafile = { @@ -32,6 +33,8 @@ window.seafile = { assetsUrl, isShowInternalLink: true, isStarIconShown: true, // for star/unstar + isSdocRevision, + isPublished, revisionURL: Utils.generateRevisionURL(siteRoot, repoID, docPath), };