1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-12 13:24:52 +00:00

optimize code

This commit is contained in:
杨顺强
2023-11-29 16:14:38 +08:00
parent 185af18660
commit e226fcda0b
3 changed files with 11 additions and 5 deletions

View File

@@ -207,7 +207,7 @@ class DirentGridItem extends React.Component {
gridClass += this.state.isGridSelected ? ' grid-selected-active' : ' '; gridClass += this.state.isGridSelected ? ' grid-selected-active' : ' ';
gridClass += this.state.isGridDropTipShow ? ' grid-drop-show' : ' '; gridClass += this.state.isGridDropTipShow ? ' grid-drop-show' : ' ';
let lockedInfo = gettext('locked by {name}'); let lockedInfo = dirent.is_freezed ? gettext('locked by {name}') : gettext('Freezed by {name}');
lockedInfo = lockedInfo.replace('{name}', dirent.lock_owner_name); lockedInfo = lockedInfo.replace('{name}', dirent.lock_owner_name);
const lockedImageUrl = `${mediaUrl}img/file-${dirent.is_freezed ? 'freezed' : 'locked'}-32.png`; const lockedImageUrl = `${mediaUrl}img/file-${dirent.is_freezed ? 'freezed' : 'locked'}-32.png`;

View File

@@ -376,6 +376,7 @@ class DirentListItem extends React.Component {
let repoID = this.props.repoID; let repoID = this.props.repoID;
let filePath = this.getDirentPath(this.props.dirent); let filePath = this.getDirentPath(this.props.dirent);
seafileAPI.lockfile(repoID, filePath, -1).then(() => { seafileAPI.lockfile(repoID, filePath, -1).then(() => {
this.props.updateDirent(this.props.dirent, 'is_freezed', true);
this.props.updateDirent(this.props.dirent, 'is_locked', true); this.props.updateDirent(this.props.dirent, 'is_locked', true);
this.props.updateDirent(this.props.dirent, 'locked_by_me', true); this.props.updateDirent(this.props.dirent, 'locked_by_me', true);
let lockName = username.split('@'); let lockName = username.split('@');
@@ -711,7 +712,9 @@ class DirentListItem extends React.Component {
trClass += (activeDirent && activeDirent.name === dirent.name) ? 'tr-active' : ''; trClass += (activeDirent && activeDirent.name === dirent.name) ? 'tr-active' : '';
trClass += dirent.isSelected? 'tr-active' : ''; trClass += dirent.isSelected? 'tr-active' : '';
let lockedInfo = gettext('locked by {name}').replace('{name}', dirent.lock_owner_name); let lockedInfo = dirent.is_freezed ? gettext('locked by {name}') : gettext('Freezed by {name}');
lockedInfo = lockedInfo.replace('{name}', dirent.lock_owner_name);
const isDesktop = Utils.isDesktop(); const isDesktop = Utils.isDesktop();
const { canDrag } = this.state; const { canDrag } = this.state;
const lockedImageUrl = `${mediaUrl}img/file-${dirent.is_freezed ? 'freezed' : 'locked'}-32.png`; const lockedImageUrl = `${mediaUrl}img/file-${dirent.is_freezed ? 'freezed' : 'locked'}-32.png`;

View File

@@ -592,15 +592,18 @@ export const Utils = {
list.push(UNLOCK); list.push(UNLOCK);
} }
} else { } else {
if (dirent.name.endsWith('.sdoc')) { if (!dirent.name.endsWith('.sdoc')) {
list.push(FREEZE_DOCUMENT);
} else {
list.push(LOCK); list.push(LOCK);
} }
} }
} }
list.push('Divider'); list.push('Divider');
if (isPro && !dirent.is_locked && dirent.name.endsWith('.sdoc')) {
list.push(FREEZE_DOCUMENT);
}
} }
if ((permission == 'rw' || permission == 'cloud-edit') && enableSeadoc) { if ((permission == 'rw' || permission == 'cloud-edit') && enableSeadoc) {