Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat history page mobile fit #6075

Merged
merged 8 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@gatsbyjs/reach-router": "1.3.9",
"@seafile/react-image-lightbox": "2.0.2",
"@seafile/resumablejs": "1.1.16",
"@seafile/sdoc-editor": "0.5.59",
"@seafile/sdoc-editor": "0.5.60",
"@seafile/seafile-calendar": "0.0.12",
"@seafile/seafile-editor": "1.0.82",
"@uiw/codemirror-extensions-langs": "^4.19.4",
Expand Down
30 changes: 30 additions & 0 deletions frontend/src/pages/sdoc/sdoc-file-history/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const getLastVersion = (path, isShowChanges, historyGroups) => {
const [monthIndex, dayIndex, dailyIndex] = path;
const monthHistoryGroup = historyGroups[monthIndex];
const dayHistoryGroup = monthHistoryGroup.children[dayIndex];
let lastVersion = '';
if (isShowChanges) {
if (dayHistoryGroup.showDaily) {
lastVersion = dayHistoryGroup.children[dailyIndex + 1];
}
if (!lastVersion) {
lastVersion = monthHistoryGroup.children[dayIndex + 1]?.children[0];
}
if (!lastVersion) {
lastVersion = historyGroups[monthIndex + 1]?.children[0]?.children[0];
}
if (monthIndex === 0 && !lastVersion) {
lastVersion = 'init';
}
}
return lastVersion;
};

export const getCurrentAndLastVersion = (path, historyGroups, isShowChanges) => {
const [monthIndex, dayIndex, dailyIndex] = path;
const monthHistoryGroup = historyGroups[monthIndex];
const dayHistoryGroup = monthHistoryGroup.children[dayIndex];
const currentVersion = dayHistoryGroup.children[dailyIndex];
const lastVersion = getLastVersion(path, isShowChanges, historyGroups);
return [currentVersion, lastVersion];
};
74 changes: 56 additions & 18 deletions frontend/src/pages/sdoc/sdoc-file-history/history-version.js
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -20,6 +21,7 @@ class HistoryVersion extends React.Component {
isMenuShow: false,
isRenameShow: false,
};
this.isMobile = isMobile;
}

