Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quota: hide "used" from user #149

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions web/ASC.Web.Api/Core/QuotaHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,21 @@ public class QuotaHelper
private readonly TenantManager _tenantManager;
private readonly IServiceProvider _serviceProvider;
private readonly CoreBaseSettings _coreBaseSettings;

public QuotaHelper(TenantManager tenantManager, IServiceProvider serviceProvider, CoreBaseSettings coreBaseSettings)
private readonly UserManager _userManager;
private readonly AuthContext _authContext;

public QuotaHelper(
TenantManager tenantManager,
IServiceProvider serviceProvider,
CoreBaseSettings coreBaseSettings,
UserManager userManager,
AuthContext authContext)
{
_tenantManager = tenantManager;
_serviceProvider = serviceProvider;
_coreBaseSettings = coreBaseSettings;
_userManager = userManager;
_authContext = authContext;
}

public async IAsyncEnumerable<QuotaDto> GetQuotasAsync()
Expand Down Expand Up @@ -109,7 +118,9 @@ private async IAsyncEnumerable<TenantQuotaFeatureDto> GetFeatures(TenantQuota qu
result.Id = feature.Name;

object used = null;

var currentUserId = _authContext.CurrentAccount.ID;
var isUsedAvailable = !await _userManager.IsUserAsync(currentUserId) && !await _userManager.IsCollaboratorAsync(currentUserId);

if (feature is TenantQuotaFeatureSize size)
{
result.Value = size.Value == long.MaxValue ? -1 : size.Value;
Expand Down Expand Up @@ -137,7 +148,7 @@ private async IAsyncEnumerable<TenantQuotaFeatureDto> GetFeatures(TenantQuota qu
{
result.Used = new FeatureUsedDto
{
Value = used,
Value = isUsedAvailable ? used : null,
Title = Resource.ResourceManager.GetString($"TariffsFeature_used_{feature.Name}")
};
}
Expand Down
Loading