Skip to content
Merged
56 changes: 50 additions & 6 deletions apps/ubuntu_bootstrap/lib/app/installer_wizard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:subiquity_client/subiquity_client.dart';
import 'package:ubuntu_bootstrap/app/installation_step.dart';
import 'package:ubuntu_bootstrap/app/installer_model.dart';
import 'package:ubuntu_bootstrap/l10n.dart';
import 'package:ubuntu_bootstrap/pages.dart';
import 'package:ubuntu_bootstrap/pages/autoinstall/autoinstall_model.dart';
import 'package:ubuntu_bootstrap/services.dart';
import 'package:ubuntu_provision/ubuntu_provision.dart';
import 'package:ubuntu_wizard/ubuntu_wizard.dart';
Expand Down Expand Up @@ -83,10 +85,15 @@ class _InstallWizard extends ConsumerWidget {
...preInstallRoutes,
InstallationStep.done.route: WizardRoute(
builder: (_) => const DonePage(),
onLoad: (_) => const DonePage().load(context, ref),
onLoad: (_) {
if (!ref.context.mounted) {
return false;
}
return const DonePage().load(context, ref);
},
),
InstallationStep.error.route: WizardRoute(
builder: (_) => const ErrorPage(allowRestart: false),
builder: (_) => const ErrorPage(allowRestart: true),
),
},
predicate: (route) {
Expand Down Expand Up @@ -146,24 +153,61 @@ class _AutoinstallWizard extends ConsumerWidget {
onLoad: (_) => const DonePage().load(context, ref),
),
InstallationStep.error.route: WizardRoute(
builder: (_) => const ErrorPage(allowRestart: false),
builder: (_) => ErrorPage(
allowRestart: false,
),
),
},
);
}
}

class _ErrorWizard extends StatelessWidget {
class _ErrorWizard extends ConsumerWidget {
const _ErrorWizard();

@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final status = ref.read(installerModelProvider.select((m) => m.status));
return Wizard(
routes: <String, WizardRoute>{
InstallationStep.error.route: WizardRoute(
builder: (_) => const ErrorPage(allowRestart: false),
builder: (_) => ErrorPage(
allowRestart: false,
errorDetails: status
?.toErrorDetails(UbuntuBootstrapLocalizations.of(context)),
),
),
},
);
}
}

