2019-05-01 17:31:00 +02:00
|
|
|
|
using Bit.App.Resources;
|
2023-06-29 20:37:08 +02:00
|
|
|
|
using Bit.App.Utilities.Automation;
|
2022-01-21 10:31:03 +01:00
|
|
|
|
using Bit.Core;
|
2019-05-01 17:31:00 +02:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
using Bit.Core.Models.View;
|
2019-03-29 18:24:44 +01:00
|
|
|
|
|
|
|
|
|
namespace Bit.App.Pages
|
|
|
|
|
{
|
2022-03-17 21:33:22 +01:00
|
|
|
|
public class GroupingsPageListItem : IGroupingsPageListItem
|
2019-03-29 18:24:44 +01:00
|
|
|
|
{
|
2019-04-22 23:08:37 +02:00
|
|
|
|
private string _icon;
|
2019-05-01 17:31:00 +02:00
|
|
|
|
private string _name;
|
2019-04-22 23:08:37 +02:00
|
|
|
|
|
2019-03-29 18:24:44 +01:00
|
|
|
|
public FolderView Folder { get; set; }
|
2019-04-19 22:45:16 +02:00
|
|
|
|
public CollectionView Collection { get; set; }
|
2019-03-29 18:24:44 +01:00
|
|
|
|
public CipherView Cipher { get; set; }
|
2019-05-01 17:31:00 +02:00
|
|
|
|
public CipherType? Type { get; set; }
|
2019-05-01 18:28:49 +02:00
|
|
|
|
public string ItemCount { get; set; }
|
2019-05-17 20:34:29 +02:00
|
|
|
|
public bool FuzzyAutofill { get; set; }
|
2020-05-20 19:35:20 +02:00
|
|
|
|
public bool IsTrash { get; set; }
|
2022-08-17 23:10:16 +02:00
|
|
|
|
public bool IsTotpCode { get; set; }
|
2019-05-01 17:31:00 +02:00
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
|
if (_name != null)
|
2019-05-01 17:31:00 +02:00
|
|
|
|
{
|
|
|
|
|
return _name;
|
|
|
|
|
}
|
2020-05-20 19:35:20 +02:00
|
|
|
|
if (IsTrash)
|
|
|
|
|
{
|
|
|
|
|
_name = AppResources.Trash;
|
|
|
|
|
}
|
|
|
|
|
else if (Folder != null)
|
2019-05-01 17:31:00 +02:00
|
|
|
|
{
|
|
|
|
|
_name = Folder.Name;
|
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
else if (Collection != null)
|
2019-05-01 17:31:00 +02:00
|
|
|
|
{
|
|
|
|
|
_name = Collection.Name;
|
|
|
|
|
}
|
2022-08-17 23:10:16 +02:00
|
|
|
|
else if (IsTotpCode)
|
|
|
|
|
{
|
|
|
|
|
_name = AppResources.VerificationCodes;
|
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
else if (Type != null)
|
2019-05-01 17:31:00 +02:00
|
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
|
switch (Type.Value)
|
2019-05-01 17:31:00 +02:00
|
|
|
|
{
|
|
|
|
|
case CipherType.Login:
|
|
|
|
|
_name = AppResources.TypeLogin;
|
|
|
|
|
break;
|
|
|
|
|
case CipherType.SecureNote:
|
|
|
|
|
_name = AppResources.TypeSecureNote;
|
|
|
|
|
break;
|
|
|
|
|
case CipherType.Card:
|
|
|
|
|
_name = AppResources.TypeCard;
|
|
|
|
|
break;
|
|
|
|
|
case CipherType.Identity:
|
|
|
|
|
_name = AppResources.TypeIdentity;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return _name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-22 23:08:37 +02:00
|
|
|
|
public string Icon
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
|
if (_icon != null)
|
2019-04-22 23:08:37 +02:00
|
|
|
|
{
|
|
|
|
|
return _icon;
|
|
|
|
|
}
|
2020-05-20 19:35:20 +02:00
|
|
|
|
if (IsTrash)
|
|
|
|
|
{
|
2022-01-21 10:31:03 +01:00
|
|
|
|
_icon = BitwardenIcons.Trash;
|
2020-05-20 19:35:20 +02:00
|
|
|
|
}
|
|
|
|
|
else if (Folder != null)
|
2019-04-22 23:08:37 +02:00
|
|
|
|
{
|
2022-02-03 17:34:20 +01:00
|
|
|
|
_icon = BitwardenIcons.Folder;
|
2019-04-22 23:08:37 +02:00
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
else if (Collection != null)
|
2019-04-22 23:08:37 +02:00
|
|
|
|
{
|
2022-02-12 13:27:37 +01:00
|
|
|
|
_icon = BitwardenIcons.Collection;
|
2019-04-22 23:08:37 +02:00
|
|
|
|
}
|
2022-08-17 23:10:16 +02:00
|
|
|
|
else if (IsTotpCode)
|
|
|
|
|
{
|
|
|
|
|
_icon = BitwardenIcons.Clock;
|
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
else if (Type != null)
|
2019-05-01 17:31:00 +02:00
|
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
|
switch (Type.Value)
|
2019-05-01 17:31:00 +02:00
|
|
|
|
{
|
|
|
|
|
case CipherType.Login:
|
2022-01-21 10:31:03 +01:00
|
|
|
|
_icon = BitwardenIcons.Globe;
|
2019-05-01 17:31:00 +02:00
|
|
|
|
break;
|
|
|
|
|
case CipherType.SecureNote:
|
2022-01-21 10:31:03 +01:00
|
|
|
|
_icon = BitwardenIcons.StickyNote;
|
2019-05-01 17:31:00 +02:00
|
|
|
|
break;
|
|
|
|
|
case CipherType.Card:
|
2022-01-21 10:31:03 +01:00
|
|
|
|
_icon = BitwardenIcons.CreditCard;
|
2019-05-01 17:31:00 +02:00
|
|
|
|
break;
|
|
|
|
|
case CipherType.Identity:
|
2022-01-21 10:31:03 +01:00
|
|
|
|
_icon = BitwardenIcons.IdCard;
|
2019-05-01 17:31:00 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2022-01-21 10:31:03 +01:00
|
|
|
|
_icon = BitwardenIcons.Globe;
|
2019-05-01 17:31:00 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-22 23:08:37 +02:00
|
|
|
|
return _icon;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-29 20:37:08 +02:00
|
|
|
|
|
|
|
|
|
public string AutomationId
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (Type != null)
|
|
|
|
|
{
|
|
|
|
|
return AutomationIdsHelper.AddSuffixFor(System.Enum.GetName(typeof(CipherType), Type.Value), SuffixType.Filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsTrash)
|
|
|
|
|
{
|
|
|
|
|
return AutomationIdsHelper.AddSuffixFor("Trash", SuffixType.Filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Folder != null)
|
|
|
|
|
{
|
|
|
|
|
return AutomationIdsHelper.AddSuffixFor("Folder", SuffixType.Filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Collection != null)
|
|
|
|
|
{
|
|
|
|
|
return AutomationIdsHelper.AddSuffixFor("Collection", SuffixType.Filter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsTotpCode)
|
|
|
|
|
{
|
|
|
|
|
return AutomationIdsHelper.AddSuffixFor("TOTP", SuffixType.ListItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-29 18:24:44 +01:00
|
|
|
|
}
|
|
|
|
|
}
|