mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 17:11:14 +00:00
refactor: Remove the server deletion function
This commit is contained in:
parent
7a2d468324
commit
e874392a83
|
@ -81,9 +81,7 @@
|
||||||
"dark_theme_description": "Switch your application theme",
|
"dark_theme_description": "Switch your application theme",
|
||||||
"dangerous_settings": "Dangerous settings",
|
"dangerous_settings": "Dangerous settings",
|
||||||
"reset_config_title": "Reset application config",
|
"reset_config_title": "Reset application config",
|
||||||
"reset_config_description": "Resets API keys and root user.",
|
"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."
|
|
||||||
},
|
},
|
||||||
"ssh": {
|
"ssh": {
|
||||||
"title": "SSH keys",
|
"title": "SSH keys",
|
||||||
|
@ -542,7 +540,6 @@
|
||||||
"are_you_sure": "Are you sure?",
|
"are_you_sure": "Are you sure?",
|
||||||
"purge_all_keys": "Purge all authentication keys?",
|
"purge_all_keys": "Purge all authentication keys?",
|
||||||
"purge_all_keys_confirm": "Yes, purge all my tokens",
|
"purge_all_keys_confirm": "Yes, purge all my tokens",
|
||||||
"delete_server_volume": "Delete the server and volume?",
|
|
||||||
"reboot": "Reboot",
|
"reboot": "Reboot",
|
||||||
"yes": "Yes",
|
"yes": "Yes",
|
||||||
"no": "No"
|
"no": "No"
|
||||||
|
|
|
@ -850,35 +850,6 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
|
||||||
emit(const ServerInstallationEmpty());
|
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
|
@override
|
||||||
Future<void> close() {
|
Future<void> close() {
|
||||||
closeTimer();
|
closeTimer();
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -61,61 +59,9 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const _ResetAppTile(),
|
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 {
|
class _ResetAppTile extends StatelessWidget {
|
||||||
|
|
Loading…
Reference in a new issue