From 4900d0ad1878bf1c7b19f09e34c5ff16ac0a3eca Mon Sep 17 00:00:00 2001 From: Tatiana Lopaeva Date: Tue, 9 Jan 2024 14:36:56 +0300 Subject: [PATCH] Web: Hiding the quota item for a user with room admin rights. --- .../client/src/components/SpaceQuota/index.js | 3 +- .../InfoPanel/Body/views/Accounts/index.js | 33 +++++++++++++------ .../AccountsBody/RowView/userContent.js | 8 ++--- .../AccountsBody/TableView/TableHeader.js | 9 ++--- .../AccountsBody/TableView/TableRow.js | 25 +++++++++++--- .../Section/Body/TableView/TableHeader.js | 15 +++------ .../TableView/sub-components/RoomsRowData.js | 9 +++-- .../src/pages/Home/Section/Filter/index.js | 14 ++++---- packages/common/store/CurrentQuotaStore.js | 6 ++++ 9 files changed, 79 insertions(+), 43 deletions(-) diff --git a/packages/client/src/components/SpaceQuota/index.js b/packages/client/src/components/SpaceQuota/index.js index e21344bd68..97befe1ac0 100644 --- a/packages/client/src/components/SpaceQuota/index.js +++ b/packages/client/src/components/SpaceQuota/index.js @@ -27,6 +27,7 @@ const SpaceQuota = (props) => { getPeopleListItem, setSelection, setSelected, + type, } = props; const [isLoading, setIsLoading] = useState(false); @@ -72,7 +73,7 @@ const SpaceQuota = (props) => { onSuccess && onSuccess(users); setIsLoading(false); - if (!needResetSelection) { + if (type === "user" && !needResetSelection) { const user = getPeopleListItem(users[0]); setSelection(user); diff --git a/packages/client/src/pages/Home/InfoPanel/Body/views/Accounts/index.js b/packages/client/src/pages/Home/InfoPanel/Body/views/Accounts/index.js index 885dbc4dcf..044fbac950 100644 --- a/packages/client/src/pages/Home/InfoPanel/Body/views/Accounts/index.js +++ b/packages/client/src/pages/Home/InfoPanel/Body/views/Accounts/index.js @@ -20,6 +20,8 @@ const Accounts = ({ canChangeUserType, setSelection, getPeopleListItem, + + showStorageInfo, }) => { const [statusLabel, setStatusLabel] = React.useState(""); const [isLoading, setIsLoading] = React.useState(false); @@ -215,16 +217,24 @@ const Accounts = ({ > {statusText} - - {t("Common:Storage")} - - + {showStorageInfo && ( + <> + + {t("Common:Storage")} + + {" "} + + )} {/* {t("Common:Room")} @@ -242,7 +252,9 @@ export default inject(({ auth, peopleStore, accessRightsStore }) => { const { canChangeUserType } = accessRightsStore; const { setSelection } = auth.infoPanelStore; + const { currentQuotaStore } = auth; + const { showStorageInfo } = currentQuotaStore; return { isOwner, isAdmin, @@ -252,6 +264,7 @@ export default inject(({ auth, peopleStore, accessRightsStore }) => { loading: usersStore.operationRunning, getPeopleListItem: usersStore.getPeopleListItem, setSelection, + showStorageInfo, }; })( withTranslation([ diff --git a/packages/client/src/pages/Home/Section/AccountsBody/RowView/userContent.js b/packages/client/src/pages/Home/Section/AccountsBody/RowView/userContent.js index e3af53baef..bbb42c0eaa 100644 --- a/packages/client/src/pages/Home/Section/AccountsBody/RowView/userContent.js +++ b/packages/client/src/pages/Home/Section/AccountsBody/RowView/userContent.js @@ -71,7 +71,7 @@ const UserContent = ({ standalone, isDefaultUsersQuotaSet, - isStatisticsAvailable, + showStorageInfo, }) => { const { displayName, @@ -161,7 +161,7 @@ const UserContent = ({ {email} - {isStatisticsAvailable && ( + {showStorageInfo && ( { const { currentQuotaStore } = auth; - const { isDefaultUsersQuotaSet, isStatisticsAvailable } = currentQuotaStore; + const { isDefaultUsersQuotaSet, showStorageInfo } = currentQuotaStore; return { isDefaultUsersQuotaSet, - isStatisticsAvailable, + showStorageInfo, }; })(withTranslation(["People", "Common"])(observer(UserContent))); diff --git a/packages/client/src/pages/Home/Section/AccountsBody/TableView/TableHeader.js b/packages/client/src/pages/Home/Section/AccountsBody/TableView/TableHeader.js index 14b777194a..ed3bdb3840 100644 --- a/packages/client/src/pages/Home/Section/AccountsBody/TableView/TableHeader.js +++ b/packages/client/src/pages/Home/Section/AccountsBody/TableView/TableHeader.js @@ -13,7 +13,7 @@ class PeopleTableHeader extends React.Component { super(props); const { t } = props; - const { isDefaultUsersQuotaSet, isStatisticsAvailable } = this.props; + const { isDefaultUsersQuotaSet, showStorageInfo } = this.props; const defaultColumns = [ { @@ -54,7 +54,7 @@ class PeopleTableHeader extends React.Component { }, ]; - isStatisticsAvailable && + showStorageInfo && defaultColumns.push({ key: "Storage", title: isDefaultUsersQuotaSet @@ -195,7 +195,8 @@ export default inject(({ auth, peopleStore, clientLoadingStore }) => { const { isVisible: infoPanelVisible } = auth.infoPanelStore; const { withPaging } = auth.settingsStore; const { currentQuotaStore } = auth; - const { isDefaultUsersQuotaSet, isStatisticsAvailable } = currentQuotaStore; + + const { isDefaultUsersQuotaSet, showStorageInfo } = currentQuotaStore; return { filter, @@ -205,7 +206,7 @@ export default inject(({ auth, peopleStore, clientLoadingStore }) => { infoPanelVisible, withPaging, isDefaultUsersQuotaSet, - isStatisticsAvailable, + showStorageInfo, }; })( withTranslation(["People", "Common", "PeopleTranslations"])( diff --git a/packages/client/src/pages/Home/Section/AccountsBody/TableView/TableRow.js b/packages/client/src/pages/Home/Section/AccountsBody/TableView/TableRow.js index b060d5936c..71ceba5c37 100644 --- a/packages/client/src/pages/Home/Section/AccountsBody/TableView/TableRow.js +++ b/packages/client/src/pages/Home/Section/AccountsBody/TableView/TableRow.js @@ -1,6 +1,7 @@ import React from "react"; import styled, { css } from "styled-components"; import { withTranslation } from "react-i18next"; +import { inject, observer } from "mobx-react"; import TableRow from "@docspace/components/table-container/TableRow"; import TableCell from "@docspace/components/table-container/TableCell"; @@ -218,6 +219,8 @@ const PeopleTableRow = (props) => { hideColumns, standalone, value, + + showStorageInfo, } = props; const { @@ -516,14 +519,26 @@ const PeopleTableRow = (props) => { - - - + {showStorageInfo && ( + + + + )} ); }; -export default withContent( - withTranslation(["People", "Common", "Settings"])(PeopleTableRow) +export default inject(({ auth }) => { + const { currentQuotaStore } = auth; + + const { showStorageInfo } = currentQuotaStore; + + return { + showStorageInfo, + }; +})( + withContent( + withTranslation(["People", "Common", "Settings"])(observer(PeopleTableRow)) + ) ); diff --git a/packages/client/src/pages/Home/Section/Body/TableView/TableHeader.js b/packages/client/src/pages/Home/Section/Body/TableView/TableHeader.js index 6f9292f7d6..233154a94a 100644 --- a/packages/client/src/pages/Home/Section/Body/TableView/TableHeader.js +++ b/packages/client/src/pages/Home/Section/Body/TableView/TableHeader.js @@ -24,9 +24,7 @@ class FilesTableHeader extends React.Component { columnInfoPanelStorageName, isPublicRoom, isDefaultRoomsQuotaSet, - isStatisticsAvailable, - isOwner, - isAdmin, + showStorageInfo, } = this.props; const defaultColumns = []; @@ -89,8 +87,7 @@ class FilesTableHeader extends React.Component { }, ]; - isStatisticsAvailable && - (isOwner || isAdmin) && + showStorageInfo && columns.push({ key: "Storage", title: isDefaultRoomsQuotaSet @@ -473,10 +470,10 @@ export default inject( clientLoadingStore, }) => { const { currentQuotaStore } = auth; - const { isDefaultRoomsQuotaSet, isStatisticsAvailable } = currentQuotaStore; + const { isDefaultRoomsQuotaSet, showStorageInfo } = currentQuotaStore; const { isVisible: infoPanelVisible } = auth.infoPanelStore; - const { isOwner, isAdmin } = auth.userStore.user; + const { isHeaderChecked, @@ -579,9 +576,7 @@ export default inject( isPublicRoom, publicRoomKey, isDefaultRoomsQuotaSet, - isStatisticsAvailable, - isOwner, - isAdmin, + showStorageInfo, }; } )( diff --git a/packages/client/src/pages/Home/Section/Body/TableView/sub-components/RoomsRowData.js b/packages/client/src/pages/Home/Section/Body/TableView/sub-components/RoomsRowData.js index 7da83c3e52..23cf99ee8b 100644 --- a/packages/client/src/pages/Home/Section/Body/TableView/sub-components/RoomsRowData.js +++ b/packages/client/src/pages/Home/Section/Body/TableView/sub-components/RoomsRowData.js @@ -19,6 +19,7 @@ const RoomsRowDataComponent = (props) => { roomColumnTagsIsEnabled, roomColumnActivityIsEnabled, roomQuotaColumnIsEnable, + showStorageInfo, dragStyles, selectionProp, @@ -128,7 +129,7 @@ const RoomsRowDataComponent = (props) => { ) : (
)} - {roomQuotaColumnIsEnable ? ( + {roomQuotaColumnIsEnable && showStorageInfo ? ( @@ -160,7 +161,7 @@ const RoomsRowDataComponent = (props) => { ); }; -export default inject(({ tableStore }) => { +export default inject(({ auth, tableStore }) => { const { roomColumnTypeIsEnabled, roomColumnOwnerIsEnabled, @@ -170,6 +171,9 @@ export default inject(({ tableStore }) => { roomQuotaColumnIsEnable, } = tableStore; + const { currentQuotaStore } = auth; + + const { showStorageInfo } = currentQuotaStore; return { roomQuotaColumnIsEnable, roomColumnTypeIsEnabled, @@ -177,5 +181,6 @@ export default inject(({ tableStore }) => { roomColumnQuickButtonsIsEnabled, roomColumnTagsIsEnabled, roomColumnActivityIsEnabled, + showStorageInfo, }; })(observer(RoomsRowDataComponent)); diff --git a/packages/client/src/pages/Home/Section/Filter/index.js b/packages/client/src/pages/Home/Section/Filter/index.js index d894161d3d..6997aa0540 100644 --- a/packages/client/src/pages/Home/Section/Filter/index.js +++ b/packages/client/src/pages/Home/Section/Filter/index.js @@ -266,7 +266,7 @@ const SectionFilterContent = ({ standalone, currentDeviceType, isRoomAdmin, - isStatisticsAvailable, + showStorageInfo, isDefaultRoomsQuotaSet, }) => { const location = useLocation(); @@ -1207,7 +1207,7 @@ const SectionFilterContent = ({ if (!standalone) filterOptions.push(...accountItems); // filterOptions.push(...roomItems); filterOptions.push(...accountLoginTypeItems); - isStatisticsAvailable && + showStorageInfo && isDefaultRoomsQuotaSet && filterOptions.push(...quotaFilter); return filterOptions; @@ -1515,7 +1515,7 @@ const SectionFilterContent = ({ filterOptions.push(...thirdPartyOptions); } - isStatisticsAvailable && + showStorageInfo && isDefaultRoomsQuotaSet && filterOptions.push(...quotaFilter); } else { @@ -1687,7 +1687,7 @@ const SectionFilterContent = ({ }, ]; - isStatisticsAvailable && + showStorageInfo && accountsOptions.push({ id: "sort-quota", key: SortByFieldName.UsedSpace, @@ -1817,7 +1817,7 @@ const SectionFilterContent = ({ !hide && commonOptions.push(modifiedDate); } - if (isStatisticsAvailable && availableSort?.includes("Storage")) { + if (showStorageInfo && availableSort?.includes("Storage")) { const idx = availableSort.findIndex( (x) => x === SortByFieldName.UsedSpace ); @@ -2213,7 +2213,7 @@ export default inject( const isRooms = isRoomsFolder || isArchiveFolder; const { isVisible: infoPanelVisible } = auth.infoPanelStore; - const { isStatisticsAvailable, isDefaultRoomsQuotaSet } = currentQuotaStore; + const { showStorageInfo, isDefaultRoomsQuotaSet } = currentQuotaStore; const { filterStore, @@ -2231,7 +2231,7 @@ export default inject( return { isRoomAdmin, - isStatisticsAvailable, + showStorageInfo, isDefaultRoomsQuotaSet, user, diff --git a/packages/common/store/CurrentQuotaStore.js b/packages/common/store/CurrentQuotaStore.js index 26e3c83f89..ffb5fc07d0 100644 --- a/packages/common/store/CurrentQuotaStore.js +++ b/packages/common/store/CurrentQuotaStore.js @@ -241,6 +241,12 @@ class QuotasStore { return this.currentPortalQuota?.usersQuota?.defaultQuota; } + get showStorageInfo() { + const { user } = this.userStore; + + return this.isStatisticsAvailable && (user.isOwner || user.isAdmin); + } + setPortalQuotaValue = (res) => { this.currentPortalQuota = res; this.currentPortalQuotaFeatures = res.features;