Add IsDeprecated to Wallet and Uploader

This commit is contained in:
Ivan Yaremenchuk 2022-10-02 21:29:06 -05:00
parent 592ffa5bcb
commit 3f97a9cfdf
6 changed files with 28 additions and 30 deletions

View File

@ -7,4 +7,5 @@ public interface INamedEntity
public string ShortName { get; } public string ShortName { get; }
public string ImageName { get; } public string ImageName { get; }
public bool IsSupported { get; } public bool IsSupported { get; }
public bool IsDeprecated { get; }
} }

View File

@ -8,7 +8,6 @@ public interface INetwork : INamedEntity, IEntityWithOrder
public ulong? ChainId { get; } public ulong? ChainId { get; }
public string Currency { get; } public string Currency { get; }
public bool IsTestnet { get; } public bool IsTestnet { get; }
public bool IsDeprecated { get; }
public NetworkType Type { get; } public NetworkType Type { get; }
public NetworkSubtype SubType { get; } public NetworkSubtype SubType { get; }
public Uri PublicRpcUrl { get; } public Uri PublicRpcUrl { get; }

View File

@ -10,6 +10,7 @@ public abstract class DefaultEntity : INamedEntity, IEntityWithOrder, IStateful,
public abstract string ShortName { get; } public abstract string ShortName { get; }
public abstract string ImageName { get; } public abstract string ImageName { get; }
public virtual bool IsSupported { get; } = true; public virtual bool IsSupported { get; } = true;
public virtual bool IsDeprecated { get; } = false;
public virtual int? Order { get; } = null; public virtual int? Order { get; } = null;

View File

@ -9,7 +9,6 @@ public abstract class Network : DefaultEntity, INetwork
public virtual ulong? ChainId { get; } = null; public virtual ulong? ChainId { get; } = null;
public virtual string Currency { get; } = null; public virtual string Currency { get; } = null;
public virtual bool IsTestnet { get; } = true; public virtual bool IsTestnet { get; } = true;
public virtual bool IsDeprecated { get; } = false;
public abstract NetworkType Type { get; } public abstract NetworkType Type { get; }
public abstract NetworkSubtype SubType { get; } public abstract NetworkSubtype SubType { get; }
public abstract Uri PublicRpcUrl { get; } public abstract Uri PublicRpcUrl { get; }

View File

