From 8c441fff7f06abc80daf57cf445d9c3094e575da Mon Sep 17 00:00:00 2001 From: NaiJi Date: Thu, 22 Aug 2024 11:21:36 +0400 Subject: [PATCH] fix: Remove hardcode for recovery support articles - Resolves: #251 --- lib/logic/models/hive/server_domain.dart | 7 +++++++ .../setup/recovering/recovery_confirm_dns.dart | 4 +++- .../recovery_server_provider_connected.dart | 14 +++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/logic/models/hive/server_domain.dart b/lib/logic/models/hive/server_domain.dart index 63387145..aeed58d5 100644 --- a/lib/logic/models/hive/server_domain.dart +++ b/lib/logic/models/hive/server_domain.dart @@ -56,6 +56,13 @@ enum DnsProviderType { desec => 'deSEC', unknown => 'Unknown', }; + + String get supportArticle => switch (this) { + digitalOcean => 'how_digital_ocean', + cloudflare => 'how_cloudflare', + desec => 'how_desec', + unknown => '', + }; } extension DnsProviderTypeIsSpecified on DnsProviderType? { diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_dns.dart b/lib/ui/pages/setup/recovering/recovery_confirm_dns.dart index e49efe9e..f692c904 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_dns.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_dns.dart @@ -24,6 +24,8 @@ class RecoveryConfirmDns extends StatelessWidget { final String providerDisplayName = appConfig.state.serverDomain?.provider.displayName ?? 'DNS Provider'; + final String providerSupportArticle = + appConfig.state.serverDomain?.provider.supportArticle ?? ''; return BrandHeroScreen( heroTitle: 'recovering.provider_connected'.tr( args: [providerDisplayName], @@ -60,7 +62,7 @@ class RecoveryConfirmDns extends StatelessWidget { builder: (final context) => BrandButton.text( onPressed: () => context.read().showArticle( - article: 'how_cloudflare', + article: providerSupportArticle, context: context, ), title: 'initializing.how'.tr(), diff --git a/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart b/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart index 59fd685f..a9024e46 100644 --- a/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart +++ b/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart @@ -17,6 +17,12 @@ class RecoveryServerProviderConnected extends StatelessWidget { final ServerInstallationCubit appConfig = context.watch(); + final displayName = appConfig.state.serverDetails?.provider.displayName ?? + 'Server Provider'; + + final supportArticle = + appConfig.state.serverDetails?.provider.supportArticle ?? ''; + if (appConfig.state.serverDetails?.provider == ServerProviderType.unknown) { return BrandHeroScreen( heroTitle: 'recovering.server_provider_unknown'.tr(), @@ -45,8 +51,7 @@ class RecoveryServerProviderConnected extends StatelessWidget { builder: (final BuildContext context) => BrandHeroScreen( heroTitle: 'recovering.provider_connected'.tr( args: [ - appConfig.state.serverDetails?.provider.displayName ?? - 'Server Provider', + displayName, ], ), heroSubtitle: 'recovering.provider_connected_description'.tr( @@ -67,8 +72,7 @@ class RecoveryServerProviderConnected extends StatelessWidget { border: const OutlineInputBorder(), labelText: 'recovering.provider_connected_placeholder'.tr( args: [ - appConfig.state.serverDetails?.provider.displayName ?? - 'Server Provider', + displayName, ], ), ), @@ -84,7 +88,7 @@ class RecoveryServerProviderConnected extends StatelessWidget { builder: (final context) => BrandButton.text( title: 'initializing.how'.tr(), onPressed: () => context.read().showArticle( - article: 'how_hetzner', + article: supportArticle, context: context, ), ),