extension on ApplicationStatus {
ErrorDetails? toErrorDetails(UbuntuBootstrapLocalizations l10n) =>
switch (this) {
ApplicationStatus(
state: ApplicationState.ERROR,
nonreportableError: NonReportableError(
cause: 'AutoinstallUserSuppliedCmdError',
message: final message,
details: final details,
)
) =>
ErrorDetails(
title: l10n.installationFailed,
message: [
l10n.autoinstallErrorMessage,
l10n.autoinstallErrorInstructions,
],
details: [
message,
details,
].nonNulls.join('\n'),
action: (ref) async {
await ref.read(autoinstallModelProvider.notifier).restart();
},
actionLabel: l10n.restartInstaller,
),
_ => null,
};
}
3 changes: 3 additions & 0 deletions apps/ubuntu_bootstrap/lib/l10n/ubuntu_bootstrap_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"autoinstallDirectDescription": "For advanced users who have an autoinstall.yaml for consistent and repeatable system setups.",
"autoinstallLandscapeOption": "Automated with Landscape",
"autoinstallLandscapeDescription": "For users in organizations that provide an autoinstall file via Landscape.",
"autoinstallErrorMessage": "A command in the autoinstall file failed to run during installation.",
"autoinstallErrorInstructions": "You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.",
"changeButtonText": "Change",
"quitButtonText": "Quit installation",
"loadingPageTitle": "Welcome to {DISTRO}",
Expand Down Expand Up @@ -583,6 +585,7 @@
"bitlockerWarningTitle": "You may lose all your data without BitLocker recovery keys",
"restartComputer": "Restart computer",
"restartComputerTitle": "Restart computer?",
"restartInstaller": "Restart installer",
"restartIntoWindows": "Restart into Windows",
"restartIntoWindowsTitle": "Restart into Windows?",
"restartIntoWindowsDescription": "Are you sure you want to restart your computer? You will need to restart the {DISTRO} installation later to finish installing {DISTRO}.",
Expand Down
18 changes: 18 additions & 0 deletions apps/ubuntu_bootstrap/lib/l10n/ubuntu_bootstrap_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,18 @@ abstract class UbuntuBootstrapLocalizations {
/// **'For users in organizations that provide an autoinstall file via Landscape.'**
String get autoinstallLandscapeDescription;

/// No description provided for @autoinstallErrorMessage.
///
/// In en, this message translates to:
/// **'A command in the autoinstall file failed to run during installation.'**
String get autoinstallErrorMessage;

/// No description provided for @autoinstallErrorInstructions.
///
/// In en, this message translates to:
/// **'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.'**
String get autoinstallErrorInstructions;

/// No description provided for @changeButtonText.
///
/// In en, this message translates to:
Expand Down Expand Up @@ -1714,6 +1726,12 @@ abstract class UbuntuBootstrapLocalizations {
/// **'Restart computer?'**
String get restartComputerTitle;

/// No description provided for @restartInstaller.
///
/// In en, this message translates to:
/// **'Restart installer'**
String get restartInstaller;

/// No description provided for @restartIntoWindows.
///
/// In en, this message translates to:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UbuntuBootstrapLocalizationsAm extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'For users in organizations that provide an autoinstall file via Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'ለውጥ';

Expand Down Expand Up @@ -898,6 +906,9 @@ class UbuntuBootstrapLocalizationsAm extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restart computer?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Restart into Windows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UbuntuBootstrapLocalizationsAr extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'For users in organizations that provide an autoinstall file via Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'تغيير';

Expand Down Expand Up @@ -897,6 +905,9 @@ class UbuntuBootstrapLocalizationsAr extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restart computer?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Restart into Windows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ class UbuntuBootstrapLocalizationsBe extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'For users in organizations that provide an autoinstall file via Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'Змяніць';

Expand Down Expand Up @@ -897,6 +905,9 @@ class UbuntuBootstrapLocalizationsBe extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restart computer?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Перазапусціць у Windows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UbuntuBootstrapLocalizationsBg extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'For users in organizations that provide an autoinstall file via Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'Change';

Expand Down Expand Up @@ -898,6 +906,9 @@ class UbuntuBootstrapLocalizationsBg extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restart computer?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Restart into Windows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UbuntuBootstrapLocalizationsBn extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'For users in organizations that provide an autoinstall file via Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'পরিবর্তন';

Expand Down Expand Up @@ -898,6 +906,9 @@ class UbuntuBootstrapLocalizationsBn extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restart computer?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Restart into Windows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UbuntuBootstrapLocalizationsBo extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'For users in organizations that provide an autoinstall file via Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'Change';

Expand Down Expand Up @@ -898,6 +906,9 @@ class UbuntuBootstrapLocalizationsBo extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restart computer?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Restart into Windows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UbuntuBootstrapLocalizationsBs extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'For users in organizations that provide an autoinstall file via Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'Change';

Expand Down Expand Up @@ -898,6 +906,9 @@ class UbuntuBootstrapLocalizationsBs extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restart computer?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Restart into Windows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UbuntuBootstrapLocalizationsCa extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'Per als usuaris en organitzacions que proporcionen un fitxer autoinstall mitjançant Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'Canvia';

Expand Down Expand Up @@ -910,6 +918,9 @@ class UbuntuBootstrapLocalizationsCa extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Voleu reiniciar l\'ordinador?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Reiniciar a WIndows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ class UbuntuBootstrapLocalizationsCs extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'Pro uživatele v organizacích, které poskytují soubor autoinstall prostřednictvím Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'Změnit';

Expand Down Expand Up @@ -902,6 +910,9 @@ class UbuntuBootstrapLocalizationsCs extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restartovat počítač?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Restartovat do Windows';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UbuntuBootstrapLocalizationsCy extends UbuntuBootstrapLocalizations {
String get autoinstallLandscapeDescription =>
'For users in organizations that provide an autoinstall file via Landscape.';

@override
String get autoinstallErrorMessage =>
'A command in the autoinstall file failed to run during installation.';

@override
String get autoinstallErrorInstructions =>
'You will need to restart the installation. Check the autoinstall file, choose a different installation type, or contact your IT support.';

@override
String get changeButtonText => 'Newid';

Expand Down Expand Up @@ -899,6 +907,9 @@ class UbuntuBootstrapLocalizationsCy extends UbuntuBootstrapLocalizations {
@override
String get restartComputerTitle => 'Restart computer?';

@override
String get restartInstaller => 'Restart installer';

@override
String get restartIntoWindows => 'Restart into Windows';

Expand Down
Loading