fix: Remove hardcode for recovery support articles

- Resolves: #251
This commit is contained in:
NaiJi 2024-08-22 11:21:36 +04:00
parent a6640a7950
commit 8c441fff7f
3 changed files with 19 additions and 6 deletions

View file

@ -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? {

View file

@ -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<SupportSystemCubit>().showArticle(
article: 'how_cloudflare',
article: providerSupportArticle,
context: context,
),
title: 'initializing.how'.tr(),

View file

@ -17,6 +17,12 @@ class RecoveryServerProviderConnected extends StatelessWidget {
final ServerInstallationCubit appConfig =
context.watch<ServerInstallationCubit>();
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<SupportSystemCubit>().showArticle(
article: 'how_hetzner',
article: supportArticle,
context: context,
),
),