Merge branch 'develop' into bugfix/additional-resources

This commit is contained in:
Viktor Fomin 2022-11-18 16:11:14 +05:00
commit 64469e0bb8
5 changed files with 108 additions and 3 deletions

View File

@ -18,6 +18,7 @@ import { ColorTheme, ThemeType } from "@docspace/common/components/ColorTheme";
import { StyledInfoPanelHeader } from "./styles/common";
import { FolderType } from "@docspace/common/constants";
import { getArchiveRoomRoleActions } from "@docspace/common/utils/actions";
const InfoPanelHeaderContent = (props) => {
const {
@ -32,6 +33,7 @@ const InfoPanelHeaderContent = (props) => {
getIsAccounts,
isRootFolder,
rootFolderType,
canViewUsers,
} = props;
const isRooms = getIsRooms();
@ -73,7 +75,9 @@ const InfoPanelHeaderContent = (props) => {
];
const roomsSubmenu = isArchiveRoot
? [{ ...submenuData[0] }, { ...submenuData[2] }]
? canViewUsers(selection)
? [{ ...submenuData[0] }, { ...submenuData[2] }]
: [{ ...submenuData[2] }]
: [...submenuData];
const personalSubmenu = [submenuData[1], submenuData[2]];
@ -128,7 +132,7 @@ const InfoPanelHeaderContent = (props) => {
);
};
export default inject(({ auth, selectedFolderStore }) => {
export default inject(({ auth, selectedFolderStore, accessRightsStore }) => {
const {
selection,
setIsVisible,
@ -141,6 +145,7 @@ export default inject(({ auth, selectedFolderStore }) => {
getIsAccounts,
} = auth.infoPanelStore;
const { isRootFolder, rootFolderType } = selectedFolderStore;
const { canViewUsers } = accessRightsStore;
return {
selection,
@ -155,6 +160,7 @@ export default inject(({ auth, selectedFolderStore }) => {
isRootFolder,
rootFolderType,
canViewUsers,
};
})(
withTranslation(["Common", "InfoPanel"])(

View File

@ -9,6 +9,7 @@ import {
import {
getFileRoleActions,
getRoomRoleActions,
getArchiveRoomRoleActions,
} from "@docspace/common/utils/actions";
class AccessRightsStore {
@ -207,6 +208,19 @@ class AccessRightsStore {
return false;
};
canViewUsers = (room) => {
const { rootFolderType } = this.selectedFolderStore;
if (!room) return false;
const options =
rootFolderType === FolderType.Archive
? getArchiveRoomRoleActions(room.access)
: getRoomRoleActions(room.access);
return options.viewUsers;
};
}
export default AccessRightsStore;

View File

@ -23,7 +23,7 @@ class InfoPanelStore {
selection = null;
selectionParentRoom = null;
roomsView = "members";
roomsView = "details";
fileView = "history";
authStore = null;

View File

@ -0,0 +1,52 @@
export const ArchiveRoomsActions = Object.freeze({
edit: false,
inviteUsers: false,
changeUserRole: false,
viewUsers: false,
viewHistory: false,
viewInfo: false,
deleteUsers: false,
restore: false,
delete: false,
});
export const OwnerArchiveRoomsActions = Object.freeze({
...ArchiveRoomsActions,
viewUsers: true,
viewInfo: true,
deleteUsers: true,
restore: true,
delete: true,
});
export const RoomAdminArchiveRoomsActions = Object.freeze({
...ArchiveRoomsActions,
viewUsers: true,
viewInfo: true,
deleteUsers: true,
});
export const EditorArchiveRoomsActions = Object.freeze({
...ArchiveRoomsActions,
viewInfo: true,
});
export const FormFillerArchiveRoomsActions = Object.freeze({
...ArchiveRoomsActions,
viewInfo: true,
});
export const ReviewerArchiveRoomsActions = Object.freeze({
...ArchiveRoomsActions,
viewInfo: true,
});
export const CommentatorArchiveRoomsActions = Object.freeze({
...ArchiveRoomsActions,
viewInfo: true,
});
export const ViewerArchiveRoomsActions = Object.freeze({
...ArchiveRoomsActions,
viewInfo: true,
});

View File

@ -11,6 +11,17 @@ import {
ViewerRoomsActions,
} from "./Rooms";
import {
ArchiveRoomsActions,
OwnerArchiveRoomsActions,
RoomAdminArchiveRoomsActions,
EditorArchiveRoomsActions,
FormFillerArchiveRoomsActions,
ReviewerArchiveRoomsActions,
CommentatorArchiveRoomsActions,
ViewerArchiveRoomsActions,
} from "./ArchiveRoom";
import {
FilesActions,
OwnerFilesActions,
@ -72,6 +83,28 @@ export const getFileRoleActions = (access) => {
}
};
export const getArchiveRoomRoleActions = (access) => {
switch (access) {
case ShareAccessRights.None:
case ShareAccessRights.FullAccess:
return OwnerArchiveRoomsActions;
case ShareAccessRights.RoomManager:
return RoomAdminArchiveRoomsActions;
case ShareAccessRights.Editing:
return EditorArchiveRoomsActions;
case ShareAccessRights.FormFilling:
return FormFillerArchiveRoomsActions;
case ShareAccessRights.Review:
return ReviewerArchiveRoomsActions;
case ShareAccessRights.Comment:
return CommentatorArchiveRoomsActions;
case ShareAccessRights.ReadOnly:
return ViewerArchiveRoomsActions;
default:
return ArchiveRoomsActions;
}
};
export const getAccountsTypeActions = (isAdmin, isOwner) => {
if (isOwner) return OwnerAccountsActions;