Client: Updated bar for storage tenant quota.

This commit is contained in:
Tatiana Lopaeva 2024-08-14 15:36:41 +03:00
parent 93dd41ff7e
commit f2997597fe
5 changed files with 62 additions and 21 deletions

View File

@ -23,6 +23,7 @@
"StorageTariffLimit": "The limit is reached for storage space: {{currentValue}} / {{maxValue}}",
"RemoveFilesOrClickToUpgrade": "Remove the unnecessary files or <1>click here</1> to upgrade your tariff plan.",
"RemoveFilesOrContactToUpgrade": "Remove the unnecessary files or contact the {{productName}} administrator to upgrade the tariff plan.",
"RemoveFilesOrContactToUpgradeQuota": "Remove the unnecessary files or contact the {{productName}} administrator to increase the storage quota.",
"StorageQuotaPerUserExceeded": "Storage quota per user exceeded",
"PersonalStorageQuotaExceed": "Your personal storage quota exceeded"
}

View File

@ -79,6 +79,8 @@ const Bar = (props) => {
tenantCustomQuota,
isStorageTariffLimit,
isUserTariffLimit,
isStorageQuotaAlmostLimit,
isStorageQuotaLimit,
} = props;
const navigate = useNavigate();
@ -87,7 +89,8 @@ const Bar = (props) => {
roomQuota: false,
storageTariff: false,
storageTariffLimit: false,
tenantCustomQuota: false,
storageQuota: false,
storageQuotaLimit: false,
usersTariff: false,
usersTariffLimit: false,
storageAndUserQuota: false,
@ -148,8 +151,8 @@ const Bar = (props) => {
storageTariffLimit: !closed.includes(
QuotaBarTypes.StorageTariffLimit,
),
tenantCustomQuota: !closed.includes(QuotaBarTypes.TenantCustomQuota),
storageQuota: !closed.includes(QuotaBarTypes.StorageQuota),
storageQuotaLimit: !closed.includes(QuotaBarTypes.StorageQuotaLimit),
personalUserQuota: !closed.includes(QuotaBarTypes.PersonalUserQuota),
}));
}
@ -165,7 +168,8 @@ const Bar = (props) => {
roomQuota: isAdmin,
storageTariff: isAdmin || isPowerUser || isRoomAdmin,
storageTariffLimit: isAdmin || isPowerUser || isRoomAdmin,
tenantCustomQuota: isAdmin || isPowerUser || isRoomAdmin,
storageQuota: isAdmin || isPowerUser || isRoomAdmin,
storageQuotaLimit: isAdmin || isPowerUser || isRoomAdmin,
usersTariff: isAdmin | isRoomAdmin,
usersTariffLimit: isAdmin | isRoomAdmin,
storageAndUserQuota: isAdmin,
@ -216,7 +220,7 @@ const Bar = (props) => {
};
const onClickQuota = (type, e) => {
type === QuotaBarTypes.TenantCustomQuota ||
type === QuotaBarTypes.StorageQuota ||
type === QuotaBarTypes.PersonalUserQuota
? onClickTenantCustomQuota()
: onPaymentsClick(e);
@ -253,9 +257,12 @@ const Bar = (props) => {
case QuotaBarTypes.StorageTariffLimit:
setBarVisible((value) => ({ ...value, storageTariffLimit: false }));
break;
// case QuotaBarTypes.TenantCustomQuota:
// setBarVisible((value) => ({ ...value, tenantCustomQuota: false }));
// break;
case QuotaBarTypes.StorageQuota:
setBarVisible((value) => ({ ...value, storageQuota: false }));
break;
case QuotaBarTypes.StorageQuotaLimit:
setBarVisible((value) => ({ ...value, storageQuotaLimit: false }));
break;
case QuotaBarTypes.UsersTariff:
setBarVisible((value) => ({
...value,
@ -327,13 +334,21 @@ const Bar = (props) => {
// };
// }
// if (isStorageTariffLimit && barVisible.tenantCustomQuota) {
// return {
// type: QuotaBarTypes.TenantCustomQuota,
// maxValue: getConvertedSize(t, tenantCustomQuota),
// currentValue: getConvertedSize(t, usedTotalStorageSizeCount),
// };
// }
if (isStorageQuotaAlmostLimit && barVisible.storageQuota) {
return {
type: QuotaBarTypes.StorageQuota,
maxValue: getConvertedSize(t, tenantCustomQuota),
currentValue: getConvertedSize(t, usedTotalStorageSizeCount),
};
}
if (isStorageQuotaLimit && barVisible.storageQuotaLimit) {
return {
type: QuotaBarTypes.StorageQuotaLimit,
maxValue: getConvertedSize(t, tenantCustomQuota),
currentValue: getConvertedSize(t, usedTotalStorageSizeCount),
};
}
if (isStorageTariffAlmostLimit && barVisible.storageTariff) {
return {
@ -366,7 +381,7 @@ const Bar = (props) => {
currentValue: addedManagersCount,
};
}
console.log("isPersonalQuotaLimit", isPersonalQuotaLimit);
if (isPersonalQuotaLimit && barVisible.personalUserQuota) {
return {
type: QuotaBarTypes.PersonalUserQuota,
@ -451,6 +466,8 @@ export default inject(
tenantCustomQuota,
isStorageTariffLimit,
isUserTariffLimit,
isStorageQuotaAlmostLimit,
isStorageQuotaLimit,
} = currentQuotaStore;
const { currentColorScheme, setMainBarVisible } = settingsStore;
@ -485,6 +502,8 @@ export default inject(
tenantCustomQuota,
isStorageTariffLimit,
isUserTariffLimit,
isStorageQuotaAlmostLimit,
isStorageQuotaLimit,
};
},
)(withTranslation(["Profile", "Common"])(observer(Bar)));

View File

@ -76,7 +76,7 @@ const QuotasBar = ({
);
};
const getTenantCustomQuota = () => {
if (!isAdmin) return t("StorageQuotaUserDescription");
if (!isAdmin) return t("RemoveFilesOrContactToUpgradeQuota");
return (
<Trans i18nKey="TenantCustomQuotaDescription" t={t}>
@ -254,11 +254,16 @@ const QuotasBar = ({
header: t("StorageTariffLimit", { currentValue, maxValue }),
description: getStorageTariffDescription(),
};
case QuotaBarTypes.TenantCustomQuota:
case QuotaBarTypes.StorageQuota:
return {
header: t("StorageQuotaHeader", { currentValue, maxValue }),
description: getTenantCustomQuota(),
};
case QuotaBarTypes.StorageQuotaLimit:
return {
header: t("StorageTariffLimit", { currentValue, maxValue }),
description: getTenantCustomQuota(),
};
case QuotaBarTypes.UsersTariff:
return {
header: t("UserQuotaHeader", { currentValue, maxValue }),

View File

@ -104,7 +104,8 @@ export const QuotaBarTypes = Object.freeze({
UserAndStorageQuota: "user-storage-quota",
RoomAndStorageQuota: "room-storage-quota",
PersonalUserQuota: "personal-user-quota",
TenantCustomQuota: "tenant-custom-quota",
StorageQuota: "tenant-custom-quota",
StorageQuotaLimit: "tenant-custom-quota-limit",
});
export const BINDING_POST = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST";

View File

@ -268,7 +268,8 @@ class CurrentQuotasStore {
);
}
get showTenantCustomQuotaBar() {
// For standalone mode
get isStorageQuotaAlmostLimit() {
if (!this.isTenantCustomQuotaSet || this.tenantCustomQuota === undefined)
return false;
@ -276,7 +277,21 @@ class CurrentQuotasStore {
return (
(this.usedTotalStorageSizeCount / this.tenantCustomQuota) * 100 >=
PERCENTAGE_FOR_SHOWING_BAR
PERCENTAGE_FOR_SHOWING_BAR &&
this.tenantCustomQuota > this.usedTotalStorageSizeCount
);
}
get isStorageQuotaLimit() {
if (!this.isTenantCustomQuotaSet || this.tenantCustomQuota === undefined)
return false;
if (+this.tenantCustomQuota === -1) return false;
return (
(this.usedTotalStorageSizeCount / this.tenantCustomQuota) * 100 >=
PERCENTAGE_FOR_SHOWING_BAR &&
this.tenantCustomQuota <= this.usedTotalStorageSizeCount
);
}