Web: Hiding the quota item for a user with room admin rights.

This commit is contained in:
Tatiana Lopaeva 2024-01-09 14:36:56 +03:00
parent e757fdf203
commit 4900d0ad18
9 changed files with 79 additions and 43 deletions

View File

@ -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);

View File

@ -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}
</Text>
<Text className={"info_field"} noSelect title={t("Common:Storage")}>
{t("Common:Storage")}
</Text>
<SpaceQuota
type="user"
item={selection}
className="type-combobox"
onSuccess={onSuccess}
onAbort={onAbort}
/>
{showStorageInfo && (
<>
<Text
className={"info_field"}
noSelect
title={t("Common:Storage")}
>
{t("Common:Storage")}
</Text>
<SpaceQuota
type="user"
item={selection}
className="type-combobox"
onSuccess={onSuccess}
onAbort={onAbort}
/>{" "}
</>
)}
{/* <Text className={"info_field"} noSelect title={t("Common:Room")}>
{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([

View File

@ -71,7 +71,7 @@ const UserContent = ({
standalone,
isDefaultUsersQuotaSet,
isStatisticsAvailable,
showStorageInfo,
}) => {
const {
displayName,
@ -161,7 +161,7 @@ const UserContent = ({
{email}
</Link>
{isStatisticsAvailable && (
{showStorageInfo && (
<Link
containerMinWidth="140px"
containerWidth="17%"
@ -180,9 +180,9 @@ const UserContent = ({
export default inject(({ auth }) => {
const { currentQuotaStore } = auth;
const { isDefaultUsersQuotaSet, isStatisticsAvailable } = currentQuotaStore;
const { isDefaultUsersQuotaSet, showStorageInfo } = currentQuotaStore;
return {
isDefaultUsersQuotaSet,
isStatisticsAvailable,
showStorageInfo,
};
})(withTranslation(["People", "Common"])(observer(UserContent)));

View File

@ -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"])(

View File

@ -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) => {
</Link>
</TableCell>
<TableCell className={"table-cell_Storage/Quota"}>
<SpaceQuota hideColumns={hideColumns} item={item} type="user" />
</TableCell>
{showStorageInfo && (
<TableCell className={"table-cell_Storage/Quota"}>
<SpaceQuota hideColumns={hideColumns} item={item} type="user" />
</TableCell>
)}
</StyledPeopleRow>
</StyledWrapper>
);
};
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))
)
);

View File

@ -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,
};
}
)(

View File

@ -19,6 +19,7 @@ const RoomsRowDataComponent = (props) => {
roomColumnTagsIsEnabled,
roomColumnActivityIsEnabled,
roomQuotaColumnIsEnable,
showStorageInfo,
dragStyles,
selectionProp,
@ -128,7 +129,7 @@ const RoomsRowDataComponent = (props) => {
) : (
<div />
)}
{roomQuotaColumnIsEnable ? (
{roomQuotaColumnIsEnable && showStorageInfo ? (
<TableCell className={"table-cell_Storage/Quota"}>
<SpaceQuota item={item} type="room" />
</TableCell>
@ -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));

View File

@ -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,

View File

@ -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;