Merge pull request #1061 from ONLYOFFICE/bugfix/access-rights

Bugfix/access rights
This commit is contained in:
Alexey Safronov 2022-11-24 22:15:08 +03:00 committed by GitHub
commit 14aae505bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 811 additions and 477 deletions

View File

@ -173,14 +173,14 @@ services:
- SERVICE_CLEAR_EVENTS=${SERVICE_CLEAR_EVENTS}
# - SERVICE_MIGRATION=${SERVICE_MIGRATION}
# - SERVICE_WEBHOOKS_SERVICE=${SERVICE_WEBHOOKS_SERVICE}
# - SERVICE_NOTIFY=${SERVICE_NOTIFY}
- SERVICE_NOTIFY=${SERVICE_NOTIFY}
- SERVICE_PEOPLE_SERVER=${SERVICE_PEOPLE_SERVER}
- SERVICE_SOCKET=${SERVICE_SOCKET}
- SERVICE_STUDIO_NOTIFY=${SERVICE_STUDIO_NOTIFY}
# - SERVICE_TELEGRAM_SERVICE=${SERVICE_TELEGRAM_SERVICE}
# - SERVICE_URLSHORTENER=${SERVICE_URLSHORTENER}
- SERVICE_API=${SERVICE_API}
# - SERVICE_API_SYSTEM=${SERVICE_API_SYSTEM}
- SERVICE_API_SYSTEM=${SERVICE_API_SYSTEM}
- SERVICE_STUDIO=${SERVICE_STUDIO}
- SERVICE_SSOAUTH=${SERVICE_SSOAUTH}
- SERVICE_DOCEDITOR=${SERVICE_DOCEDITOR}

View File

