Client: Added a bar for reaching the user limit by tariff.

This commit is contained in:
Tatiana Lopaeva 2024-08-13 13:08:26 +03:00
parent ce448f9dda
commit 92cf12621d
5 changed files with 87 additions and 9 deletions

View File

@ -14,7 +14,10 @@
"StorageQuotaHeader": "Storage space amount is about to be exceeded: {{currentValue}} / {{maxValue}}",
"StorageQuotaUserDescription": "You can remove the unnecessary files to free up disk space.",
"TenantCustomQuotaDescription": "You can remove the unnecessary files or change quota in the <1>Storage management settings.</1>",
"UserTariffAlmostReachedForAdmins": "Once the limit is reached, all users will be added with user permissions only. To be able to add further admins/power users, <1>click here</1> to upgrade your tariff plan.",
"UserTariffAlmostReached": "Once the limit is reached, all users will be added with user permissions only. To be able to add further admins/power users, contact the DocSpace administrator to upgrade the tariff plan.",
"UserQuotaHeader": "The number of admins/power users is about to be exceeded: {{currentValue}} / {{maxValue}}."
"UserTariffAlmostReachedForAdmins": "Once the limit is reached, all users will be added with User permissions only. To be able to add further admins/power users, <1>click here</1> to upgrade your tariff plan.",
"UserTariffAlmostReached": "Once the limit is reached, all users will be added with User permissions only. To be able to add further admins/power users, contact the DocSpace administrator to upgrade the tariff plan.",
"UserTariffReachedForAdmins": "All users will be added with User permissions only. To be able to add further admins/power users, <1>click here</1> to upgrade your tariff plan.",
"UserTariffReached": "All users will be added with User permissions only. To be able to add further admins/power users, contact the DocSpace administrator to upgrade the tariff plan.",
"UserQuotaHeader": "The number of admins/power users is about to be exceeded: {{currentValue}} / {{maxValue}}.",
"UserTariffLimit": "The limit is reached for the number of admins/power users: {{currentValue}} / {{maxValue}}"
}

View File

@ -78,6 +78,7 @@ const Bar = (props) => {
tenantCustomQuota,
showTenantCustomQuotaBar,
isUserTariffLimit,
} = props;
const navigate = useNavigate();
@ -87,6 +88,7 @@ const Bar = (props) => {
storageQuota: false,
tenantCustomQuota: false,
almostTariffLimitPerUser: false,
tariffLimitPerUser: false,
storageAndUserQuota: false,
storageAndRoomQuota: false,
confirmEmail: false,
@ -129,10 +131,13 @@ const Bar = (props) => {
),
}));
}
if (isAdmin || isRoomAdmin) {
setBarVisible((value) => ({
...value,
tariffLimitPerUser: !closed.includes(
QuotaBarTypes.TariffLimitPerUser,
),
almostTariffLimitPerUser: !closed.includes(
QuotaBarTypes.AlmostTariffLimitPerUser,
),
@ -158,6 +163,7 @@ const Bar = (props) => {
storageQuota: isAdmin || isPowerUser || isRoomAdmin,
tenantCustomQuota: isAdmin || isPowerUser || isRoomAdmin,
almostTariffLimitPerUser: isAdmin | isRoomAdmin,
tariffLimitPerUser: isAdmin | isRoomAdmin,
storageAndUserQuota: isAdmin,
storageAndRoomQuota: isAdmin,
confirmEmail: true,
@ -249,6 +255,12 @@ const Bar = (props) => {
almostTariffLimitPerUser: false,
}));
break;
case QuotaBarTypes.TariffLimitPerUser:
setBarVisible((value) => ({
...value,
tariffLimitPerUser: false,
}));
break;
case QuotaBarTypes.UserAndStorageQuota:
setBarVisible((value) => ({ ...value, storageAndUserQuota: false }));
break;
@ -322,6 +334,14 @@ const Bar = (props) => {
};
}
if (isUserTariffLimit && barVisible.tariffLimitPerUser) {
return {
type: QuotaBarTypes.TariffLimitPerUser,
maxValue: maxCountManagersByQuota,
currentValue: addedManagersCount,
};
}
if (
showAlmostReachedUserTariffLimit &&
barVisible.almostTariffLimitPerUser
@ -415,6 +435,7 @@ export default inject(
showUserPersonalQuotaBar,
tenantCustomQuota,
showTenantCustomQuotaBar,
isUserTariffLimit,
} = currentQuotaStore;
const { currentColorScheme, setMainBarVisible } = settingsStore;
@ -448,6 +469,7 @@ export default inject(
showUserPersonalQuotaBar,
tenantCustomQuota,
showTenantCustomQuotaBar,
isUserTariffLimit,
};
},
)(withTranslation(["Profile", "Common"])(observer(Bar)));

View File

@ -116,7 +116,55 @@ const QuotasBar = ({
/>
);
};
const getUserTariffAlmostLimit = () => {
if (!isAdmin) return t("UserTariffAlmostReached");
return (
<Trans
t={t}
i18nKey="UserTariffAlmostReachedForAdmins"
values={{
productName: t("Common:ProductName"),
}}
components={{
1: (
<Link
fontSize="12px"
fontWeight="400"
color={currentColorScheme?.main?.accent}
className="error_description_link"
onClick={onClickAction}
/>
),
}}
/>
);
};
const getUserTariffLimit = () => {
if (!isAdmin) return t("UserTariffReached");
return (
<Trans
t={t}
i18nKey="UserTariffReachedForAdmins"
values={{
productName: t("Common:ProductName"),
}}
components={{
1: (
<Link
fontSize="12px"
fontWeight="400"
color={currentColorScheme?.main?.accent}
className="error_description_link"
onClick={onClickAction}
/>
),
}}
/>
);
};
const getQuotaInfo = () => {
switch (type) {
case QuotaBarTypes.RoomQuota:
@ -154,9 +202,13 @@ const QuotasBar = ({
case QuotaBarTypes.AlmostTariffLimitPerUser:
return {
header: t("UserQuotaHeader", { currentValue, maxValue }),
description: getUserQuotaDescription(),
description: getUserTariffAlmostLimit(),
};
case QuotaBarTypes.TariffLimitPerUser:
return {
header: t("UserTariffLimit", { currentValue, maxValue }),
description: getUserTariffLimit(),
};
case QuotaBarTypes.UserAndStorageQuota:
return {
header: t("StorageAndUserHeader", { currentValue, maxValue }),

View File

@ -99,6 +99,7 @@ export const QuotaBarTypes = Object.freeze({
RoomQuota: "room-quota",
StorageQuota: "storage-quota",
AlmostTariffLimitPerUser: "user-quota",
TariffLimitPerUser: "user-quota-limit",
UserAndStorageQuota: "user-storage-quota",
RoomAndStorageQuota: "room-storage-quota",
PersonalUserQuota: "personal-user-quota",

View File

@ -276,12 +276,12 @@ class CurrentQuotasStore {
this.addedManagersCount > 1 &&
this.maxCountManagersByQuota - this.addedManagersCount <=
COUNT_FOR_SHOWING_BAR &&
this.maxCountManagersByQuota >= this.addedManagersCount
this.maxCountManagersByQuota > this.addedManagersCount
);
}
get showReachedUserTariffLimit() {
return null;
get isUserTariffLimit() {
return this.isPaidUserLimit;
}
get isPaidUserLimit() {