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

fix: sodc history ui (#5478)

This commit is contained in:
杨国璇
2023-05-18 13:52:49 +08:00
committed by GitHub
parent ae52fbe261
commit 33c80ff085
5 changed files with 70 additions and 24 deletions

View File

@@ -11,7 +11,7 @@
"@gatsbyjs/reach-router": "1.3.9",
"@seafile/react-image-lightbox": "2.0.2",
"@seafile/resumablejs": "1.1.16",
"@seafile/sdoc-editor": "0.1.35",
"@seafile/sdoc-editor": "0.1.36",
"@seafile/seafile-calendar": "0.0.12",
"@seafile/seafile-editor": "0.3.132",
"@seafile/slate-react": "0.54.13",
@@ -5198,9 +5198,9 @@
"license": "MIT"
},
"node_modules/@seafile/sdoc-editor": {
"version": "0.1.35",
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.1.35.tgz",
"integrity": "sha512-5f2VJ/Qg2lCK8jnYV0X0ACnmCEWWWRjHan+32TLnTduK0VfFyz3k7wlqhUPM9WODXsRPqg9iGsSmNrTJjREskQ==",
"version": "0.1.36",
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.1.36.tgz",
"integrity": "sha512-DVGbfqmemRUlecUA4CVpyGSbx8zpm9edfFNBPe1iTsNGfx8WDZYnEd1Kc7ltuz5ja+xEs99FgvKDJsR7Bs62Tw==",
"dependencies": {
"@seafile/react-image-lightbox": "2.0.2",
"@seafile/slate": "0.91.8",
@@ -33279,9 +33279,9 @@
"version": "1.1.16"
},
"@seafile/sdoc-editor": {
"version": "0.1.35",
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.1.35.tgz",
"integrity": "sha512-5f2VJ/Qg2lCK8jnYV0X0ACnmCEWWWRjHan+32TLnTduK0VfFyz3k7wlqhUPM9WODXsRPqg9iGsSmNrTJjREskQ==",
"version": "0.1.36",
"resolved": "https://registry.npmjs.org/@seafile/sdoc-editor/-/sdoc-editor-0.1.36.tgz",
"integrity": "sha512-DVGbfqmemRUlecUA4CVpyGSbx8zpm9edfFNBPe1iTsNGfx8WDZYnEd1Kc7ltuz5ja+xEs99FgvKDJsR7Bs62Tw==",
"requires": {
"@seafile/react-image-lightbox": "2.0.2",
"@seafile/slate": "0.91.8",

View File

@@ -6,7 +6,7 @@
"@gatsbyjs/reach-router": "1.3.9",
"@seafile/react-image-lightbox": "2.0.2",
"@seafile/resumablejs": "1.1.16",
"@seafile/sdoc-editor": "0.1.35",
"@seafile/sdoc-editor": "0.1.36",
"@seafile/seafile-calendar": "0.0.12",
"@seafile/seafile-editor": "0.3.132",
"@seafile/slate-react": "0.54.13",

View File

@@ -6,7 +6,7 @@
.sdoc-file-history .sdoc-file-history-header {
height: 50px;
border-bottom: 1px solid #e5e5e5;
background-color: #f4f4f7;
background-color: #fff;
}
.sdoc-file-history .sdoc-file-history-header .sdoc-file-history-header-left {
@@ -38,22 +38,32 @@
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-last,
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-next {
padding: 0 8px;
height: 100%;
}
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-last .fas,
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-next .fas {
color: #000;
opacity: .5;
height: 100%;
}
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-last:hover,
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-next:hover {
cursor: pointer;
opacity: .75;
background-color: #F5F5F5;
}
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-last:hover .fas,
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-next:hover .fas {
opacity: .75;
}
.sdoc-file-history .sdoc-file-history-content {
flex: 1;
min-height: 0;
padding: 20px 40px;
background-color: #fafaf9;
background-color: #F5F5F5;
overflow-y: scroll;
}
@@ -85,7 +95,7 @@
padding: 10px 18px;
height: 50px;;
border-bottom: 1px solid #e5e5e5;
background-color: rgb(250, 250, 249);
background-color: #fff;
}
.sdoc-file-history .sdoc-file-history-panel .sdoc-file-history-select-range-title {
@@ -136,11 +146,31 @@
border-bottom: none;
}
.sdoc-file-history-versions .history-list-item:hover {
background-color: #ffe7d5;
.sdoc-file-history-versions .history-list-item:not(.item-active):hover {
background-color: #F5F5F5;
cursor: pointer;
}
.sdoc-file-history-versions .history-list-item .history-operation:hover {
cursor: pointer;
}
.sdoc-file-history-versions .history-list-item .history-operation a.fas {
color: #888;
}
.sdoc-file-history-versions .history-list-item .history-operation:hover a.fas {
color: #333;
}
.sdoc-file-history-versions .history-list-item.item-active {
background-color: #FFECD9 !important;
}
.sdoc-file-history-versions .history-list-item.item-active .history-info .time {
color: #ff8000;
}
.history-info .owner {
min-height: 22.5px;
}
@@ -149,11 +179,6 @@
min-width: 8rem;
}
.sdoc-file-history-versions .dropdown-menu a {
text-decoration: none;
color: #6e7687;
}
.history-content .main-panel {
flex: 1 1 auto;
}

View File

@@ -2,7 +2,7 @@ import React from 'react';
import ReactDom from 'react-dom';
import { UncontrolledTooltip } from 'reactstrap';
import classnames from 'classnames';
import DiffViewer from '@seafile/sdoc-editor/dist/pages/diff-viewer';
import { DiffViewer } from '@seafile/sdoc-editor';
import { seafileAPI } from '../../utils/seafile-api';
import { gettext, historyRepoID } from '../../utils/constants';
import Loading from '../../components/loading';
@@ -79,7 +79,26 @@ class SdocFileHistory extends React.Component {
this.setState({ currentVersionContent, lastVersionContent, isLoading: false, changes: [], currentDiffIndex: 0 });
}
onShowChanges = (isShowChanges) => {
onShowChanges = (isShowChanges, lastVersion) => {
if (isShowChanges && lastVersion) {
const { currentVersionContent } = this.state;
this.setState({ isLoading: true }, () => {
localStorage.setItem('seahub-sdoc-history-show-changes', isShowChanges + '');
seafileAPI.getFileRevision(historyRepoID, lastVersion.commitId, lastVersion.path).then(res => {
return seafileAPI.getFileContent(res.data);
}).then(res => {
const lastVersionContent = res.data;
this.setContent(currentVersionContent, lastVersionContent);
this.setState({ isShowChanges });
}).catch(error => {
const errorMessage = Utils.getErrorMsg(error, true);
toaster.danger(gettext(errorMessage));
this.setContent(currentVersionContent, '');
this.setState({ isShowChanges });
});
});
return;
}
this.setState({ isShowChanges }, () => {
localStorage.setItem('seahub-sdoc-history-show-changes', isShowChanges + '');
});
@@ -171,7 +190,6 @@ class SdocFileHistory extends React.Component {
</div>
) : (
<DiffViewer
ref={ref => this.diffViewerRef = ref}
currentContent={currentVersionContent}
lastContent={isShowChanges ? lastVersionContent : ''}
didMountCallback={this.setDiffCount}

View File

@@ -163,8 +163,11 @@ class SidePanel extends Component {
}
onShowChanges = () => {
const { isShowChanges } = this.props;
this.props.onShowChanges(!isShowChanges);
const { isShowChanges, currentVersion } = this.props;
const { historyVersions } = this.state;
const historyVersionIndex = historyVersions.findIndex(item => item.commitId === currentVersion.commitId);
const lastVersion = historyVersions[historyVersionIndex + 1];
this.props.onShowChanges(!isShowChanges, lastVersion);
}
render() {