onMouseEnter = () => {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -118,22 +121,57 @@ class HistoryVersion extends React.Component {
</div>
</div>
<div className="history-operation">
<Dropdown isOpen={this.state.isMenuShow} toggle={this.onToggleClick}>
<DropdownToggle
tag='a'
className={`fas fa-ellipsis-v ${(this.state.isShowOperationIcon || isHighlightItem) ? '' : 'invisible'}`}
data-toggle="dropdown"
aria-expanded={this.state.isMenuShow}
title={gettext('More operations')}
aria-label={gettext('More operations')}
/>
<DropdownMenu>
{/* {(this.props.index !== 0) && <DropdownItem onClick={this.onItemRestore}>{gettext('Restore')}</DropdownItem>} */}
<DropdownItem tag='a' href={url} onClick={this.onItemDownLoad}>{gettext('Download')}</DropdownItem>
{(path[0] !== 0 && path[1] !== 0 && path[2] !== 0) && <DropdownItem onClick={this.onItemCopy}>{gettext('Copy')}</DropdownItem>}
<DropdownItem onClick={this.toggleRename}>{gettext('Rename')}</DropdownItem>
</DropdownMenu>
</Dropdown>
{this.isMobile
? (
<>
<a
className={`fas fa-ellipsis-v ${(this.state.isShowOperationIcon || isHighlightItem) ? '' : 'invisible'}`}
title={gettext('More operations')}
aria-label={gettext('More operations')}
aria-expanded={this.state.isMenuShow}
onClick={this.onToggleClick}
/>
<Modal
className='sdoc-mobile-history-options-modal'
isOpen={this.state.isMenuShow}
toggle={this.onToggleClick}
>
<ModalBody className='sdoc-operation-mobile-modal-body'>
<div className='option-item'>
<i className='mr-3 sf3-font sf3-font-download'></i>
<a href={url} onClick={this.onItemDownLoad}>{gettext('Download')}</a>
</div>
{(path[0] !== 0 && path[1] !== 0 && path[2] !== 0) && (
<div className='option-item'>
<i className='mr-3 sf3-font sf3-font-copy'></i>
<span href={url} onClick={this.onItemCopy}>{gettext('Copy')}</span>
</div>
)}
<div className='option-item' onClick={this.toggleRename}>
<i className='mr-3 sf3-font sf3-font-rename'></i>
<span>{gettext('Rename')}</span>
</div>
</ModalBody>
</Modal>
</>
)
: (<Dropdown isOpen={this.state.isMenuShow} toggle={this.onToggleClick}>
<DropdownToggle
tag='a'
className={`fas fa-ellipsis-v ${(this.state.isShowOperationIcon || isHighlightItem) ? '' : 'invisible'}`}
data-toggle="dropdown"
aria-expanded={this.state.isMenuShow}
title={gettext('More operations')}
aria-label={gettext('More operations')}
/>
<DropdownMenu>
{/* {(this.props.index !== 0) && <DropdownItem onClick={this.onItemRestore}>{gettext('Restore')}</DropdownItem>} */}
<DropdownItem tag='a' href={url} onClick={this.onItemDownLoad}>{gettext('Download')}</DropdownItem>
{(path[0] !== 0 && path[1] !== 0 && path[2] !== 0) && <DropdownItem onClick={this.onItemCopy}>{gettext('Copy')}</DropdownItem>}
<DropdownItem onClick={this.toggleRename}>{gettext('Rename')}</DropdownItem>
</DropdownMenu>
</Dropdown>
)}
</div>
</li>
);
Expand Down
87 changes: 76 additions & 11 deletions frontend/src/pages/sdoc/sdoc-file-history/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
.sdoc-file-history .sdoc-content-wrapper {
flex: 1;
/* Header is 50px */
height: calc(100vh - 50px);
}

.sdoc-file-history .sdoc-file-history-container {
flex: 1;
overflow-x: hidden;
}

.sdoc-file-history .sdoc-file-history-header {
Expand All @@ -21,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 {
Expand All @@ -35,12 +41,22 @@
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 {
padding: 0 8px;
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-next,
.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch {
padding: 0 8px;
height: 100%;
}

.sdoc-file-history .sdoc-file-history-header .sdoc-file-changes-switch {
padding: 0;
}

.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;
Expand All @@ -59,6 +75,17 @@
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%;
Expand All @@ -78,11 +105,24 @@
padding: 20px 40px;
}

.sdoc-file-history.mobile .sdoc-file-history-container .sdoc-file-history-content .sdoc-editor-content {
padding: 0;
min-width: auto;
}

.sdoc-file-history .sdoc-file-history-content .sdoc-scroll-container {
position: relative !important;
width: 100%;
}

.sdoc-file-history .sdoc-file-history-content .sdoc-editor-container {
flex-direction: row;
}

.sdoc-editor-container.mobile .sdoc-editor-content.readonly .sdoc-article-container {
width: 100%;
}

.sdoc-file-history .sdoc-file-history-content .sdoc-article-container {
width: 100%;
padding-top: 0;
Expand All @@ -98,11 +138,15 @@
.sdoc-file-history .sdoc-file-history-panel {
width: 260px;
border-left: 1px solid #e5e5e5;
height: calc(100vh - 50px);
}

.sdoc-file-history .sdoc-file-history-panel .sdoc-file-history-select-range {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 18px;
height: 50px;;
height: 50px;
border-bottom: 1px solid #e5e5e5;
background-color: #fff;
}
Expand All @@ -115,9 +159,14 @@
line-height: 29px;
}

.sdoc-file-history .sdoc-file-history-panel .sdoc-file-history-select-range .sdoc-side-panel-close {
opacity: 0.7;
cursor: pointer;
}

.sdoc-file-history .sdoc-file-history-panel .sdoc-file-history-diff-switch {
padding: 0 18px;
height: 50px;;
height: 50px;
border-top: 1px solid #e5e5e5;
}

Expand All @@ -138,7 +187,7 @@

/* history versions */
.sdoc-file-history-versions {
flex: 1;
flex: 1;
flex-direction: column;
min-height: 0;
overflow: auto;
Expand Down Expand Up @@ -179,27 +228,43 @@
white-space: nowrap;
}

.sdoc-file-history-versions .history-list-item.item-active .history-info .name{
.sdoc-file-history-versions .history-list-item.item-active .history-info .name {
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;
}

.sdoc-file-history-versions .history-list-item .history-operation a.fas {
.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 {
.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 {
.sdoc-file-history-versions .history-list-item.item-active .history-info .time {
color: #ff8000;
}

Expand Down Expand Up @@ -230,7 +295,7 @@
line-height: 50px;
font-size: 1rem;
padding: 0 10px;
background-color: rgb(250,250,249);
background-color: rgb(250, 250, 249);
font-weight: bolder;
}

Expand Down
Loading
Loading