From e874392a832afa148f16b99762a9c8a66b075273 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Thu, 14 Mar 2024 19:06:35 +0300 Subject: [PATCH] refactor: Remove the server deletion function --- assets/translations/en.json | 5 +- .../server_installation_cubit.dart | 29 ---------- .../pages/more/app_settings/app_settings.dart | 54 ------------------- 3 files changed, 1 insertion(+), 87 deletions(-) diff --git a/assets/translations/en.json b/assets/translations/en.json index 40b1a85a..b862cba6 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -81,9 +81,7 @@ "dark_theme_description": "Switch your application theme", "dangerous_settings": "Dangerous settings", "reset_config_title": "Reset application config", - "reset_config_description": "Resets API keys and root user.", - "delete_server_title": "Delete server", - "delete_server_description": "This removes your server. It will be no longer accessible." + "reset_config_description": "Resets API keys and root user." }, "ssh": { "title": "SSH keys", @@ -542,7 +540,6 @@ "are_you_sure": "Are you sure?", "purge_all_keys": "Purge all authentication keys?", "purge_all_keys_confirm": "Yes, purge all my tokens", - "delete_server_volume": "Delete the server and volume?", "reboot": "Reboot", "yes": "Yes", "no": "No" diff --git a/lib/logic/cubit/server_installation/server_installation_cubit.dart b/lib/logic/cubit/server_installation/server_installation_cubit.dart index 5476a755..66e9e2f2 100644 --- a/lib/logic/cubit/server_installation/server_installation_cubit.dart +++ b/lib/logic/cubit/server_installation/server_installation_cubit.dart @@ -850,35 +850,6 @@ class ServerInstallationCubit extends Cubit { emit(const ServerInstallationEmpty()); } - Future serverDelete() async { - closeTimer(); - - if (state.serverDetails != null) { - final bool deletionResult = - await repository.deleteServer(state.serverDomain!); - if (!deletionResult) { - return; - } - } - await repository.deleteServerRelatedRecords(); - emit( - ServerInstallationNotFinished( - providerApiToken: state.providerApiToken, - serverDomain: state.serverDomain, - dnsApiToken: state.dnsApiToken, - backblazeCredential: state.backblazeCredential, - rootUser: state.rootUser, - customSshKey: null, - serverDetails: null, - isServerStarted: false, - isServerResetedFirstTime: false, - isServerResetedSecondTime: false, - isLoading: false, - dnsMatches: null, - ), - ); - } - @override Future close() { closeTimer(); diff --git a/lib/ui/pages/more/app_settings/app_settings.dart b/lib/ui/pages/more/app_settings/app_settings.dart index b41f1a74..7cce6715 100644 --- a/lib/ui/pages/more/app_settings/app_settings.dart +++ b/lib/ui/pages/more/app_settings/app_settings.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:auto_route/auto_route.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -61,61 +59,9 @@ class _AppSettingsPageState extends State { ), ), const _ResetAppTile(), - // const Divider(height: 0), - _deleteServer(context), ], ); } - - Widget _deleteServer(final BuildContext context) { - final bool isDisabled = - context.watch().state.serverDetails == null; - return ListTile( - title: Text('application_settings.delete_server_title'.tr()), - subtitle: Text('application_settings.delete_server_description'.tr()), - textColor: isDisabled - ? Theme.of(context).colorScheme.onBackground.withOpacity(0.5) - : Theme.of(context).colorScheme.onBackground, - onTap: isDisabled - ? null - : () { - showDialog( - context: context, - builder: (final _) => AlertDialog( - title: Text('modals.are_you_sure'.tr()), - content: Text('modals.delete_server_volume'.tr()), - actions: [ - DialogActionButton( - text: 'modals.yes'.tr(), - isRed: true, - onPressed: () async { - unawaited( - showDialog( - context: context, - builder: (final context) => Container( - alignment: Alignment.center, - child: const CircularProgressIndicator(), - ), - ), - ); - await context - .read() - .serverDelete(); - if (!mounted) { - return; - } - Navigator.of(context).pop(); - }, - ), - DialogActionButton( - text: 'basis.cancel'.tr(), - ), - ], - ), - ); - }, - ); - } } class _ResetAppTile extends StatelessWidget {