@ -38,25 +38,24 @@ public partial class CreateUploadDialog : BasicComponent
RefreshMediator.NotifyStateHasChangedSafe(); RefreshMediator.NotifyStateHasChangedSafe();
} }
private CardListItem MapCardListItem(IUploader uploader) private CardListItem MapCardListItem(IUploader model)
{ {
var configurationItems = uploader.GetConfigurationItems(); var configurationItems = model.GetConfigurationItems();
return new CardListItem return new CardListItem
{ {
Id = uploader.Id, Id = model.Id,
ImageLocation = uploader.ImageName != null ? "./images/" + uploader.ImageName : null, ImageLocation = model.ImageName != null ? "./images/" + model.ImageName : null,
Header = uploader.Name, Header = model.Name,
Properties = uploader.GetProperties().Select(Map).ToArray(), Properties = model.GetProperties().Select(Map).ToArray(),
IsDisabled = !uploader.IsSupported, IsDisabled = !model.IsSupported,
SelectionIcon = uploader.IsConfigured ? CardListItemSelectionIcon.Checkmark : CardListItemSelectionIcon.Warning, SelectionIcon = model.IsConfigured ? CardListItemSelectionIcon.Checkmark : CardListItemSelectionIcon.Warning,
Badges = new[] Badges = new[]
{ {
(Settings?.RecommendedUploaders?.Contains(uploader.Id) ?? false) (Settings?.RecommendedUploaders?.Contains(model.Id) ?? false)
? new CardListItemBadge {Style = BadgeStyle.Success, Text = "Recommended"} ? new CardListItemBadge {Style = BadgeStyle.Success, Text = "Recommended"}
: null, : null,
!uploader.IsSupported !model.IsSupported ? new CardListItemBadge { Style = BadgeStyle.Light, Text = "Not Supported" } : null,
? new CardListItemBadge {Style = BadgeStyle.Light, Text = "Not Supported"} model.IsDeprecated ? new CardListItemBadge { Style = BadgeStyle.Warning, Text = "Deprecated" } : null,
: null,
}.Where(x => x != null).ToArray(), }.Where(x => x != null).ToArray(),
Buttons = configurationItems != null && configurationItems.Any() Buttons = configurationItems != null && configurationItems.Any()
? new[] ? new[]
@ -67,11 +66,11 @@ public partial class CreateUploadDialog : BasicComponent
Style = ButtonStyle.Secondary, Style = ButtonStyle.Secondary,
Action = async () => Action = async () =>
{ {
var result = await OpenConfigurationDialog(uploader); var result = await OpenConfigurationDialog(model);
RefreshCards(); RefreshCards();
if (result.IsSuccess) if (result.IsSuccess)
{ {
await StateRepository.SaveUploaderState(uploader); await StateRepository.SaveUploaderState(model);
} }
} }
} }

View File

@ -37,25 +37,24 @@ public partial class WalletsPage : BasicComponent
WalletCards = Wallets.Select(MapCardListItem).ToArray(); WalletCards = Wallets.Select(MapCardListItem).ToArray();
} }
private CardListItem MapCardListItem(IWallet wallet) private CardListItem MapCardListItem(IWallet model)
{ {
var configurationItems = wallet.GetConfigurationItems(); var configurationItems = model.GetConfigurationItems();
return new CardListItem return new CardListItem
{ {
Id = wallet.Id, Id = model.Id,
ImageLocation = wallet.ImageName != null ? "./images/" + wallet.ImageName : null, ImageLocation = model.ImageName != null ? "./images/" + model.ImageName : null,
Header = wallet.Name, Header = model.Name,
IsDisabled = !wallet.IsSupported, IsDisabled = !model.IsSupported,
Properties = wallet.GetProperties().Select(Map).ToArray(), Properties = model.GetProperties().Select(Map).ToArray(),
SelectionIcon = wallet.IsConfigured ? CardListItemSelectionIcon.Checkmark : CardListItemSelectionIcon.Warning, SelectionIcon = model.IsConfigured ? CardListItemSelectionIcon.Checkmark : CardListItemSelectionIcon.Warning,
Badges = new[] Badges = new[]
{ {
(Settings?.RecommendedWallets?.Contains(wallet.Id) ?? false) (Settings?.RecommendedWallets?.Contains(model.Id) ?? false)
? new CardListItemBadge {Style = BadgeStyle.Success, Text = "Recommended"} ? new CardListItemBadge {Style = BadgeStyle.Success, Text = "Recommended"}
: null, : null,
!wallet.IsSupported !model.IsSupported ? new CardListItemBadge { Style = BadgeStyle.Light, Text = "Not Supported" } : null,
? new CardListItemBadge {Style = BadgeStyle.Light, Text = "Not Supported"} model.IsDeprecated ? new CardListItemBadge { Style = BadgeStyle.Warning, Text = "Deprecated" } : null,
: null,
}.Where(x => x != null).ToArray(), }.Where(x => x != null).ToArray(),
Buttons = configurationItems != null && configurationItems.Any() Buttons = configurationItems != null && configurationItems.Any()
? new[] ? new[]
@ -66,11 +65,11 @@ public partial class WalletsPage : BasicComponent
Style = ButtonStyle.Secondary, Style = ButtonStyle.Secondary,
Action = async () => Action = async () =>
{ {
var result = await OpenConfigurationDialog(wallet); var result = await OpenConfigurationDialog(model);
RefreshCards(); RefreshCards();
if (result.IsSuccess) if (result.IsSuccess)
{ {
await StateRepository.SaveWalletState(wallet); await StateRepository.SaveWalletState(model);
} }
} }
} }