diff --git a/frontend/src/pages/sdoc/sdoc-file-history/history-version.js b/frontend/src/pages/sdoc/sdoc-file-history/history-version.js index abec95db3b..19082eab69 100644 --- a/frontend/src/pages/sdoc/sdoc-file-history/history-version.js +++ b/frontend/src/pages/sdoc/sdoc-file-history/history-version.js @@ -1,11 +1,12 @@ import moment from 'moment'; import React from 'react'; import PropTypes from 'prop-types'; -import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem} from 'reactstrap'; +import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Modal, ModalBody } from 'reactstrap'; import classnames from 'classnames'; import { gettext, filePath } from '../../../utils/constants'; import URLDecorator from '../../../utils/url-decorator'; import Rename from '../../../components/rename'; +import { isMobile } from '../../../utils/utils'; import '../../../css/history-record-item.css'; @@ -20,6 +21,7 @@ class HistoryVersion extends React.Component { isMenuShow: false, isRenameShow: false, }; + this.isMobile = isMobile; } onMouseEnter = () => { @@ -61,7 +63,8 @@ class HistoryVersion extends React.Component { }; toggleRename = () => { - this.setState({isRenameShow: !this.state.isRenameShow}); + this.isMobile && this.setState({ isMenuShow: false }); + this.setState({ isRenameShow: !this.state.isRenameShow }); }; onRenameConfirm = (newName) => { @@ -108,8 +111,8 @@ class HistoryVersion extends React.Component { {path[2] > 0 && (
)}
{this.state.isRenameShow ? - - :
{name}
+ + :
{name}
}
{moment(ctime).format('YYYY-MM-DD HH:mm')}
@@ -118,22 +121,56 @@ class HistoryVersion extends React.Component {
- - - - {/* {(this.props.index !== 0) && {gettext('Restore')}} */} - {gettext('Download')} - {(path[0] !== 0 && path[1] !== 0 && path[2] !== 0) && {gettext('Copy')}} - {gettext('Rename')} - - + {this.isMobile + ? ( + <> + + + +
+ + {gettext('Download')} +
+ {(path[0] !== 0 && path[1] !== 0 && path[2] !== 0) && ( +
+ + {gettext('Copy')} +
+ )} +
+ + {gettext('Rename')} +
+ + + + ) + : ( + + + {/* {(this.props.index !== 0) && {gettext('Restore')}} */} + {gettext('Download')} + {(path[0] !== 0 && path[1] !== 0 && path[2] !== 0) && {gettext('Copy')}} + {gettext('Rename')} + + )}
); diff --git a/frontend/src/pages/sdoc/sdoc-file-history/index.css b/frontend/src/pages/sdoc/sdoc-file-history/index.css index 11ff272af9..5b35263796 100644 --- a/frontend/src/pages/sdoc/sdoc-file-history/index.css +++ b/frontend/src/pages/sdoc/sdoc-file-history/index.css @@ -26,6 +26,7 @@ .sdoc-file-history .sdoc-file-history-header .sdoc-file-history-header-right { height: 100%; min-width: 100px; + align-items: center; } .sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-container { @@ -40,6 +41,11 @@ width: 1px; } +.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch { + display: flex; + align-items: center; +} + .sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-last, .sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-next, .sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch { @@ -47,6 +53,11 @@ height: 100%; } +.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch { + padding: 0; + margin-left: 8px; +} + .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; @@ -54,20 +65,28 @@ } .sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-last:hover, -.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-next:hover, -.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch: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, -.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch:hover { +.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-next:hover .fas { opacity: .75; } +.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch .sf3-font-history:hover { + cursor: pointer; + color: #000; +} + +.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch .sf3-font-history { + font-size: 18px; + color: #666; +} + + .sdoc-file-history .sdoc-file-history-content { height: 100%; width: 100%; @@ -209,6 +228,22 @@ color: #ff8000; } +/* mobile options modal */ +.sdoc-mobile-history-options-modal { + margin: 0; + transition: none; + transform: translateY(calc(100vh - 100%)) !important; +} + +.sdoc-mobile-history-options-modal .sdoc-operation-mobile-modal-body .option-item { + padding: 10px 5px; +} + +.sdoc-mobile-history-options-modal .sdoc-operation-mobile-modal-body .option-item a, +.sdoc-mobile-history-options-modal .sdoc-operation-mobile-modal-body .option-item a:hover { + color: #212529; +} + .sdoc-file-history-versions .history-list-item .history-operation:hover { cursor: pointer; } diff --git a/frontend/src/pages/sdoc/sdoc-file-history/index.js b/frontend/src/pages/sdoc/sdoc-file-history/index.js index 0fc1d640b4..cf3059bc1d 100644 --- a/frontend/src/pages/sdoc/sdoc-file-history/index.js +++ b/frontend/src/pages/sdoc/sdoc-file-history/index.js @@ -3,6 +3,7 @@ import ReactDom from 'react-dom'; import { UncontrolledTooltip } from 'reactstrap'; import classnames from 'classnames'; import { DiffViewer } from '@seafile/sdoc-editor'; +import moment from 'moment'; import { seafileAPI } from '../../../utils/seafile-api'; import { PER_PAGE, gettext, historyRepoID } from '../../../utils/constants'; import Loading from '../../../components/loading'; @@ -10,11 +11,10 @@ import GoBack from '../../../components/common/go-back'; import SidePanel from './side-panel'; import { Utils, isMobile } from '../../../utils/utils'; import toaster from '../../../components/toast'; +import { getCurrentAndLastVersion } from './helper'; import '../../../css/layout.css'; import './index.css'; -import moment from 'moment'; -import { getCurrentAndLastVersion, getLastVersion } from './helper'; const { serviceURL, avatarURL, siteRoot } = window.app.config; const { username, name } = window.app.pageOptions; @@ -124,7 +124,6 @@ class SdocFileHistory extends React.Component { onSelectHistoryVersion = (currentVersion, lastVersion) => { this.setState({ isLoading: true, currentVersion }); - console.log('currentVersion', currentVersion); seafileAPI.getFileRevision(historyRepoID, currentVersion.commit_id, currentVersion.path).then(res => { return seafileAPI.getFileContent(res.data); }).then(res => { @@ -241,7 +240,7 @@ class SdocFileHistory extends React.Component { this.setState({ showSidePanel: !this.state.showSidePanel }); }; - renderChangesTip = () => { + renderChangesTip = ({onChangeSidePanelDisplay}) => { const { isShowChanges, changes, currentDiffIndex, isLoading } = this.state; if (isLoading) return null; if (!isShowChanges) return null; @@ -252,6 +251,9 @@ class SdocFileHistory extends React.Component {
{gettext('No changes')}
+
+ +
); } @@ -357,7 +359,7 @@ class SdocFileHistory extends React.Component {
{fileName}
- {this.renderChangesTip()} + {this.renderChangesTip({onChangeSidePanelDisplay: this.changeSidePanelStatus})}
this.historyContentRef = ref}> {isLoading ? ( diff --git a/frontend/src/pages/sdoc/sdoc-file-history/side-panel.js b/frontend/src/pages/sdoc/sdoc-file-history/side-panel.js index 84aa37d9fc..31a70d1085 100644 --- a/frontend/src/pages/sdoc/sdoc-file-history/side-panel.js +++ b/frontend/src/pages/sdoc/sdoc-file-history/side-panel.js @@ -31,33 +31,6 @@ class SidePanel extends Component { this.currentPage = 1; } - // listSdocDailyHistoryDetail - - componentDidMount() { - // this.firstLoadSdocHistory(); - } - - // firstLoadSdocHistory() { - // this.currentPage = 1; - // seafileAPI.listSdocHistory(docUuid, this.currentPage, PER_PAGE).then(res => { - // const result = res.data; - // const resultCount = result.histories.length; - // const historyGroups = this.formatHistories(result.histories); - // this.setState({ - // historyGroups: this.formatHistories(result.histories), - // hasMore: resultCount >= PER_PAGE, - // isLoading: false, - // }, () => { - // if (historyGroups.length > 0) { - // this.onSelectHistoryVersion([0, 0, 0]); - // } - // }); - // }).catch((error) => { - // this.setState({isLoading: false}); - // throw Error('there has an error in server'); - // }); - // } - formatHistories(histories) { const oldHistoryGroups = this.state.historyGroups; if (!Array.isArray(histories) || histories.length === 0) return oldHistoryGroups; @@ -286,7 +259,7 @@ class SidePanel extends Component { {gettext('History Versions')}
- +