From b260a8bdbbdb3ad333be79797bf82a2f56299fa4 Mon Sep 17 00:00:00 2001 From: Jean28518 Date: Sun, 4 Aug 2024 21:05:22 +0200 Subject: [PATCH] Add retry button and error message when admin password failed (#199) --- lib/l10n/app_de.arb | 2 ++ lib/l10n/app_en.arb | 2 ++ lib/l10n/app_it.arb | 2 ++ lib/layouts/run_command_queue.dart | 47 ++++++++++++++++++++++++++---- lib/services/linux.dart | 5 +++- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 9f8f032..73baf74 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -359,6 +359,8 @@ "save": "Speichern", "distribution_selection": "Distributions-Auswahl", "copyCommands": "Befehle kopieren", + "errorThisDidntWork": "Das hat leider nicht funktioniert.", + "complete": "Abgeschlossen", "@helloWorld": { "placeholders": {}, "description": "", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 3927a4d..1c1f7f4 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -359,6 +359,8 @@ "save": "Save", "distribution_selection": "Distribution selection", "copyCommands": "Copy commands", + "errorThisDidntWork": "That didn't work.", + "complete": "Complete", "@helloWorld": { "placeholders": {}, "description": "The conventional newborn programmer greeting", diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index 6a2702e..8356c2e 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -339,6 +339,8 @@ "settingUpFirewall": "Configura firewall...", "distribution_selection": "Selezione della distribuzione", "copyCommands": "Copia comandi", + "errorThisDidntWork": "Errore! Questo non ha funzionato.", + "complete": "Completa", "@helloWorld": { "placeholders": {}, "description": "Il saluto convenzionale del programmatore appena nato", diff --git a/lib/layouts/run_command_queue.dart b/lib/layouts/run_command_queue.dart index db46391..728722b 100644 --- a/lib/layouts/run_command_queue.dart +++ b/lib/layouts/run_command_queue.dart @@ -72,11 +72,44 @@ class RunCommandQueue extends StatelessWidget { const SizedBox( height: 16, ), - Text( - "Complete.", - style: Theme.of(context).textTheme.bodyMedium, - textAlign: TextAlign.center, - ), + snapshot.data!.contains( + "Error executing command as another user: Request dismissed") + ? Column( + children: [ + Text( + AppLocalizations.of(context)!.errorThisDidntWork, + style: Theme.of(context).textTheme.bodyMedium, + textAlign: TextAlign.center, + ), + SizedBox( + height: 16, + ), + MintYButton( + text: Text( + AppLocalizations.of(context)!.retry, + style: MintY.heading4White, + ), + color: MintY.currentColor, + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => RunCommandQueue( + route: route, + title: title, + message: message, + offerShutdownAfterwards: + offerShutdownAfterwards, + )), + ); + }, + ) + ], + ) + : Text( + AppLocalizations.of(context)!.complete, + style: Theme.of(context).textTheme.bodyMedium, + textAlign: TextAlign.center, + ), ], bottom: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -135,6 +168,9 @@ class RunCommandQueue extends StatelessWidget { ), MintYButtonNext( route: route, + onPressed: () { + Linux.clearCommandQueue(); + }, ), ], ), @@ -183,6 +219,7 @@ class RunCommandQueue extends StatelessWidget { ); hotKeyManager.register(enter, keyDownHandler: (hotKey) { if (commandQueueCompleted) { + Linux.clearCommandQueue(); Navigator.of(context).push( MaterialPageRoute( builder: (context) => route, diff --git a/lib/services/linux.dart b/lib/services/linux.dart index 904dd66..bf7eafd 100644 --- a/lib/services/linux.dart +++ b/lib/services/linux.dart @@ -1385,7 +1385,6 @@ class Linux { // Example of a line: // "0";"apt update";"DEBIAN_NONINTERACTIVE='true'"; - commandQueue.clear(); String checksum = Hashing.getMd5OfString(string); @@ -1399,6 +1398,10 @@ class Linux { return output; } + static void clearCommandQueue() { + commandQueue.clear(); + } + static Future getUserIdOfCurrentUser() async { String output = await Linux.runCommand("id -u"); return int.parse(output);