Merge pull request #1055 from ONLYOFFICE/bugfix/fixed-info-panel-tabs-view

Bugfix/fixed info panel tabs view
This commit is contained in:
Nikita Gopienko 2022-11-18 14:10:34 +03:00 committed by GitHub
commit 5e05093a89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 { StyledInfoPanelHeader } from "./styles/common";
import { FolderType } from "@docspace/common/constants"; import { FolderType } from "@docspace/common/constants";
import { getArchiveRoomRoleActions } from "@docspace/common/utils/actions";
const InfoPanelHeaderContent = (props) => { const InfoPanelHeaderContent = (props) => {
const { const {
@ -32,6 +33,7 @@ const InfoPanelHeaderContent = (props) => {
getIsAccounts, getIsAccounts,
isRootFolder, isRootFolder,
rootFolderType, rootFolderType,
canViewUsers,
} = props; } = props;
const isRooms = getIsRooms(); const isRooms = getIsRooms();
@ -73,7 +75,9 @@ const InfoPanelHeaderContent = (props) => {
]; ];
const roomsSubmenu = isArchiveRoot const roomsSubmenu = isArchiveRoot
? [{ ...submenuData[0] }, { ...submenuData[2] }] ? canViewUsers(selection)
? [{ ...submenuData[0] }, { ...submenuData[2] }]
: [{ ...submenuData[2] }]
: [...submenuData]; : [...submenuData];
const personalSubmenu = [submenuData[1], submenuData[2]]; 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 { const {
selection, selection,
setIsVisible, setIsVisible,
@ -141,6 +145,7 @@ export default inject(({ auth, selectedFolderStore }) => {
getIsAccounts, getIsAccounts,
} = auth.infoPanelStore; } = auth.infoPanelStore;
const { isRootFolder, rootFolderType } = selectedFolderStore; const { isRootFolder, rootFolderType } = selectedFolderStore;
const { canViewUsers } = accessRightsStore;
return { return {
selection, selection,
@ -155,6 +160,7 @@ export default inject(({ auth, selectedFolderStore }) => {
isRootFolder, isRootFolder,
rootFolderType, rootFolderType,
canViewUsers,
}; };
})( })(
withTranslation(["Common", "InfoPanel"])( withTranslation(["Common", "InfoPanel"])(

View File

@ -9,6 +9,7 @@ import {
import { import {
getFileRoleActions, getFileRoleActions,
getRoomRoleActions, getRoomRoleActions,
getArchiveRoomRoleActions,
} from "@docspace/common/utils/actions"; } from "@docspace/common/utils/actions";
class AccessRightsStore { class AccessRightsStore {
@ -207,6 +208,19 @@ class AccessRightsStore {
return false; 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; export default AccessRightsStore;

View File

@ -23,7 +23,7 @@ class InfoPanelStore {
selection = null; selection = null;
selectionParentRoom = null; selectionParentRoom = null;
roomsView = "members"; roomsView = "details";
fileView = "history"; fileView = "history";
authStore = null; 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, ViewerRoomsActions,
} from "./Rooms"; } from "./Rooms";
import {
ArchiveRoomsActions,
OwnerArchiveRoomsActions,
RoomAdminArchiveRoomsActions,
EditorArchiveRoomsActions,
FormFillerArchiveRoomsActions,
ReviewerArchiveRoomsActions,
CommentatorArchiveRoomsActions,
ViewerArchiveRoomsActions,
} from "./ArchiveRoom";
import { import {
FilesActions, FilesActions,
OwnerFilesActions, 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) => { export const getAccountsTypeActions = (isAdmin, isOwner) => {
if (isOwner) return OwnerAccountsActions; if (isOwner) return OwnerAccountsActions;