diff --git a/gui/packages/ubuntupro/lib/pages/landscape/landscape_model.dart b/gui/packages/ubuntupro/lib/pages/landscape/landscape_model.dart index b11afa806..bb0f6c163 100644 --- a/gui/packages/ubuntupro/lib/pages/landscape/landscape_model.dart +++ b/gui/packages/ubuntupro/lib/pages/landscape/landscape_model.dart @@ -26,17 +26,17 @@ class LandscapeModel extends ChangeNotifier { /// The current configuration type, allowing the UI to show the correct form. LandscapeConfigType get configType => _current; - LandscapeConfigType _current = LandscapeConfigType.saas; + LandscapeConfigType _current = LandscapeConfigType.manual; // The active configuration form data, a shortcut to reduce some switch statements // and avoid relying on ducktyping when serializing the config or checking for completeness. - late LandscapeConfig _active = saas; + late LandscapeConfig _active = manual; - /// The configuration form data for the SaaS configuration. - final LandscapeSaasConfig saas = LandscapeSaasConfig(); + /// The configuration form data for the manual configuration. + final LandscapeManualConfig manual = LandscapeManualConfig(); - // TODO: Remove this condition when Landscape SaaS starts supporting WSL. - bool get isSaaSSupported => kDebugMode; + // TODO: Remove this condition when Landscape manual/SaaS starts supporting WSL. + bool get isManualSupported => kDebugMode; /// The configuration form data for the custom configuration. final LandscapeCustomConfig custom = LandscapeCustomConfig(); @@ -46,8 +46,8 @@ class LandscapeModel extends ChangeNotifier { if (value == null) return; _current = value; switch (configType) { - case LandscapeConfigType.saas: - _active = saas; + case LandscapeConfigType.manual: + _active = manual; case LandscapeConfigType.custom: _active = custom; } @@ -55,27 +55,27 @@ class LandscapeModel extends ChangeNotifier { notifyListeners(); } - /// Sets the registration key for the SaaS configurations. - void setSaasRegistrationKey(String? registrationKey) { - assert(_active is LandscapeSaasConfig); + /// Sets the registration key for the manual configurations. + void setManualRegistrationKey(String? registrationKey) { + assert(_active is LandscapeManualConfig); if (registrationKey == null) return; - saas.registrationKey = registrationKey; + manual.registrationKey = registrationKey; notifyListeners(); } /// Sets (and validates) the FQDN for the self-hosted configuration. void setFqdn(String? fqdn) { - assert(_active is LandscapeSaasConfig); + assert(_active is LandscapeManualConfig); if (fqdn == null) return; - saas.fqdn = fqdn; + manual.fqdn = fqdn; notifyListeners(); } /// Sets (and validates) the SSL key path for the self-hosted configuration. void setSslKeyPath(String? sslKeyPath) { - assert(_active is LandscapeSaasConfig); + assert(_active is LandscapeManualConfig); if (sslKeyPath == null) return; - saas.sslKeyPath = sslKeyPath; + manual.sslKeyPath = sslKeyPath; notifyListeners(); } @@ -102,7 +102,7 @@ class LandscapeModel extends ChangeNotifier { } /// The different types of Landscape configurations, modelled as an enum to make it easy on the UI side to switch between them. -enum LandscapeConfigType { saas, custom } +enum LandscapeConfigType { manual, custom } /// The alternative errors we could encounter when validating file paths submitted as part of any subform data. enum FileError { @@ -115,7 +115,6 @@ enum FileError { invalidFormat, } -const landscapeSaas = 'landscape.canonical.com'; const validCertExtensions = ['cer', 'crt', 'der', 'pem']; /// The base class for the closed set of Landscape configuration form types. @@ -128,7 +127,7 @@ sealed class LandscapeConfig { } /// The SaaS configuration form data: only the FQDN is mandatory. -class LandscapeSaasConfig extends LandscapeConfig { +class LandscapeManualConfig extends LandscapeConfig { String _fqdn = ''; String get fqdn => _fqdn; bool _fqdnError = false; @@ -142,7 +141,7 @@ class LandscapeSaasConfig extends LandscapeConfig { FileError _fileError = FileError.none; FileError get fileError => _fileError; - // FQDN must be a valid URL (without an explicit port) and must not be the Landscape SaaS URL. + // FQDN must be a valid URL (without an explicit port) and must not be the Landscape URL. bool _validateFQDN(String value) { final uri = Uri.tryParse(value); _fqdnError = value.isEmpty || uri == null || uri.hasPort; diff --git a/gui/packages/ubuntupro/lib/pages/landscape/landscape_page.dart b/gui/packages/ubuntupro/lib/pages/landscape/landscape_page.dart index 873c9fbe6..f687f3199 100644 --- a/gui/packages/ubuntupro/lib/pages/landscape/landscape_page.dart +++ b/gui/packages/ubuntupro/lib/pages/landscape/landscape_page.dart @@ -125,7 +125,7 @@ class LandscapeConfigForm extends StatelessWidget { return Column( children: [ YaruRadioListTile( - value: LandscapeConfigType.saas, + value: LandscapeConfigType.manual, groupValue: model.configType, contentPadding: EdgeInsets.zero, onChanged: model.setConfigType, @@ -150,7 +150,7 @@ class LandscapeConfigForm extends StatelessWidget { } } -/// The subform for quick-configuring Landscape SaaS. +/// The subform for quick-configuring Landscape Manual. class _ManualForm extends StatelessWidget { const _ManualForm(this.model); final LandscapeModel model; @@ -164,10 +164,10 @@ class _ManualForm extends StatelessWidget { TextField( decoration: InputDecoration( label: Text(lang.landscapeFQDNLabel), - errorText: model.saas.fqdnError ? lang.landscapeFQDNError : null, + errorText: model.manual.fqdnError ? lang.landscapeFQDNError : null, ), onChanged: model.setFqdn, - enabled: model.configType == LandscapeConfigType.saas, + enabled: model.configType == LandscapeConfigType.manual, ), const SizedBox(height: 8), TextField( @@ -175,18 +175,18 @@ class _ManualForm extends StatelessWidget { label: Text(lang.landscapeKeyLabel), hintText: '163456', ), - onChanged: model.setSaasRegistrationKey, - enabled: model.configType == LandscapeConfigType.saas, + onChanged: model.setManualRegistrationKey, + enabled: model.configType == LandscapeConfigType.manual, ), const SizedBox(height: 8), _FilePickerField( buttonLabel: lang.landscapeFilePicker, - errorText: model.saas.fileError.localize(lang), + errorText: model.manual.fileError.localize(lang), hint: 'C:\\landscape.pem', inputlabel: lang.landscapeSSLKeyLabel, onChanged: model.setSslKeyPath, allowedExtensions: validCertExtensions, - enabled: model.configType == LandscapeConfigType.saas, + enabled: model.configType == LandscapeConfigType.manual, ), ], ); diff --git a/gui/packages/ubuntupro/test/pages/landscape/landscape_data_model_test.dart b/gui/packages/ubuntupro/test/pages/landscape/landscape_data_model_test.dart index c9f0ab8d7..9d2313024 100644 --- a/gui/packages/ubuntupro/test/pages/landscape/landscape_data_model_test.dart +++ b/gui/packages/ubuntupro/test/pages/landscape/landscape_data_model_test.dart @@ -27,7 +27,7 @@ void main() { }; for (final MapEntry(key: name, value: tc) in testcases.entries) { test(name, () { - final c = LandscapeSaasConfig(); + final c = LandscapeManualConfig(); c.accountName = tc.account; expect(c.accountNameError, tc.wantError); expect(c.isComplete, tc.wantComplete); diff --git a/gui/packages/ubuntupro/test/pages/landscape/landscape_model_test.dart b/gui/packages/ubuntupro/test/pages/landscape/landscape_model_test.dart index dd2065b08..87598db68 100644 --- a/gui/packages/ubuntupro/test/pages/landscape/landscape_model_test.dart +++ b/gui/packages/ubuntupro/test/pages/landscape/landscape_model_test.dart @@ -39,7 +39,7 @@ void main() { expect(notified, isTrue); notified = false; - model.setConfigType(LandscapeConfigType.saas); + model.setConfigType(LandscapeConfigType.manual); expect(notified, isTrue); notified = false; @@ -47,7 +47,7 @@ void main() { expect(notified, isTrue); notified = false; - model.setSaasRegistrationKey('123'); + model.setManualRegistrationKey('123'); expect(notified, isTrue); notified = false; @@ -73,7 +73,7 @@ void main() { final model = LandscapeModel(client); - model.setConfigType(LandscapeConfigType.saas); + model.setConfigType(LandscapeConfigType.manual); // Those assertions exist because the methods are not relevant for the current config type. // Allowing those conditions to proceed could contribute to hide logic errors. expect(() => model.setCustomConfigPath(customConf), throwsAssertionError); @@ -87,13 +87,13 @@ void main() { model.setConfigType(LandscapeConfigType.selfHosted); expect(() => model.setAccountName('testuser'), throwsAssertionError); - expect(() => model.setSaasRegistrationKey('123'), throwsAssertionError); + expect(() => model.setManualRegistrationKey('123'), throwsAssertionError); expect(() => model.setCustomConfigPath(customConf), throwsAssertionError); model.setConfigType(LandscapeConfigType.custom); expect(() => model.setSslKeyPath(customConf), throwsAssertionError); expect(() => model.setAccountName('testuser'), throwsAssertionError); - expect(() => model.setSaasRegistrationKey('123'), throwsAssertionError); + expect(() => model.setManualRegistrationKey('123'), throwsAssertionError); expect(() => model.setFqdn(testFqdn), throwsAssertionError); expect( () => model.setSelfHostedRegistrationKey('123'), @@ -113,7 +113,7 @@ void main() { ); final model = LandscapeModel(client); - model.setConfigType(LandscapeConfigType.saas); + model.setConfigType(LandscapeConfigType.manual); expect(model.applyConfig, throwsAssertionError); model.setAccountName('testaccount'); diff --git a/gui/packages/ubuntupro/test/pages/landscape/landscape_page_test.dart b/gui/packages/ubuntupro/test/pages/landscape/landscape_page_test.dart index 5a25d63e5..60c3cb209 100644 --- a/gui/packages/ubuntupro/test/pages/landscape/landscape_page_test.dart +++ b/gui/packages/ubuntupro/test/pages/landscape/landscape_page_test.dart @@ -75,7 +75,7 @@ void main() { testWidgets('continue enabled', (tester) async { final model = LandscapeModel(MockAgentApiClient()); - model.setConfigType(LandscapeConfigType.saas); + model.setConfigType(LandscapeConfigType.manual); model.setAccountName('testaccount'); final app = buildApp(model);