1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-04 17:43:17 +00:00

[SG-79] Mobile Vault Filter (#1928)

* [SG-79] Vault Filter

* Update vault button text after sync

* formatting

* cleanup

* cleanup
This commit is contained in:
mp-bw
2022-05-31 13:34:54 -04:00
committed by GitHub
parent b8b41fe847
commit 8a3d88b3ce
13 changed files with 261 additions and 25 deletions

View File

@@ -15,7 +15,7 @@ namespace Bit.Core.Abstractions
Task<Folder> EncryptAsync(FolderView model, SymmetricCryptoKey key = null);
Task<List<Folder>> GetAllAsync();
Task<List<FolderView>> GetAllDecryptedAsync();
Task<List<TreeNode<FolderView>>> GetAllNestedAsync();
Task<List<TreeNode<FolderView>>> GetAllNestedAsync(List<FolderView> folders = null);
Task<Folder> GetAsync(string id);
Task<TreeNode<FolderView>> GetNestedAsync(string id);
Task ReplaceAsync(Dictionary<string, FolderData> folders);

View File

@@ -20,5 +20,6 @@ namespace Bit.Core.Abstractions
string orgId);
Task<bool> PolicyAppliesToUser(PolicyType policyType, Func<Policy, bool> policyFilter = null, string userId = null);
int? GetPolicyInt(Policy policy, string key);
Task<bool> ShouldShowVaultFilterAsync();
}
}

View File

@@ -111,5 +111,6 @@
public const string EyeSlash = "\xe96d";
public const string File = "\xe96e";
public const string Paste = "\xe96f";
public const string ViewCellMenu = "\xe5d3";
}
}

View File

@@ -107,9 +107,12 @@ namespace Bit.Core.Services
return _decryptedFolderCache;
}
public async Task<List<TreeNode<FolderView>>> GetAllNestedAsync()
public async Task<List<TreeNode<FolderView>>> GetAllNestedAsync(List<FolderView> folders = null)
{
var folders = await GetAllDecryptedAsync();
if (folders == null)
{
folders = await GetAllDecryptedAsync();
}
var nodes = new List<TreeNode<FolderView>>();
foreach (var f in folders)
{

View File

@@ -193,7 +193,8 @@ namespace Bit.Core.Services
return new Tuple<ResetPasswordPolicyOptions, bool>(resetPasswordPolicyOptions, policy != null);
}
public async Task<bool> PolicyAppliesToUser(PolicyType policyType, Func<Policy, bool> policyFilter, string userId = null)
public async Task<bool> PolicyAppliesToUser(PolicyType policyType, Func<Policy, bool> policyFilter = null,
string userId = null)
{
var policies = await GetAll(policyType, userId);
if (policies == null)
@@ -246,6 +247,13 @@ namespace Bit.Core.Services
return null;
}
public async Task<bool> ShouldShowVaultFilterAsync()
{
var organizations = await _organizationService.GetAllAsync();
var personalOwnershipPolicyApplies = await PolicyAppliesToUser(PolicyType.PersonalOwnership);
return (organizations?.Any() ?? false) && !personalOwnershipPolicyApplies;
}
private bool? GetPolicyBool(Policy policy, string key)
{
if (policy.Data.ContainsKey(key))