refactor: Remove the server deletion function
continuous-integration/drone/push Build is failing Details

pull/484/head
Inex Code 2024-03-14 19:06:35 +03:00
parent 7a2d468324
commit e874392a83
3 changed files with 1 additions and 87 deletions

View File

@ -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"

View File

@ -850,35 +850,6 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
emit(const ServerInstallationEmpty());
}
Future<void> 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<void> close() {
closeTimer();

View File

@ -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<AppSettingsPage> {
),
),
const _ResetAppTile(),
// const Divider(height: 0),
_deleteServer(context),
],
);
}
Widget _deleteServer(final BuildContext context) {
final bool isDisabled =
context.watch<ServerInstallationCubit>().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<ServerInstallationCubit>()
.serverDelete();
if (!mounted) {
return;
}
Navigator.of(context).pop();
},
),
DialogActionButton(
text: 'basis.cancel'.tr(),
),
],
),
);
},
);
}
}
class _ResetAppTile extends StatelessWidget {