mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-09 19:07:40 +00:00
Update sdoc struct (#6920)
* optimize code * optimize code * update sdoc-editor version
This commit is contained in:
parent
b723b6436e
commit
058b95362e
8
frontend/package-lock.json
generated
8
frontend/package-lock.json
generated
@ -16,7 +16,7 @@
|
|||||||
"@gatsbyjs/reach-router": "1.3.9",
|
"@gatsbyjs/reach-router": "1.3.9",
|
||||||
"@seafile/react-image-lightbox": "3.0.1",
|
"@seafile/react-image-lightbox": "3.0.1",
|
||||||
"@seafile/resumablejs": "1.1.16",
|
"@seafile/resumablejs": "1.1.16",
|
||||||
"@seafile/sdoc-editor": "1.0.102",
|
"@seafile/sdoc-editor": "1.0.105",
|
||||||
"@seafile/seafile-calendar": "0.0.28",
|
"@seafile/seafile-calendar": "0.0.28",
|
||||||
"@seafile/seafile-editor": "^1.0.121",
|
"@seafile/seafile-editor": "^1.0.121",
|
||||||
"@seafile/sf-metadata-ui-component": "^0.0.43",
|
"@seafile/sf-metadata-ui-component": "^0.0.43",
|
||||||
@ -4784,9 +4784,9 @@
|
|||||||
"integrity": "sha512-8rBbmAEuuwOAGHYGCtEzpx+bxAcGS+V30otMmhRe7bPAdh4E57RWgCa8x7pkzHGFlY1t5d+ILz1gojvPVMYQig=="
|
"integrity": "sha512-8rBbmAEuuwOAGHYGCtEzpx+bxAcGS+V30otMmhRe7bPAdh4E57RWgCa8x7pkzHGFlY1t5d+ILz1gojvPVMYQig=="
|
||||||
},
|
},
|
||||||
"node_modules/@seafile/sdoc-editor": {
|
"node_modules/@seafile/sdoc-editor": {
|
||||||
"version": "1.0.102",
|
"version": "1.0.105",
|
||||||
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-1.0.102.tgz",
|
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-1.0.105.tgz",
|
||||||
"integrity": "sha512-FMuv26UWablfbsFr39LX4ApIBgJSU9q0x4p6CzW2tzDVIio+M1xvMUzS6NMiBrjhWjv9FEArNoNDvyEndcaG5w==",
|
"integrity": "sha512-7njoR8JDGXpf8WbOiMCOpqDlYAt7UT3QVPit+9/9OnC6wok5iTdY7ZpaRkvGD1DkkfCk8lSTH5tLdxImaRrN7Q==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@seafile/print-js": "1.6.6",
|
"@seafile/print-js": "1.6.6",
|
||||||
"@seafile/react-image-lightbox": "2.0.5",
|
"@seafile/react-image-lightbox": "2.0.5",
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
"@gatsbyjs/reach-router": "1.3.9",
|
"@gatsbyjs/reach-router": "1.3.9",
|
||||||
"@seafile/react-image-lightbox": "3.0.1",
|
"@seafile/react-image-lightbox": "3.0.1",
|
||||||
"@seafile/resumablejs": "1.1.16",
|
"@seafile/resumablejs": "1.1.16",
|
||||||
"@seafile/sdoc-editor": "1.0.102",
|
"@seafile/sdoc-editor": "1.0.105",
|
||||||
"@seafile/seafile-calendar": "0.0.28",
|
"@seafile/seafile-calendar": "0.0.28",
|
||||||
"@seafile/seafile-editor": "^1.0.121",
|
"@seafile/seafile-editor": "^1.0.121",
|
||||||
"@seafile/sf-metadata-ui-component": "^0.0.43",
|
"@seafile/sf-metadata-ui-component": "^0.0.43",
|
||||||
|
@ -28,3 +28,8 @@ export const getCurrentAndLastVersion = (path, historyGroups, isShowChanges) =>
|
|||||||
const lastVersion = getLastVersion(path, isShowChanges, historyGroups);
|
const lastVersion = getLastVersion(path, isShowChanges, historyGroups);
|
||||||
return [currentVersion, lastVersion];
|
return [currentVersion, lastVersion];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const formatHistoryContent = (content) => {
|
||||||
|
// patch new sdoc data struct
|
||||||
|
return { ...content, elements: content.elements || content.children };
|
||||||
|
};
|
||||||
|
@ -14,7 +14,7 @@ import GoBack from '../../../components/common/go-back';
|
|||||||
import SidePanel from './side-panel';
|
import SidePanel from './side-panel';
|
||||||
import { Utils, isMobile } from '../../../utils/utils';
|
import { Utils, isMobile } from '../../../utils/utils';
|
||||||
import toaster from '../../../components/toast';
|
import toaster from '../../../components/toast';
|
||||||
import { getCurrentAndLastVersion } from './helper';
|
import { formatHistoryContent, getCurrentAndLastVersion } from './helper';
|
||||||
|
|
||||||
import '../../../css/layout.css';
|
import '../../../css/layout.css';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@ -70,7 +70,7 @@ class SdocFileHistory extends React.Component {
|
|||||||
if (firstChildren) {
|
if (firstChildren) {
|
||||||
return {
|
return {
|
||||||
version: -1,
|
version: -1,
|
||||||
children: [
|
elements: [
|
||||||
{
|
{
|
||||||
id: firstChildren.id,
|
id: firstChildren.id,
|
||||||
type: 'title',
|
type: 'title',
|
||||||
@ -91,7 +91,7 @@ class SdocFileHistory extends React.Component {
|
|||||||
const name = path ? path.split('/')?.pop()?.slice(0, -5) : '';
|
const name = path ? path.split('/')?.pop()?.slice(0, -5) : '';
|
||||||
return {
|
return {
|
||||||
version: -1,
|
version: -1,
|
||||||
children: [
|
elements: [
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
type: 'title',
|
type: 'title',
|
||||||
@ -112,7 +112,7 @@ class SdocFileHistory extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (lastVersion === 'init') {
|
if (lastVersion === 'init') {
|
||||||
const lastVersionContent = currentVersionContent ? this.getInitContent(currentVersionContent.children[0]) : this.getInitContentByPath(currentVersion.path);
|
const lastVersionContent = currentVersionContent ? this.getInitContent(currentVersionContent?.elements[0]) : this.getInitContentByPath(currentVersion.path);
|
||||||
const validCurrentVersionContent = currentVersionContent || this.getInitContentByPath(currentVersion.path);
|
const validCurrentVersionContent = currentVersionContent || this.getInitContentByPath(currentVersion.path);
|
||||||
this.setContent(validCurrentVersionContent, lastVersionContent);
|
this.setContent(validCurrentVersionContent, lastVersionContent);
|
||||||
return;
|
return;
|
||||||
@ -120,8 +120,8 @@ class SdocFileHistory extends React.Component {
|
|||||||
seafileAPI.getFileRevision(historyRepoID, lastVersion.commit_id, lastVersion.path).then(res => {
|
seafileAPI.getFileRevision(historyRepoID, lastVersion.commit_id, lastVersion.path).then(res => {
|
||||||
return res.data ? seafileAPI.getFileContent(res.data) : { data: '' };
|
return res.data ? seafileAPI.getFileContent(res.data) : { data: '' };
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
const lastVersionContent = res.data;
|
const lastVersionContent = formatHistoryContent(res.data);
|
||||||
const firstChildren = currentVersionContent.children[0];
|
const firstChildren = currentVersionContent?.elements[0];
|
||||||
const validLastVersionContent = lastVersion && !lastVersionContent ? this.getInitContent(firstChildren) : lastVersionContent;
|
const validLastVersionContent = lastVersion && !lastVersionContent ? this.getInitContent(firstChildren) : lastVersionContent;
|
||||||
this.setContent(currentVersionContent, validLastVersionContent);
|
this.setContent(currentVersionContent, validLastVersionContent);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@ -139,8 +139,9 @@ class SdocFileHistory extends React.Component {
|
|||||||
seafileAPI.getFileRevision(historyRepoID, currentVersion.commit_id, currentVersion.path).then(res => {
|
seafileAPI.getFileRevision(historyRepoID, currentVersion.commit_id, currentVersion.path).then(res => {
|
||||||
return seafileAPI.getFileContent(res.data);
|
return seafileAPI.getFileContent(res.data);
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
const currentVersionContent = res.data;
|
const currentVersionContent = formatHistoryContent(res.data);
|
||||||
this.updateLastVersionContent(currentVersionContent, currentVersion, lastVersion);
|
const validCurrentVersionContent = currentVersionContent.elements ? currentVersionContent : this.getInitContentByPath(currentVersion.path);
|
||||||
|
this.updateLastVersionContent(validCurrentVersionContent, currentVersion, lastVersion);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
const errorMessage = Utils.getErrorMsg(error, true);
|
const errorMessage = Utils.getErrorMsg(error, true);
|
||||||
toaster.danger(gettext(errorMessage));
|
toaster.danger(gettext(errorMessage));
|
||||||
|
Loading…
Reference in New Issue
Block a user