@ -29,7 +29,7 @@ export default function withBadges(WrappedComponent) {
isTrashFolder,
} = this.props;
if (isTrashFolder) return;
fetchFileVersions(item.id + "");
fetchFileVersions(item.id + "", item.access);
setIsVerHistoryPanel(true);
};
@ -91,6 +91,7 @@ export default function withBadges(WrappedComponent) {
isDesktopClient,
sectionWidth,
viewAs,
canViewVersionFileHistory,
} = this.props;
const { fileStatus, access } = item;
@ -123,6 +124,7 @@ export default function withBadges(WrappedComponent) {
setConvertDialogVisible={this.setConvertDialogVisible}
onFilesClick={onFilesClick}
viewAs={viewAs}
canViewVersionFileHistory={canViewVersionFileHistory}
/>
);
@ -142,6 +144,7 @@ export default function withBadges(WrappedComponent) {
dialogsStore,
filesStore,
settingsStore,
accessRightsStore,
},
{ item }
) => {
@ -158,6 +161,9 @@ export default function withBadges(WrappedComponent) {
const canWebEdit = settingsStore.canWebEdit(item.fileExst);
const canConvert = settingsStore.canConvert(item.fileExst);
const canViewVersionFileHistory = accessRightsStore.canViewVersionFileHistory(
item
);
return {
theme,
@ -177,6 +183,7 @@ export default function withBadges(WrappedComponent) {
setConvertItem,
isDesktopClient,
setPinAction,
canViewVersionFileHistory,
};
}
)(observer(WithBadges));

View File

@ -1,7 +1,5 @@
import React from "react";
import { inject, observer } from "mobx-react";
import { ShareAccessRights } from "@docspace/common/constants";
import toastr from "@docspace/components/toast/toastr";
import QuickButtons from "../components/QuickButtons";
@ -56,19 +54,12 @@ export default function withQuickButtons(WrappedComponent) {
t,
theme,
item,
isTrashFolder,
isAdmin,
sectionWidth,
viewAs,
isArchiveFolderRoot,
canLockFile,
} = this.props;
const { access, id, fileExst } = item;
const accessToEdit =
access === ShareAccessRights.FullAccess ||
access === ShareAccessRights.None; // TODO: fix access type for owner (now - None)
const quickButtonsComponent = (
<QuickButtons
t={t}
@ -76,14 +67,12 @@ export default function withQuickButtons(WrappedComponent) {
item={item}
sectionWidth={sectionWidth}
isAdmin={isAdmin}
isTrashFolder={isTrashFolder}
accessToEdit={accessToEdit}
viewAs={viewAs}
isDisabled={isLoading}
isCanWebEdit={isCanWebEdit}
onClickLock={this.onClickLock}
onClickFavorite={this.onClickFavorite}
isArchiveFolderRoot={isArchiveFolderRoot}
canLockFile={canLockFile}
/>
);
@ -99,13 +88,11 @@ export default function withQuickButtons(WrappedComponent) {
return inject(
({
auth,
treeFoldersStore,
filesActionsStore,
filesStore,
dialogsStore,
settingsStore,
accessRightsStore,
}) => {
const { isRecycleBinFolder, isArchiveFolderRoot } = treeFoldersStore;
const {
lockFileAction,
setFavoriteAction,
@ -114,16 +101,17 @@ export default function withQuickButtons(WrappedComponent) {
const { setSharingPanelVisible } = dialogsStore;
const { canWebEdit } = settingsStore;
const { canLockFile } = accessRightsStore;
return {
theme: auth.settingsStore.theme,
isAdmin: auth.isAdmin,
isTrashFolder: isRecycleBinFolder,
lockFileAction,
setFavoriteAction,
onSelectItem,
setSharingPanelVisible,
canWebEdit,
isArchiveFolderRoot,
canLockFile,
};
}
)(observer(WithQuickButtons));

View File

@ -71,6 +71,7 @@ const Badges = ({
setConvertDialogVisible,
viewAs,
onUnpinClick,
canViewVersionFileHistory,
}) => {
const {
id,
@ -142,6 +143,10 @@ const Badges = ({
"data-id": id,
};
const onShowVersionHistoryProp = canViewVersionFileHistory
? { onClick: onShowVersionHistory }
: {};
return fileExst ? (
<div className="badges additional-badges temp-badges">
{isEditing && (
@ -167,13 +172,13 @@ const Badges = ({
/>
)}
{version > 1 && (
<BadgeWrapper onClick={onShowVersionHistory} isTile={isTile}>
<BadgeWrapper {...onShowVersionHistoryProp} isTile={isTile}>
<Badge
{...versionBadgeProps}
className="badge-version badge-version-current tablet-badge icons-group"
backgroundColor={theme.filesBadges.backgroundColor}
label={t("VersionBadge", { version: countVersions })}
onClick={onShowVersionHistory}
{...onShowVersionHistoryProp}
noHover={true}
isVersionBadge={true}
/>

View File

@ -17,16 +17,16 @@ const QuickButtons = (props) => {
theme,
sectionWidth,
isTrashFolder,
accessToEdit,
onClickLock,
isDisabled,
onClickFavorite,
viewAs,
isCanWebEdit,
isArchiveFolderRoot,
canLockFile,
} = props;
const { id, locked, fileStatus, title, fileExst } = item;
const { id, locked, fileStatus, title, fileExst, access, folderType } = item;
const canLockFileAbility = canLockFile(item);
const isFavorite =
(fileStatus & FileStatus.IsFavorite) === FileStatus.IsFavorite;
@ -59,12 +59,7 @@ const QuickButtons = (props) => {
const setFavorite = () => onClickFavorite(isFavorite);
const isAvailableLockFile =
!isArchiveFolderRoot &&
fileExst &&
accessToEdit &&
!isTrashFolder &&
displayBadges &&
isCanWebEdit;
canLockFileAbility && fileExst && displayBadges && isCanWebEdit;
return (
<div className="badges additional-badges">

View File

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import { inject } from "mobx-react";
import { ReactSVG } from "react-svg";
@ -9,14 +9,26 @@ import infoPanel from "@docspace/common/components/Section/sub-components/info-p
const CommentEditor = ({
t,
item,
editing,
setSelection,
isRecycleBinFolder,
isArchiveFolderRoot,
fetchFileVersions,
updateCommentVersion,
canChangeVersionFileHistory,
setVerHistoryFileId,
setVerHistoryFileAccess,
}) => {
const { id, comment, version } = item;
const { id, comment, version, access, folderType } = item;
const changeVersionHistoryAbility = canChangeVersionFileHistory({
access,
folderType,
editing,
});
useEffect(() => {
setVerHistoryFileId(id);
setVerHistoryFileAccess(access);
}, []);
const [isEdit, setIsEdit] = useState(false);
const [isLoading, setIsLoading] = useState(false);
@ -32,7 +44,7 @@ const CommentEditor = ({
const onSave = async () => {
setIsLoading(true);
await fetchFileVersions(id).catch((err) => {
await fetchFileVersions(id, access).catch((err) => {
toastr.error(err);
setIsLoading(false);
});
@ -61,7 +73,7 @@ const CommentEditor = ({
{comment}
</Text>
)}
{!isRecycleBinFolder && !isArchiveFolderRoot && (
{changeVersionHistoryAbility && (
<div className="edit_toggle" onClick={onOpenEditor}>
<ReactSVG
className="edit_toggle-icon"
@ -104,17 +116,29 @@ const CommentEditor = ({
);
};
export default inject(({ auth, versionHistoryStore, treeFoldersStore }) => {
export default inject(({ auth, versionHistoryStore, accessRightsStore }) => {
const { setSelection } = auth.infoPanelStore;
const { fetchFileVersions, updateCommentVersion } = versionHistoryStore;
const { isRecycleBinFolder, isArchiveFolderRoot } = treeFoldersStore;
const {
fetchFileVersions,
updateCommentVersion,
isEditingVersion,
isEditing,
fileId,
setVerHistoryFileId,
setVerHistoryFileAccess,
} = versionHistoryStore;
const { canChangeVersionFileHistory } = accessRightsStore;
const editing = isEditingVersion || isEditing;
return {
setSelection,
isRecycleBinFolder,
isArchiveFolderRoot,
fetchFileVersions,
updateCommentVersion,
canChangeVersionFileHistory,
editing,
setVerHistoryFileId,
setVerHistoryFileAccess,
};
})(CommentEditor);

View File

@ -3,7 +3,6 @@ import React, { useState } from "react";
import { StyledUser } from "../../styles/members";
import Avatar from "@docspace/components/avatar";
import { ComboBox } from "@docspace/components";
import { ShareAccessRights } from "@docspace/common/constants";
const User = ({
t,
@ -15,7 +14,9 @@ const User = ({
currCanEditUsers,
selectionParentRoom,
setSelectionParentRoom,
isArchiveRoot,
canChangeUserRoleInRoom,
rootFolderType,
access,
}) => {
if (!selectionParentRoom) return null;
if (!user.displayName && !user.email) return null;
@ -66,11 +67,13 @@ const User = ({
}
};
const isAvailable =
!isArchiveRoot &&
currCanEditUsers &&
currentMember?.id !== user.id &&
userRole.access !== ShareAccessRights.FullAccess;
const isCanChangeUserRole =
user &&
canChangeUserRoleInRoom({
access,
rootFolderType,
currentUserInList: { id: user.id, access: user.access },
});
return (
<StyledUser isExpect={isExpect} key={user.id}>
@ -91,7 +94,7 @@ const User = ({
{userRole && userRoleOptions && (
<div className="role-wrapper">
{isAvailable ? (
{isCanChangeUserRole ? (
<ComboBox
className="role-combobox"
selectedOption={userRole}

View File

@ -19,7 +19,6 @@ const Members = ({
selfId,
isOwner,
isAdmin,
isArchiveRoot,
selection,
selectionParentRoom,
@ -33,13 +32,19 @@ const Members = ({
changeUserType,
canInviteUserInRoom,
canChangeUserRoleInRoom,
}) => {
const membersHelper = new MembersHelper({ t });
const [members, setMembers] = useState(null);
const [showLoader, setShowLoader] = useState(false);
const { access, rootFolderType } = selection;
const canInviteUserInRoomAbility = canInviteUserInRoom({
access,
rootFolderType,
});
const isDisabledInvite = !canInviteUserInRoom({ access: selection.access });
const fetchMembers = async (roomId) => {
let timerId;
if (members) timerId = setTimeout(() => setShowLoader(true), 1000);
@ -117,19 +122,13 @@ const Members = ({
(member) => member.id === selfId
);
const currCanEditUsers =
isOwner ||
isAdmin ||
currentMember?.access === ShareAccessRights.FullAccess ||
currentMember?.access === ShareAccessRights.RoomManager;
return (
<>
<StyledUserTypeHeader>
<Text className="title">
{t("UsersInRoom")} : {members.inRoom.length}
</Text>
{currCanEditUsers && !isArchiveRoot && (
{canInviteUserInRoomAbility && (
<IconButton
className={"icon"}
title={t("Common:AddUsers")}
@ -137,7 +136,6 @@ const Members = ({
isFill={true}
onClick={onClickInviteUsers}
size={16}
isDisabled={isDisabledInvite}
/>
)}
</StyledUserTypeHeader>
@ -145,7 +143,8 @@ const Members = ({
<StyledUserList>
{Object.values(members.inRoom).map((user) => (
<User
currCanEditUsers={currCanEditUsers}
access={access}
rootFolderType={rootFolderType}
key={user.id}
t={t}
user={user}
@ -156,7 +155,7 @@ const Members = ({
roomType={selectionParentRoom.roomType}
selectionParentRoom={selectionParentRoom}
setSelectionParentRoom={setSelectionParentRoom}
isArchiveRoot={isArchiveRoot}
canChangeUserRoleInRoom={canChangeUserRoleInRoom}
/>
))}
</StyledUserList>
@ -164,7 +163,7 @@ const Members = ({
{!!members.expected.length && (
<StyledUserTypeHeader isExpect>
<Text className="title">{t("ExpectPeople")}</Text>
{currCanEditUsers && !isArchiveRoot && (
{canInviteUserInRoomAbility && (
<IconButton
className={"icon"}
title={t("Repeat invitation")}
@ -180,6 +179,8 @@ const Members = ({
<StyledUserList>
{Object.values(members.expected).map((user) => (
<User
access={access}
rootFolderType={rootFolderType}
isExpect
key={user.id}
t={t}
@ -191,7 +192,6 @@ const Members = ({
roomType={selectionParentRoom.roomType}
selectionParentRoom={selectionParentRoom}
setSelectionParentRoom={setSelectionParentRoom}
isArchiveRoot={isArchiveRoot}
/>
))}
</StyledUserList>
@ -200,14 +200,7 @@ const Members = ({
};
export default inject(
({
auth,
filesStore,
peopleStore,
dialogsStore,
accessRightsStore,
treeFoldersStore,
}) => {
({ auth, filesStore, peopleStore, dialogsStore, accessRightsStore }) => {
const { selectionParentRoom, setSelectionParentRoom } = auth.infoPanelStore;
const {
getRoomMembers,
@ -217,9 +210,7 @@ export default inject(
const { isOwner, isAdmin, id: selfId } = auth.userStore.user;
const { setInvitePanelOptions } = dialogsStore;
const { changeType: changeUserType } = peopleStore;
const { canInviteUserInRoom } = accessRightsStore;
const { isArchiveFolderRoot } = treeFoldersStore;
const { canInviteUserInRoom, canChangeUserRoleInRoom } = accessRightsStore;
return {
selectionParentRoom,
@ -237,7 +228,7 @@ export default inject(
changeUserType,
canInviteUserInRoom,
isArchiveRoot: isArchiveFolderRoot,
canChangeUserRoleInRoom,
};
}
)(

View File

@ -358,14 +358,14 @@ class SectionHeaderContent extends React.Component {
key: "empty-archive",
label: t("ArchiveAction"),
onClick: this.onEmptyTrashAction,
disabled: !canRestoreAll,
disabled: !canDeleteAll,
icon: "images/clear.trash.react.svg",
},
{
key: "restore-all",
label: t("RestoreAll"),
onClick: this.onRestoreAllArchiveAction,
disabled: !canDeleteAll,
disabled: !canRestoreAll,
icon: "images/subtract.react.svg",
},
];

View File

@ -16,7 +16,6 @@ import { inject, observer } from "mobx-react";
import toastr from "@docspace/components/toast/toastr";
import { Encoder } from "@docspace/common/utils/encoder";
import { Base } from "@docspace/components/themes";
import { getFileRoleActions } from "@docspace/common/utils/actions";
const StyledExternalLinkIcon = styled(ExternalLinkIcon)`
${commonIconsStyles}
@ -42,16 +41,12 @@ const VersionRow = (props) => {
versionsListLength,
isEditing,
theme,
isArchiveFolderRoot,
canChangeVersionFileHistory,
} = props;
const [showEditPanel, setShowEditPanel] = useState(false);
const [commentValue, setCommentValue] = useState(info.comment);
const [isSavingComment, setIsSavingComment] = useState(false);
const { changeVersionHistory } = getFileRoleActions(info.access);
const canEdit = changeVersionHistory && !isEditing;
const title = `${new Date(info.updated).toLocaleString(
culture
)} ${Encoder.htmlDecode(info.updatedBy?.displayName)}`;
@ -95,15 +90,13 @@ const VersionRow = (props) => {
);
};
const isAvailableEdit = canEdit && !isArchiveFolderRoot;
const contextOptions = [
isAvailableEdit && {
canChangeVersionFileHistory && {
key: "edit",
label: t("EditComment"),
onClick: onEditComment,
},
isAvailableEdit && {
canChangeVersionFileHistory && {
key: "restore",
label: t("Common:Restore"),
onClick: onRestoreClick,
@ -115,7 +108,9 @@ const VersionRow = (props) => {
},
];
const onClickProp = isAvailableEdit ? { onClick: onVersionClick } : {};
const onClickProp = canChangeVersionFileHistory
? { onClick: onVersionClick }
: {};
useEffect(() => {
const newRowHeight = document.getElementsByClassName(
@ -129,7 +124,7 @@ const VersionRow = (props) => {
<StyledVersionRow
showEditPanel={showEditPanel}
contextOptions={contextOptions}
canEdit={isAvailableEdit}
canEdit={canChangeVersionFileHistory}
isTabletView={isTabletView}
isSavingComment={isSavingComment}
isEditing={isEditing}
@ -225,32 +220,44 @@ const VersionRow = (props) => {
);
};
export default inject(({ auth, versionHistoryStore, treeFoldersStore }) => {
const { user } = auth.userStore;
const { culture, isTabletView } = auth.settingsStore;
const language = (user && user.cultureName) || culture || "en";
export default inject(
({ auth, versionHistoryStore, accessRightsStore, selectedFolderStore }) => {
const { user } = auth.userStore;
const { culture, isTabletView } = auth.settingsStore;
const language = (user && user.cultureName) || culture || "en";
const {
markAsVersion,
restoreVersion,
updateCommentVersion,
isEditing,
isEditingVersion,
} = versionHistoryStore;
const {
markAsVersion,
restoreVersion,
updateCommentVersion,
isEditing,
isEditingVersion,
fileAccess,
} = versionHistoryStore;
const { isArchiveFolderRoot } = treeFoldersStore;
const { rootFolderType } = selectedFolderStore;
return {
theme: auth.settingsStore.theme,
culture: language,
isTabletView,
markAsVersion,
restoreVersion,
updateCommentVersion,
isEditing: isEditingVersion || isEditing,
isArchiveFolderRoot,
};
})(
const isEdit = isEditingVersion || isEditing;
const canChangeVersionFileHistory = accessRightsStore.canChangeVersionFileHistory(
{
access: fileAccess,
rootFolderType,
editing: isEdit,
}
);
return {
theme: auth.settingsStore.theme,
culture: language,
isTabletView,
markAsVersion,
restoreVersion,
updateCommentVersion,
isEditing: isEdit,
canChangeVersionFileHistory,
};
}
)(
withRouter(
withTranslation(["VersionHistory", "Common", "Translations"])(
observer(VersionRow)

View File

@ -24,15 +24,15 @@ class SectionBodyContent extends React.Component {
const fileId = match.params.fileId || this.props.fileId;
if (fileId && fileId !== this.props.fileId) {
this.getFileVersions(fileId);
this.getFileVersions(fileId, fileAccess);
setFirstLoad(false);
}
}
getFileVersions = (fileId) => {
getFileVersions = (fileId, fileAccess) => {
const { fetchFileVersions, setIsLoading } = this.props;
setIsLoading(true);
fetchFileVersions(fileId).then(() => setIsLoading(false));
fetchFileVersions(fileId, fileAccess).then(() => setIsLoading(false));
};
onSetRestoreProcess = (restoring) => {
@ -138,14 +138,19 @@ class SectionBodyContent extends React.Component {
export default inject(({ auth, filesStore, versionHistoryStore }) => {
const { setFirstLoad, setIsLoading, isLoading } = filesStore;
const { versions, fetchFileVersions, fileId } = versionHistoryStore;
const {
versions,
fetchFileVersions,
fileId,
fileAccess,
} = versionHistoryStore;
return {
culture: auth.settingsStore.culture,
isLoading,
versions,
fileId,
fileAccess,
setFirstLoad,
setIsLoading,
fetchFileVersions,

View File

@ -10,11 +10,13 @@ import {
getFileRoleActions,
getRoomRoleActions,
getArchiveRoomRoleActions,
getArchiveFileRoleActions,
} from "@docspace/common/utils/actions";
class AccessRightsStore {
authStore = null;
selectedFolderStore = null;
treeFoldersStore = null;
constructor(authStore, selectedFolderStore) {
this.authStore = authStore;
@ -23,14 +25,133 @@ class AccessRightsStore {
makeAutoObservable(this);
}
canInviteUserInRoom = (room) => {
const { rootFolderType } = this.selectedFolderStore;
canInviteUserInRoom(room) {
const { access, rootFolderType } = room;
if (rootFolderType === FolderType.Archive) return false;
if (rootFolderType === FolderType.Archive)
return getArchiveRoomRoleActions(access).inviteUsers;
const { inviteUsers } = getRoomRoleActions(room.access);
return getRoomRoleActions(access).inviteUsers;
}
return inviteUsers;
canChangeUserRoleInRoom = (room) => {
const { access, rootFolderType, currentUserInList } = room;
const { userStore } = this.authStore;
const { user } = userStore;
if (rootFolderType === FolderType.Archive)
return getArchiveRoomRoleActions(access).changeUserRole;
const isMyProfile = user.id === currentUserInList.id;
const isOwnerRoleRoom =
currentUserInList.access === ShareAccessRights.FullAccess;
if (isMyProfile || isOwnerRoleRoom) return false;
return getRoomRoleActions(access).changeUserRole;
};
canLockFile = (file) => {
const { rootFolderType, access } = file;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).block;
if (rootFolderType === FolderType.TRASH) return false;
return getFileRoleActions(access).block;
};
canChangeVersionFileHistory = (file) => {
const { rootFolderType, editing, providerKey, access } = file;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).changeVersionHistory;
if (
rootFolderType === FolderType.TRASH ||
// rootFolderType === FolderType.Privacy ||
editing ||
providerKey
)
return false;
return getFileRoleActions(access).changeVersionHistory;
};
canViewVersionFileHistory = (file) => {
const { rootFolderType, access, providerKey } = file;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).viewVersionHistory;
if (
rootFolderType === FolderType.TRASH ||
// rootFolderType === FolderType.Privacy ||
providerKey
)
return false;
return getFileRoleActions(access).viewVersionHistory;
};
canEditFile = (file) => {
const { rootFolderType, access } = file;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).edit;
if (
rootFolderType === FolderType.TRASH
// || rootFolderType === FolderType.Privacy
)
return false;
return getFileRoleActions(access).edit;
};
canRenameItem = (item = {}) => {
const { rootFolderType, access, isFile } = item;
const { isDesktopClient } = this.authStore.settingsStore;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).rename;
if (
rootFolderType === FolderType.TRASH ||
(!isFile &&
// rootFolderType === FolderType.Privacy &&
!isDesktopClient)
)
return false;
return getFileRoleActions(access).rename;
};
canFillForm = (file) => {
const { rootFolderType, access } = file;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).fillForm;
if (rootFolderType === FolderType.TRASH) return false;
return getFileRoleActions(access).fillForm;
};
canMakeForm = (item) => {
const { rootFolderType, access } = item;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).saveAsForm;
if (
rootFolderType === FolderType.TRASH ||
// rootFolderType === FolderType.Privacy ||
rootFolderType === FolderType.Favorites ||
rootFolderType === FolderType.Recent
)
return false;
return getFileRoleActions(access).saveAsForm;
};
canArchiveRoom = (room) => {
@ -40,51 +161,130 @@ class AccessRightsStore {
};
canRemoveRoom = (room) => {
const { delete: remove } = getRoomRoleActions(room.access);
const { access, rootFolderType } = room;
return remove;
if (rootFolderType !== FolderType.Archive)
return getRoomRoleActions(access).delete;
return getArchiveRoomRoleActions(access).delete;
};
canViewRoomInfo = (room) => {
const { access, rootFolderType } = room;
if (rootFolderType === FolderType.Archive)
return getArchiveRoomRoleActions(access).viewInfo;
return getRoomRoleActions(access).viewInfo;
};
canPinRoom = (room) => {
const { access, rootFolderType } = room;
if (rootFolderType === FolderType.Archive)
return getArchiveRoomRoleActions(access).canPin;
return getRoomRoleActions(access).canPin;
};
canEditRoom = (room) => {
const { access, rootFolderType } = room;
if (rootFolderType === FolderType.Archive)
return getArchiveRoomRoleActions(access).edit;
return getRoomRoleActions(access).edit;
};
get canCreateFiles() {
const { access, rootFolderType } = this.selectedFolderStore;
if (rootFolderType === FolderType.Archive) return false;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).create;
const { create } = getFileRoleActions(access);
return create;
}
canMoveFile = (room) => {
const { rootFolderType } = room;
canMoveItems = (item) => {
const { rootFolderType, access, editing: fileEditing, providerKey } = item;
if (rootFolderType === FolderType.Archive) return false;
if (rootFolderType === FolderType.Archive) {
const { moveSelf, moveAlien } = getArchiveFileRoleActions(access);
const { moveSelf, moveAlien } = getFileRoleActions(room.access);
return moveSelf || moveAlien;
}
if (
rootFolderType === FolderType.TRASH ||
rootFolderType === FolderType.Favorites ||
rootFolderType === FolderType.Recent ||
// rootFolderType === FolderType.Privacy ||
providerKey ||
fileEditing
)
return false;
const { moveSelf, moveAlien } = getFileRoleActions(access);
return moveSelf || moveAlien;
};
canDeleteFile = (room) => {
const { rootFolderType } = room;
canDeleteItems = (item) => {
const { rootFolderType, access, editing: fileEditing } = item;
if (rootFolderType === FolderType.Archive) return false;
if (rootFolderType === FolderType.Archive) {
const { deleteSelf, deleteAlien } = getArchiveFileRoleActions(access);
const { deleteSelf, deleteAlien } = getFileRoleActions(room.access);
return deleteSelf || deleteAlien;
}
if (
rootFolderType === FolderType.TRASH ||
rootFolderType === FolderType.Favorites ||
rootFolderType === FolderType.Recent ||
// rootFolderType === FolderType.Privacy ||
fileEditing
)
return false;
const { deleteSelf, deleteAlien } = getFileRoleActions(access);
return deleteSelf || deleteAlien;
};
canCopyFile = (room) => {
const { rootFolderType } = room;
canCopyItems = (item) => {
const { rootFolderType, access } = item;
if (rootFolderType === FolderType.Archive) return false;
if (
rootFolderType === FolderType.TRASH ||
rootFolderType === FolderType.Favorites ||
rootFolderType === FolderType.Recent
// || rootFolderType === FolderType.Privacy
)
return false;
const { copyFromPersonal } = getFileRoleActions(room.access);
const { canCopy } = getFileRoleActions(access);
return copyFromPersonal;
return canCopy;
};
canDuplicateFile = (item) => {
const { rootFolderType, access } = item;
if (rootFolderType === FolderType.Archive)
return getArchiveFileRoleActions(access).canDuplicate;
if (
rootFolderType === FolderType.TRASH ||
rootFolderType === FolderType.Favorites ||
rootFolderType === FolderType.Recent
// || rootFolderType === FolderType.Privacy
)
return false;
return getFileRoleActions(access).canDuplicate;
};
canChangeUserType = (user) => {
const { id, isOwner } = this.authStore.userStore.user;

View File

@ -489,7 +489,7 @@ class ContextOptionsStore {
key: "show-version-history",
label: t("ShowVersionHistory"),
icon: "images/history.react.svg",
onClick: () => this.showVersionHistory(item.id),
onClick: () => this.showVersionHistory(item.id, item.access),
disabled: false,
},
]
@ -503,14 +503,15 @@ class ContextOptionsStore {
key: "finalize-version",
label: t("FinalizeVersion"),
icon: "images/history-finalized.react.svg",
onClick: () => this.finalizeVersion(item.id),
onClick: () => this.finalizeVersion(item.id, item.access),
disabled: false,
},
{
key: "show-version-history",
label: t("ShowVersionHistory"),
icon: "images/history.react.svg",
onClick: () => this.showVersionHistory(item.id),
onClick: () =>
this.showVersionHistory(item.id, item.access),
disabled: false,
},
],
@ -528,7 +529,7 @@ class ContextOptionsStore {
key: "show-version-history",
label: t("ShowVersionHistory"),
icon: "images/history.react.svg",
onClick: () => this.showVersionHistory(item.id),
onClick: () => this.showVersionHistory(item.id, item.access),
disabled: false,
},
]
@ -884,10 +885,25 @@ class ContextOptionsStore {
deleteRooms,
} = this.filesActionsStore;
if (isRoomsFolder || isArchiveFolder) {
const isPinOption = selection.filter((item) => !item.pinned).length > 0;
const canDelete =
selection.findIndex((k) => k.contextOptions.includes("delete")) !== -1;
const canArchiveRoom =
selection.findIndex((k) =>
k.contextOptions.includes("archive-room")
) !== -1;
const canRestoreRoom =
selection.findIndex((k) =>
k.contextOptions.includes("unarchive-room")
) !== -1;
let archiveOptions;
const pinOption = isPinOption
? {
key: "pin-room",
@ -904,25 +920,28 @@ class ContextOptionsStore {
disabled: false,
};
const archiveOptions = !isArchiveFolder
? {
key: "archive-room",
label: t("Archived"),
icon: "/static/images/room.archive.svg",
onClick: (e) => this.onClickArchive(e),
disabled: false,
"data-action": "archive",
action: "archive",
}
: {
key: "unarchive-room",
label: t("Common:Restore"),
icon: "images/subtract.react.svg",
onClick: (e) => this.onClickArchive(e),
disabled: false,
"data-action": "unarchive",
action: "unarchive",
};
if (canArchiveRoom) {
archiveOptions = {
key: "archive-room",
label: t("Archived"),
icon: "/static/images/room.archive.svg",
onClick: (e) => this.onClickArchive(e),
disabled: false,
"data-action": "archive",
action: "archive",
};
}
if (canRestoreRoom) {
archiveOptions = {
key: "unarchive-room",
label: t("Common:Restore"),
icon: "images/subtract.react.svg",
onClick: (e) => this.onClickArchive(e),
disabled: false,
"data-action": "unarchive",
action: "unarchive",
};
}
const options = [];
@ -936,14 +955,13 @@ class ContextOptionsStore {
options.push(archiveOptions);
if (isArchiveFolder) {
canDelete &&
options.push({
key: "delete-rooms",
label: t("Common:Delete"),
icon: "images/trash.react.svg",
onClick: () => deleteRooms(t),
});
}
return options;
}

View File

@ -1257,20 +1257,18 @@ class FilesActionStore {
};
isAvailableOption = (option) => {
const { isFavoritesFolder, isRecentFolder } = this.treeFoldersStore;
const {
isAccessedSelected,
canConvertSelected,
isThirdPartyRootSelection,
hasSelection,
allFilesIsEditing,
selection,
} = this.filesStore;
const {
canCopyFile,
canDeleteFile,
canMoveFile,
canCopyItems,
canDeleteItems,
canMoveItems,
canArchiveRoom,
canRemoveRoom,
} = this.accessRightsStore;
@ -1278,7 +1276,7 @@ class FilesActionStore {
switch (option) {
case "copy":
const canCopy = canCopyFile({ access, rootFolderType });
const canCopy = canCopyItems({ access, rootFolderType });
return hasSelection && canCopy;
case "showInfo":
@ -1287,16 +1285,12 @@ class FilesActionStore {
case "downloadAs":
return canConvertSelected;
case "moveTo":
const canMove = canMoveFile({ access, rootFolderType });
return (
!isThirdPartyRootSelection &&
hasSelection &&
isAccessedSelected &&
!isRecentFolder &&
!isFavoritesFolder &&
!allFilesIsEditing &&
canMove
);
const canMove = canMoveItems({
access,
rootFolderType,
editing: allFilesIsEditing,
});
return hasSelection && isAccessedSelected && canMove;
case "archive":
case "unarchive":
@ -1313,12 +1307,12 @@ class FilesActionStore {
return canRemove.length > 0;
case "delete":
const canDelete = canDeleteFile({ access, rootFolderType });
const deleteCondition =
!isThirdPartyRootSelection &&
hasSelection &&
isAccessedSelected &&
!allFilesIsEditing;
const canDelete = canDeleteItems({
access,
rootFolderType,
editing: allFilesIsEditing,
});
const deleteCondition = hasSelection && isAccessedSelected;
return canDelete && deleteCondition;
}

View File

@ -26,10 +26,7 @@ import {
import { isDesktop } from "@docspace/components/utils/device";
import { getContextMenuKeysByType } from "SRC_DIR/helpers/plugins";
import { PluginContextMenuItemType } from "SRC_DIR/helpers/plugins/constants";
import {
getFileRoleActions,
getRoomRoleActions,
} from "@docspace/common/utils/actions";
import { getArchiveRoomRoleActions } from "@docspace/common/utils/actions";
const { FilesFilter, RoomsFilter } = api;
const storageViewAs = localStorage.getItem("viewAs");
@ -1022,23 +1019,13 @@ class FilesStore {
const isDocuSign = false; //TODO: need this prop;
const isEditing =
(item.fileStatus & FileStatus.IsEditing) === FileStatus.IsEditing;
const isFileOwner =
item.createdBy?.id === this.authStore.userStore.user?.id;
// const isFileOwner =
// item.createdBy?.id === this.authStore.userStore.user?.id;
const {
isRecycleBinFolder,
isPrivacyFolder,
isRecentFolder,
isFavoritesFolder,
isShareFolder,
isMy,
isArchiveFolder,
} = this.treeFoldersStore;
const { isRecycleBinFolder, isMy, isArchiveFolder } = this.treeFoldersStore;
const { canFormFillingDocs } = this.filesSettingsStore;
const filesRights = getFileRoleActions(item.access);
const { enablePlugins } = this.authStore.settingsStore;
const isThirdPartyFolder =
@ -1051,10 +1038,39 @@ class FilesStore {
const pluginAllKeys =
enablePlugins && getContextMenuKeysByType(PluginContextMenuItemType.All);
const canRenameItem = this.accessRightsStore.canRenameItem({
...item,
...isFile,
});
const canMove = this.accessRightsStore.canMoveItems({
...item,
...{ editing: isEditing },
});
const canDelete = this.accessRightsStore.canDeleteItems({
...item,
...{ editing: isEditing },
});
const canCopy = this.accessRightsStore.canCopyItems(item);
const canCreateCopy = this.accessRightsStore.canDuplicateFile(item);
if (isFile) {
const shouldFillForm = canFormFillingDocs(item.fileExst);
const canLockFile = this.accessRightsStore.canLockFile(item);
const canChangeVersionFileHistory = this.accessRightsStore.canChangeVersionFileHistory(
{ ...item, ...{ editing: isEditing } }
);
const canViewVersionFileHistory = this.accessRightsStore.canViewVersionFileHistory(
item
);
const canFillForm = this.accessRightsStore.canFillForm(item);
const canEditFile = this.accessRightsStore.canEditFile(item);
const isMasterForm = item.fileExst === ".docxf";
const canMakeForm = this.accessRightsStore.canMakeForm(item);
let fileOptions = [
//"open",
@ -1080,7 +1096,7 @@ class FilesStore {
"open-location",
"mark-read",
// "mark-as-favorite",
"remove-from-favorites",
// "remove-from-favorites",
"download",
"download-as",
"convert",
@ -1095,75 +1111,69 @@ class FilesStore {
"delete",
];
if (!filesRights.edit) {
fileOptions = this.removeOptions(fileOptions, ["edit"]);
}
if (!filesRights.fillForm) {
fileOptions = this.removeOptions(fileOptions, ["fill-form"]);
}
if (!filesRights.blockFile) {
if (!canLockFile) {
fileOptions = this.removeOptions(fileOptions, [
"block-unblock-version",
]);
}
if (!filesRights.viewVersionHistory) {
fileOptions = this.removeOptions(fileOptions, ["show-version-history"]);
}
if (!filesRights.changeVersionHistory) {
if (!canChangeVersionFileHistory) {
fileOptions = this.removeOptions(fileOptions, ["finalize-version"]);
}
if (!filesRights.deleteSelf || !filesRights.deleteAlien) {
fileOptions = this.removeOptions(fileOptions, ["delete"]);
if (!canViewVersionFileHistory) {
fileOptions = this.removeOptions(fileOptions, ["show-version-history"]);
}
if (!filesRights.moveSelf || !filesRights.moveAlien) {
fileOptions = this.removeOptions(fileOptions, ["move-to"]);
}
if (!filesRights.rename) {
fileOptions = this.removeOptions(fileOptions, ["rename"]);
}
if (!filesRights.copyFromPersonal) {
fileOptions = this.removeOptions(fileOptions, ["copy-to", "copy"]);
}
if (
!filesRights.viewVersionHistory &&
!filesRights.changeVersionHistory
) {
if (!canChangeVersionFileHistory && !canViewVersionFileHistory) {
fileOptions = this.removeOptions(fileOptions, ["version"]);
if (item.rootFolderType === FolderType.Archive) {
fileOptions = this.removeOptions(fileOptions, ["separator0"]);
}
}
if (
(!filesRights.moveSelf || !filesRights.moveAlien) &&
!filesRights.copyFromPersonal
) {
if (!canRenameItem) {
fileOptions = this.removeOptions(fileOptions, ["rename"]);
}
if (canOpenPlayer || !canEditFile) {
fileOptions = this.removeOptions(fileOptions, ["edit"]);
}
if (!(shouldFillForm && canFillForm)) {
fileOptions = this.removeOptions(fileOptions, ["fill-form"]);
}
if (!canDelete) {
fileOptions = this.removeOptions(fileOptions, ["delete"]);
}
if (!canMove) {
fileOptions = this.removeOptions(fileOptions, ["move-to"]);
}
if (!canCopy) {
fileOptions = this.removeOptions(fileOptions, ["copy-to"]);
}
if (!canCreateCopy) {
fileOptions = this.removeOptions(fileOptions, ["copy"]);
}
if (!canMove && !canCopy && !canCreateCopy) {
fileOptions = this.removeOptions(fileOptions, ["move"]);
}
if (!(isMasterForm && canMakeForm))
fileOptions = this.removeOptions(fileOptions, ["make-form"]);
if (item.rootFolderType === FolderType.Archive) {
fileOptions = this.removeOptions(fileOptions, [
"make-form",
"mark-read",
"mark-as-favorite",
"remove-from-favorites",
"edit",
"move",
"move-to",
"copy-to",
"copy",
"rename",
"separator2",
"delete",
"finalize-version",
]);
}
if (!isMasterForm)
fileOptions = this.removeOptions(fileOptions, ["make-form"]);
if (!shouldFillForm)
fileOptions = this.removeOptions(fileOptions, ["fill-form"]);
if (!canConvert) {
fileOptions = this.removeOptions(fileOptions, ["download-as"]);
}
@ -1175,110 +1185,64 @@ class FilesStore {
if (!canOpenPlayer) {
fileOptions = this.removeOptions(fileOptions, ["view"]);
} else {
fileOptions = this.removeOptions(fileOptions, ["edit", "preview"]);
fileOptions = this.removeOptions(fileOptions, ["preview"]);
}
if (!isDocuSign) {
fileOptions = this.removeOptions(fileOptions, ["docu-sign"]);
}
if (isEditing) {
fileOptions = this.removeOptions(fileOptions, [
"finalize-version",
"move-to",
"separator2",
"delete",
]);
if (isThirdPartyItem) {
fileOptions = this.removeOptions(fileOptions, ["rename"]);
}
}
if (
isEditing ||
item.rootFolderType === FolderType.Archive
// ||
// (isFavoritesFolder && !isFavorite) ||
// isFavoritesFolder ||
// isRecentFolder
)
fileOptions = this.removeOptions(fileOptions, ["separator2"]);
if (isFavorite) {
fileOptions = this.removeOptions(fileOptions, ["mark-as-favorite"]);
} else {
fileOptions = this.removeOptions(fileOptions, [
"remove-from-favorites",
]);
// if (isFavorite) {
// fileOptions = this.removeOptions(fileOptions, ["mark-as-favorite"]);
// } else {
// fileOptions = this.removeOptions(fileOptions, [
// "remove-from-favorites",
// ]);
if (isFavoritesFolder) {
fileOptions = this.removeOptions(fileOptions, ["mark-as-favorite"]);
}
}
if (isFavoritesFolder) {
fileOptions = this.removeOptions(fileOptions, [
"move-to",
"delete",
"copy",
]);
if (!isFavorite) {
fileOptions = this.removeOptions(fileOptions, ["separator2"]);
}
}
// if (isFavoritesFolder) {
// fileOptions = this.removeOptions(fileOptions, ["mark-as-favorite"]);
// }
// }
if (isEncrypted) {
fileOptions = this.removeOptions(fileOptions, [
"open",
"edit",
"make-form",
"link-for-portal-users",
"external-link",
// "link-for-portal-users",
// "external-link",
"send-by-email",
"block-unblock-version", //need split
"version", //category
"finalize-version",
"copy-to",
"copy",
"mark-as-favorite",
]);
}
if (isRecentFolder) {
fileOptions = this.removeOptions(fileOptions, ["delete"]);
if (!isFavorite) {
fileOptions = this.removeOptions(fileOptions, ["separator2"]);
}
}
if (isFavoritesFolder || isRecentFolder) {
fileOptions = this.removeOptions(fileOptions, [
"make-form",
"copy",
"move-to",
//"sharing-settings",
"unsubscribe",
"separator2",
]);
}
// if (isFavoritesFolder || isRecentFolder) {
// fileOptions = this.removeOptions(fileOptions, [
// //"unsubscribe",
// ]);
// }
if (isRecycleBinFolder) {
fileOptions = this.removeOptions(fileOptions, [
"fill-form",
"open",
"open-location",
"view",
"preview",
"edit",
"make-form",
"link-for-portal-users",
"sharing-settings",
"external-link",
//"link-for-portal-users",
//"sharing-settings",
//"external-link",
"send-by-email",
"block-unblock-version", //need split
"version", //category
"finalize-version",
"show-version-history",
"move", //category
"move-to",
"copy-to",
"copy",
"mark-read",
"mark-as-favorite",
"remove-from-favorites",
"rename",
// "mark-as-favorite",
// "remove-from-favorites",
"separator0",
"separator1",
]);
@ -1302,11 +1266,7 @@ class FilesStore {
}
if (isThirdPartyItem) {
fileOptions = this.removeOptions(fileOptions, [
"owner-change",
"finalize-version",
"copy",
]);
fileOptions = this.removeOptions(fileOptions, ["owner-change"]);
}
if (!hasNew) {
@ -1315,38 +1275,42 @@ class FilesStore {
if (
!(
isRecentFolder ||
isFavoritesFolder ||
// isRecentFolder ||
// isFavoritesFolder ||
(isMyFolder && (this.filterType || this.filterSearch))
)
) {
fileOptions = this.removeOptions(fileOptions, ["open-location"]);
}
if (isPrivacyFolder) {
fileOptions = this.removeOptions(fileOptions, [
"preview",
"view",
"separator0",
"copy",
"download-as",
]);
// if (isPrivacyFolder) {
// fileOptions = this.removeOptions(fileOptions, [
// "preview",
// "view",
// "separator0",
// "download-as",
// ]);
if (!isDesktopClient) {
fileOptions = this.removeOptions(fileOptions, ["sharing-settings"]);
}
fileOptions = this.removeOptions(
fileOptions,
isFileOwner ? ["unsubscribe"] : ["move-to", "delete"]
);
}
// // if (!isDesktopClient) {
// // fileOptions = this.removeOptions(fileOptions, ["sharing-settings"]);
// // }
// }
fileOptions = this.removeSeparator(fileOptions);
return fileOptions;
} else if (isRoom) {
const roomAccessRights = getRoomRoleActions(item.access);
const canInviteUserInRoom = this.accessRightsStore.canInviteUserInRoom(
item
);
const canRemoveRoom = this.accessRightsStore.canRemoveRoom(item);
const canArchiveRoom = this.accessRightsStore.canArchiveRoom(item);
const canPinRoom = this.accessRightsStore.canPinRoom(item);
const canEditRoom = this.accessRightsStore.canEditRoom(item);
const canViewRoomInfo = this.accessRightsStore.canViewRoomInfo(item);
let roomOptions = [
"select",
@ -1363,29 +1327,29 @@ class FilesStore {
"delete",
];
if (!roomAccessRights.edit) {
if (!canEditRoom) {
roomOptions = this.removeOptions(roomOptions, [
"edit-room",
"reconnect-storage",
]);
}
if (!roomAccessRights.inviteUsers) {
if (!canInviteUserInRoom) {
roomOptions = this.removeOptions(roomOptions, ["invite-users-to-room"]);
}
if (!roomAccessRights.archive) {
if (!canArchiveRoom) {
roomOptions = this.removeOptions(roomOptions, [
"archive-room",
"unarchive-room",
]);
}
if (!roomAccessRights.delete) {
if (!canRemoveRoom) {
roomOptions = this.removeOptions(roomOptions, ["delete"]);
}
if (!roomAccessRights.archive && !roomAccessRights.delete) {
if (!canArchiveRoom && !canRemoveRoom) {
roomOptions = this.removeOptions(roomOptions, ["separator1"]);
}
@ -1393,27 +1357,28 @@ class FilesStore {
roomOptions = this.removeOptions(roomOptions, ["reconnect-storage"]);
}
if (item.pinned) {
roomOptions = this.removeOptions(roomOptions, ["pin-room"]);
if (!canPinRoom) {
roomOptions = this.removeOptions(roomOptions, [
"unpin-room",
"pin-room",
]);
} else {
roomOptions = this.removeOptions(roomOptions, ["unpin-room"]);
item.pinned
? (roomOptions = this.removeOptions(roomOptions, ["pin-room"]))
: (roomOptions = this.removeOptions(roomOptions, ["unpin-room"]));
}
if (!canViewRoomInfo) {
roomOptions = this.removeOptions(roomOptions, ["room-info"]);
}
if (isArchiveFolder || item.rootFolderType === FolderType.Archive) {
roomOptions = this.removeOptions(roomOptions, [
"edit-room",
"invite-users-to-room",
"pin-room",
"unpin-room",
"archive-room",
"separator1",
"room-info",
]);
} else {
roomOptions = this.removeOptions(roomOptions, [
"delete",
"unarchive-room",
]);
roomOptions = this.removeOptions(roomOptions, ["unarchive-room"]);
if (enablePlugins) {
const pluginRoomsKeys = getContextMenuKeysByType(
@ -1448,66 +1413,54 @@ class FilesStore {
"mark-read",
"restore",
"rename",
"change-thirdparty-info",
// "change-thirdparty-info",
"separator2",
// "unsubscribe",
"delete",
];
if (!filesRights.deleteSelf || !filesRights.deleteAlien) {
folderOptions = this.removeOptions(folderOptions, ["delete"]);
}
if (!filesRights.moveSelf || !filesRights.moveAlien) {
folderOptions = this.removeOptions(folderOptions, ["move-to"]);
}
if (!filesRights.rename) {
if (!canRenameItem) {
folderOptions = this.removeOptions(folderOptions, ["rename"]);
}
if (!filesRights.copyFromPersonal) {
folderOptions = this.removeOptions(folderOptions, ["copy-to", "copy"]);
if (!canDelete) {
folderOptions = this.removeOptions(folderOptions, ["delete"]);
}
if (!canMove) {
folderOptions = this.removeOptions(folderOptions, ["move-to"]);
}
if (
(!filesRights.moveSelf || !filesRights.moveAlien) &&
!filesRights.copyFromPersonal
) {
if (!canCopy) {
folderOptions = this.removeOptions(folderOptions, ["copy-to"]);
}
if (!canCreateCopy) {
folderOptions = this.removeOptions(folderOptions, ["copy"]);
}
if (!canMove && !canCopy && !canCreateCopy) {
folderOptions = this.removeOptions(folderOptions, ["move"]);
}
if (item.rootFolderType === FolderType.Archive) {
folderOptions = this.removeOptions(folderOptions, [
"move",
"move-to",
"copy-to",
"rename",
"change-thirdparty-info",
"separator2",
"delete",
]);
}
// if (item.rootFolderType === FolderType.Archive) {
// folderOptions = this.removeOptions(folderOptions, [
// "change-thirdparty-info",
// "separator2",
// ]);
// }
if (isPrivacyFolder) {
folderOptions = this.removeOptions(folderOptions, [
"sharing-settings",
"copy",
"copy-to",
]);
if (!isDesktopClient) {
folderOptions = this.removeOptions(folderOptions, ["rename"]);
}
}
// if (isPrivacyFolder) {
// folderOptions = this.removeOptions(folderOptions, [
// // "sharing-settings",
// ]);
// }
if (isRecycleBinFolder) {
folderOptions = this.removeOptions(folderOptions, [
"open",
"link-for-portal-users",
"sharing-settings",
"move",
"move-to",
"copy-to",
// "link-for-portal-users",
// "sharing-settings",
"mark-read",
"rename",
"separator0",
"separator1",
]);
@ -1534,52 +1487,43 @@ class FilesStore {
folderOptions = this.removeOptions(folderOptions, ["mark-read"]);
}
if (isThirdPartyFolder) {
folderOptions = this.removeOptions(folderOptions, ["move-to"]);
if (isThirdPartyFolder && isDesktopClient)
folderOptions = this.removeOptions(folderOptions, ["separator2"]);
if (isDesktopClient) {
folderOptions = this.removeOptions(folderOptions, [
"separator2",
"delete",
]);
}
} else {
folderOptions = this.removeOptions(folderOptions, [
"change-thirdparty-info",
]);
}
// if (!isThirdPartyFolder)
// folderOptions = this.removeOptions(folderOptions, [
// "change-thirdparty-info",
// ]);
if (isThirdPartyItem) {
folderOptions = this.removeOptions(folderOptions, ["owner-change"]);
// if (isThirdPartyItem) {
// folderOptions = this.removeOptions(folderOptions, ["owner-change"]);
if (isShareFolder) {
folderOptions = this.removeOptions(folderOptions, [
"change-thirdparty-info",
]);
} else {
if (isDesktopClient) {
folderOptions = this.removeOptions(folderOptions, [
"change-thirdparty-info",
]);
}
// if (isShareFolder) {
// folderOptions = this.removeOptions(folderOptions, [
// "change-thirdparty-info",
// ]);
// } else {
// if (isDesktopClient) {
// folderOptions = this.removeOptions(folderOptions, [
// "change-thirdparty-info",
// ]);
// }
folderOptions = this.removeOptions(folderOptions, ["remove"]);
// folderOptions = this.removeOptions(folderOptions, ["remove"]);
if (!item) {
//For damaged items
folderOptions = this.removeOptions(folderOptions, [
"open",
"download",
"copy-to",
"rename",
]);
}
}
} else {
folderOptions = this.removeOptions(folderOptions, [
"change-thirdparty-info",
]);
}
// if (!item) {
// //For damaged items
// folderOptions = this.removeOptions(folderOptions, [
// "open",
// "download",
// ]);
// }
// }
// } else {
// folderOptions = this.removeOptions(folderOptions, [
// "change-thirdparty-info",
// ]);
// }
if (!(isMyFolder && (this.filterType || this.filterSearch))) {
folderOptions = this.removeOptions(folderOptions, ["open-location"]);
@ -2321,10 +2265,10 @@ class FilesStore {
);
}
get isThirdPartyRootSelection() {
const withProvider = this.selection.find((x) => x.providerKey);
return withProvider && withProvider.rootFolderId === withProvider.id;
}
// get isThirdPartyRootSelection() {
// const withProvider = this.selection.find((x) => x.providerKey);
// return withProvider && withProvider.rootFolderId === withProvider.id;
// }
get isThirdPartySelection() {
const withProvider = this.selection.find((x) => x.providerKey);
@ -2750,11 +2694,15 @@ class FilesStore {
}
get roomsForRestore() {
return this.folders.filter((f) => getRoomRoleActions(f.access).archive);
return this.folders.filter(
(f) => getArchiveRoomRoleActions(f.access).restore
);
}
get roomsForDelete() {
return this.folders.filter((f) => getRoomRoleActions(f.access).delete);
return this.folders.filter(
(f) => getArchiveRoomRoleActions(f.access).delete
);
}
}

View File

@ -6,6 +6,7 @@ import { FileStatus } from "@docspace/common/constants";
class VersionHistoryStore {
isVisible = false;
fileId = null;
fileAccess = null;
versions = null;
filesStore = null;
showProgressBar = false;
@ -61,7 +62,9 @@ class VersionHistoryStore {
setVerHistoryFileId = (fileId) => {
this.fileId = fileId;
};
setVerHistoryFileAccess = (access) => {
this.fileAccess = access;
};
setVersions = (versions) => {
this.versions = versions;
};
@ -90,9 +93,11 @@ class VersionHistoryStore {
this.versions = versions;
};
fetchFileVersions = (fileId) => {
fetchFileVersions = (fileId, access) => {
if (this.fileId !== fileId || !this.versions) {
this.setVerHistoryFileId(fileId);
this.setVerHistoryFileAccess(access);
return api.files
.getFileVersionInfo(fileId)
.then((versions) => this.setVerHistoryFileVersions(versions));

View File

@ -36,8 +36,6 @@ const oformsStore = new OformsStore(authStore);
const selectedFolderStore = new SelectedFolderStore(authStore.settingsStore);
const accessRightsStore = new AccessRightsStore(authStore, selectedFolderStore);
const paymentStore = new PaymentStore();
const wizardStore = new WizardStore();
const setupStore = new SettingsSetupStore();
@ -48,6 +46,13 @@ const bannerStore = new BannerStore();
const ssoStore = new SsoFormStore();
const tagsStore = new TagsStore();
const treeFoldersStore = new TreeFoldersStore(selectedFolderStore);
const settingsStore = new SettingsStore(thirdPartyStore, treeFoldersStore);
const accessRightsStore = new AccessRightsStore(authStore, selectedFolderStore);
const peopleStore = new PeopleStore(
authStore,
authStore.infoPanelStore,
@ -55,11 +60,6 @@ const peopleStore = new PeopleStore(
accessRightsStore
);
const tagsStore = new TagsStore();
const treeFoldersStore = new TreeFoldersStore(selectedFolderStore);
const settingsStore = new SettingsStore(thirdPartyStore, treeFoldersStore);
const filesStore = new FilesStore(
authStore,
selectedFolderStore,

View File

@ -0,0 +1,95 @@
export const ArchiveFilesActions = Object.freeze({
create: false,
load: false,
edit: false,
fillForm: false,
peerReview: false,
commenting: false,
block: false,
viewVersionHistory: false,
changeVersionHistory: false,
viewContent: false,
viewComments: false,
copyAtBuffer: false,
printing: false,
download: false,
deleteSelf: false,
moveSelf: false,
deleteAlien: false,
moveAlien: false,
rename: false,
copyToPersonal: false,
saveAsForm: false,
canCopy: false,
canDuplicate: false,
});
export const OwnerArchiveFilesActions = Object.freeze({
...ArchiveFilesActions,
viewVersionHistory: true,
viewContent: true,
viewComments: true,
copyAtBuffer: true,
printing: true,
download: true,
copyToPersonal: true,
canCopy: true,
});
export const RoomAdminArchiveFilesActions = Object.freeze({
...ArchiveFilesActions,
viewVersionHistory: true,
viewContent: true,
viewComments: true,
copyAtBuffer: true,
printing: true,
download: true,
copyToPersonal: true,
canCopy: true,
});
export const EditorArchiveFilesActions = Object.freeze({
...ArchiveFilesActions,
viewVersionHistory: true,
viewContent: true,
viewComments: true,
copyAtBuffer: true,
printing: true,
download: true,
});
export const FormFillerArchiveFilesActions = Object.freeze({
...ArchiveFilesActions,
viewContent: true,
viewComments: true,
copyAtBuffer: true,
printing: true,
download: true,
});
export const ReviewerArchiveFilesActions = Object.freeze({
...ArchiveFilesActions,
viewContent: true,
viewComments: true,
copyAtBuffer: true,
printing: true,
download: true,
});
export const CommentatorArchiveFilesActions = Object.freeze({
...ArchiveFilesActions,
viewContent: true,
viewComments: true,
copyAtBuffer: true,
printing: true,
download: true,
});
export const ViewerArchiveFilesActions = Object.freeze({
...ArchiveFilesActions,
viewContent: true,
viewComments: true,
copyAtBuffer: true,
printing: true,
download: true,
});

View File

@ -8,6 +8,7 @@ export const ArchiveRoomsActions = Object.freeze({
deleteUsers: false,
restore: false,
delete: false,
canPin: false,
});
export const OwnerArchiveRoomsActions = Object.freeze({

View File

@ -19,6 +19,9 @@ export const FilesActions = Object.freeze({
moveAlien: false,
rename: false,
copyFromPersonal: false,
saveAsForm: false,
canCopy: false,
canDuplicate: false,
});
export const OwnerFilesActions = Object.freeze({
@ -43,6 +46,9 @@ export const OwnerFilesActions = Object.freeze({
moveAlien: true,
rename: true,
copyFromPersonal: true,
saveAsForm: true,
canCopy: true,
canDuplicate: true,
});
export const RoomAdminFilesActions = Object.freeze({
@ -67,6 +73,9 @@ export const RoomAdminFilesActions = Object.freeze({
moveAlien: true,
rename: true,
copyFromPersonal: true,
saveAsForm: true,
canCopy: true,
canDuplicate: true,
});
export const EditorFilesActions = Object.freeze({

View File

@ -8,6 +8,7 @@ export const RoomsActions = Object.freeze({
deleteUsers: false,
archive: false,
delete: false,
canPin: true,
});
export const OwnerRoomsActions = Object.freeze({
@ -20,7 +21,6 @@ export const OwnerRoomsActions = Object.freeze({
viewInfo: true,
deleteUsers: true,
archive: true,
delete: true,
});
export const RoomAdminRoomsActions = Object.freeze({

View File

@ -33,6 +33,17 @@ import {
ViewerFilesActions,
} from "./Files";
import {
ArchiveFilesActions,
OwnerArchiveFilesActions,
RoomAdminArchiveFilesActions,
EditorArchiveFilesActions,
FormFillerArchiveFilesActions,
ReviewerArchiveFilesActions,
CommentatorArchiveFilesActions,
ViewerArchiveFilesActions,
} from "./ArchiveFiles";
import {
OwnerAccountsActions,
DocSpaceAdminAccountsActions,
@ -105,6 +116,28 @@ export const getArchiveRoomRoleActions = (access) => {
}
};
export const getArchiveFileRoleActions = (access) => {
switch (access) {
case ShareAccessRights.None:
case ShareAccessRights.FullAccess:
return OwnerArchiveFilesActions;
case ShareAccessRights.RoomManager:
return RoomAdminArchiveFilesActions;
case ShareAccessRights.Editing:
return EditorArchiveFilesActions;
case ShareAccessRights.FormFilling:
return FormFillerArchiveFilesActions;
case ShareAccessRights.Review:
return ReviewerArchiveFilesActions;
case ShareAccessRights.Comment:
return CommentatorArchiveFilesActions;
case ShareAccessRights.ReadOnly:
return ViewerArchiveFilesActions;
default:
return ArchiveFilesActions;
}
};
export const getAccountsTypeActions = (isAdmin, isOwner) => {
if (isOwner) return OwnerAccountsActions;

View File

@ -26,7 +26,10 @@ import { canConvert } from "../helpers/utils";
import { assign } from "@docspace/common/utils";
import toastr from "@docspace/components/toast/toastr";
import { DocumentEditor } from "@onlyoffice/document-editor-react";
import { getFileRoleActions } from "@docspace/common/utils/actions";
import {
getArchiveFileRoleActions,
getFileRoleActions,
} from "@docspace/common/utils/actions";
toast.configure();
@ -94,13 +97,16 @@ function Editor({
filesSettings,
}) {
const fileInfo = config?.file;
isArchiveFolderRoot =
fileInfo && fileInfo.rootFolderType === FolderType.Archive;
const { t } = useTranslation(["Editor", "Common"]);
if (fileInfo) {
userAccessRights = getFileRoleActions(fileInfo.access);
userAccessRights = isArchiveFolderRoot
? getArchiveFileRoleActions(fileInfo.access)
: getFileRoleActions(fileInfo.access);
}
useEffect(() => {
if (error && mfReady) {
@ -532,7 +538,7 @@ function Editor({
);
}
let onRequestSharingSettings,
let //onRequestSharingSettings,
onRequestRename,
onRequestSaveAs,
onRequestInsertImage,
@ -545,7 +551,7 @@ function Editor({
// onRequestSharingSettings = onSDKRequestSharingSettings;
// }
if (userAccessRights.rename && !isArchiveFolderRoot) {
if (userAccessRights.rename) {
onRequestRename = onSDKRequestRename;
}
@ -563,7 +569,7 @@ function Editor({
onRequestCompareFile = onSDKRequestCompareFile;
}
if (userAccessRights.changeVersionHistory && !isArchiveFolderRoot) {
if (userAccessRights.changeVersionHistory) {
onRequestRestore = onSDKRequestRestore;
}