Skip to content

Commit

Permalink
Add retry button and error message when admin password failed (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean28518 committed Aug 4, 2024
1 parent 75948f8 commit b260a8b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
2 changes: 2 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@
"save": "Speichern",
"distribution_selection": "Distributions-Auswahl",
"copyCommands": "Befehle kopieren",
"errorThisDidntWork": "Das hat leider nicht funktioniert.",
"complete": "Abgeschlossen",
"@helloWorld": {
"placeholders": {},
"description": "",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_it.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
47 changes: 42 additions & 5 deletions lib/layouts/run_command_queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -135,6 +168,9 @@ class RunCommandQueue extends StatelessWidget {
),
MintYButtonNext(
route: route,
onPressed: () {
Linux.clearCommandQueue();
},
),
],
),
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion lib/services/linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,6 @@ class Linux {

// Example of a line:
// "0";"apt update";"DEBIAN_NONINTERACTIVE='true'";
commandQueue.clear();

String checksum = Hashing.getMd5OfString(string);

Expand All @@ -1399,6 +1398,10 @@ class Linux {
return output;
}

static void clearCommandQueue() {
commandQueue.clear();
}

static Future<int> getUserIdOfCurrentUser() async {
String output = await Linux.runCommand("id -u");
return int.parse(output);
Expand Down

0 comments on commit b260a8b

Please sign in to comment.