Skip to content

Commit

Permalink
change online-read-write permission UI (#5560)
Browse files Browse the repository at this point in the history
* change online-read-write permission UI

* update

* update
  • Loading branch information
imwhatiam authored Aug 1, 2023
1 parent 18c7b34 commit 4fa6423
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/dirent-list-view/dirent-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class DirentListItem extends React.Component {
{showShareBtn && (
<a href="#" className="op-icon sf2-icon-share" title={gettext('Share')} role="button" aria-label={gettext('Share')} onClick={this.onItemShare}></a>
)}
{(dirent.permission === 'rw' || (isCustomPermission && canDelete)) && (
{(dirent.permission === 'rw' || dirent.permission === 'cloud-edit' || (isCustomPermission && canDelete)) && (
<a href="#" className="op-icon sf2-icon-delete" title={gettext('Delete')} role="button" aria-label={gettext('Delete')} onClick={this.onItemDelete}></a>
)}
<ItemDropdownMenu
Expand All @@ -645,7 +645,7 @@ class DirentListItem extends React.Component {
{showShareBtn && (
<a href="#" className="op-icon sf2-icon-share" title={gettext('Share')} role="button" aria-label={gettext('Share')} onClick={this.onItemShare}></a>
)}
{(dirent.permission === 'rw' || (isCustomPermission && canDelete)) && (
{(dirent.permission === 'rw' || dirent.permission === 'cloud-edit' || (isCustomPermission && canDelete)) && (
<a href="#" className="op-icon sf2-icon-delete" title={gettext('Delete')} role="button" aria-label={gettext('Delete')} onClick={this.onItemDelete}></a>
)}
<ItemDropdownMenu
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/toolbar/dir-operation-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class DirOperationToolbar extends React.Component {

return (
<Fragment>
{(userPerm === 'rw' || userPerm === 'admin' || isCustomPermission) && (
{(userPerm === 'rw' || userPerm === 'admin' || userPerm === 'cloud-edit' || isCustomPermission) && (
<div className="dir-operation">
{content}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ class MultipleDirOperationToolbar extends React.Component {
{canDownload && <Button className="secondary group-op-item action-icon sf2-icon-download" title={gettext('Download')} aria-label={gettext('Download')} onClick={this.onItemsDownload}></Button>}
</Fragment>
)}
{userPerm === 'cloud-edit' && (
<Fragment>
{canModify && <Button className="secondary group-op-item action-icon sf2-icon-move" title={gettext('Move')} aria-label={gettext('Move')} onClick={this.onMoveToggle}></Button>}
{canCopy && <Button className="secondary group-op-item action-icon sf2-icon-copy" title={gettext('Copy')} aria-label={gettext('Copy')} onClick={this.onCopyToggle}></Button>}
{canDelete && <Button className="secondary group-op-item action-icon sf2-icon-delete" title={gettext('Delete')} aria-label={gettext('Delete')} onClick={this.onItemsDelete}></Button>}
</Fragment>
)}
{userPerm === 'r' && (
<Fragment>
<Button className="secondary group-op-item action-icon sf2-icon-copy" title={gettext('Copy')} aria-label={gettext('Copy')} onClick={this.onCopyToggle}></Button>
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export const Utils = {
list.push(SHARE);
}

if (permission == 'rw') {
if (permission == 'rw' || permission == 'cloud-edit') {
list.push(DELETE, 'Divider');
}

Expand All @@ -489,15 +489,15 @@ export const Utils = {
}
}

if (permission == 'rw') {
if (permission == 'rw' || permission == 'cloud-edit') {
list.push(RENAME, MOVE);
}

if (isCustomPermission && customPermission.permission.modify) {
list.push(RENAME, MOVE);
}

if (permission == 'rw') {
if (permission == 'rw' || permission == 'cloud-edit') {
list.push(COPY);
}

Expand Down Expand Up @@ -544,7 +544,7 @@ export const Utils = {
list.push(SHARE);
}

if (permission == 'rw') {
if (permission == 'rw' || permission == 'cloud-edit') {
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
list.push(DELETE);
}
Expand All @@ -559,7 +559,7 @@ export const Utils = {
}
}

if (permission == 'rw') {
if (permission == 'rw' || permission == 'cloud-edit') {
if (!dirent.is_locked || (dirent.is_locked && dirent.locked_by_me)) {
list.push(RENAME, MOVE);
}
Expand All @@ -571,7 +571,7 @@ export const Utils = {
}
}

if (permission == 'rw') {
if (permission == 'rw' || permission == 'cloud-edit') {
list.push(COPY);
}

Expand Down
2 changes: 1 addition & 1 deletion seahub/api2/endpoints/repos_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ def delete(self, request):
folder_permission_dict = get_sub_folder_permission_by_dir(request, repo_id, parent_dir)
for dirent in dirents:
if dirent in list(folder_permission_dict.keys()) and \
folder_permission_dict[dirent] != 'rw':
folder_permission_dict[dirent] not in ('rw', 'cloud-edit'):
error_msg = _("Can't delete folder %s, please check its permission.") % dirent
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

Expand Down
6 changes: 3 additions & 3 deletions seahub/utils/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def parse_repo_perm(perm):
RP.can_download = True if perm in [
PERMISSION_READ, PERMISSION_READ_WRITE, PERMISSION_ADMIN] else False
RP.can_upload = True if perm in [
PERMISSION_READ_WRITE, PERMISSION_ADMIN] else False
PERMISSION_READ_WRITE, PERMISSION_ADMIN, PERMISSION_PREVIEW_EDIT] else False
RP.can_edit_on_web = True if perm in [
PERMISSION_READ_WRITE, PERMISSION_ADMIN, PERMISSION_PREVIEW_EDIT
] else False
RP.can_copy = True if perm in [
PERMISSION_READ, PERMISSION_READ_WRITE, PERMISSION_ADMIN,
PERMISSION_READ, PERMISSION_READ_WRITE, PERMISSION_ADMIN, PERMISSION_PREVIEW_EDIT
] else False
RP.can_delete = True if perm in [
PERMISSION_READ_WRITE, PERMISSION_ADMIN,
PERMISSION_READ_WRITE, PERMISSION_ADMIN, PERMISSION_PREVIEW_EDIT
] else False
RP.can_preview = True if perm in [
PERMISSION_READ, PERMISSION_READ_WRITE, PERMISSION_ADMIN,
Expand Down
2 changes: 1 addition & 1 deletion tests/seahub/utils/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_parse_repo_perm_upload(self):
assert parse_repo_perm(PERMISSION_READ_WRITE).can_upload is True
assert parse_repo_perm(PERMISSION_READ).can_upload is False
assert parse_repo_perm(PERMISSION_PREVIEW).can_upload is False
assert parse_repo_perm(PERMISSION_PREVIEW_EDIT).can_upload is False
assert parse_repo_perm(PERMISSION_PREVIEW_EDIT).can_upload is True

def test_valid_prop(self):
assert parse_repo_perm(PERMISSION_READ).can_download is True
Expand Down

0 comments on commit 4fa6423

Please sign in to comment.