diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index d44478e7..6746219e 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -923,7 +923,6 @@ class _PipelinesAppState extends State store: SharedPreferencesSettingsStore( serverId: widget.serverId ?? '', ), - onOpenTemplates: _delegate.openTemplates, notifications: _notifications, deliveryService: _deliveryService, deliveryServiceController: _deliveryController, diff --git a/app/lib/features/settings/settings_keys.dart b/app/lib/features/settings/settings_keys.dart index cd9a56b6..337757ff 100644 --- a/app/lib/features/settings/settings_keys.dart +++ b/app/lib/features/settings/settings_keys.dart @@ -9,7 +9,6 @@ abstract final class SettingsKeys { static const reconnect = ValueKey('settings.reconnect'); static const workspace = ValueKey('settings.workspace'); static const saveWorkspace = ValueKey('settings.saveWorkspace'); - static const templates = ValueKey('settings.templates'); static const schedules = ValueKey('settings.schedules'); static const keyboardShortcuts = ValueKey( 'settings.keyboardShortcuts', diff --git a/app/lib/features/settings/settings_schedules_section.dart b/app/lib/features/settings/settings_schedules_section.dart index a531ad0a..54f4efed 100644 --- a/app/lib/features/settings/settings_schedules_section.dart +++ b/app/lib/features/settings/settings_schedules_section.dart @@ -6,7 +6,7 @@ import 'settings_row.dart'; /// The Settings entry to the saved-schedule list. /// /// The row only opens the route; the list's own controller performs the single -/// `list_schedules` read, exactly like the Templates entry. +/// `list_schedules` read. const String settingsSchedulesLabel = 'Browse schedules'; const String settingsSchedulesSecondary = 'Saved run configurations for every pipeline.'; diff --git a/app/lib/features/settings/settings_screen.dart b/app/lib/features/settings/settings_screen.dart index f63093ec..1e63875d 100644 --- a/app/lib/features/settings/settings_screen.dart +++ b/app/lib/features/settings/settings_screen.dart @@ -33,7 +33,6 @@ import 'security/settings_security_section.dart'; import 'settings_updates_section.dart'; import '../updates/app_updates.dart'; import 'settings_store.dart'; -import 'settings_templates_section.dart'; import 'server_connections.dart'; import 'saved_servers_section.dart'; import 'managed_connection_section.dart'; @@ -58,7 +57,6 @@ class SettingsScreen extends StatefulWidget { this.ping, this.embedded = false, this.navigationScope, - this.onOpenTemplates, this.onOpenSchedules, this.notifications, this.showSignIn = false, @@ -108,10 +106,6 @@ class SettingsScreen extends StatefulWidget { /// The logical server scope used to restore the last Settings category. final String? navigationScope; - /// Opens the Templates gallery. Null keeps Settings standalone/incomplete - /// without a dead row that would go nowhere. - final VoidCallback? onOpenTemplates; - /// Opens the saved-schedule list above Settings. final VoidCallback? onOpenSchedules; diff --git a/app/lib/features/settings/settings_templates_section.dart b/app/lib/features/settings/settings_templates_section.dart deleted file mode 100644 index 0334b5ad..00000000 --- a/app/lib/features/settings/settings_templates_section.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'settings_keys.dart'; -import 'settings_row.dart'; - -/// The Settings entry to the Templates gallery. -/// -/// The row wording matches the web Settings page: `Browse templates` with the -/// server-catalogue secondary line. It only opens the route; loading the -/// catalogue is the gallery's own read. -const String settingsTemplatesLabel = 'Browse templates'; -const String settingsTemplatesSecondary = - 'Reusable pipeline definitions offered by the server.'; - -/// A navigation row (chevron) for a Settings group. -class SettingsTemplatesSection extends StatelessWidget { - const SettingsTemplatesSection({super.key, required this.onOpen}); - - final VoidCallback onOpen; - - @override - Widget build(BuildContext context) => SettingsRow( - key: SettingsKeys.templates, - leading: const Icon(Icons.widgets_outlined), - title: const Text(settingsTemplatesLabel), - subtitle: const Text(settingsTemplatesSecondary), - chevron: true, - onTap: onOpen, - ); -} diff --git a/app/lib/features/settings/settings_topic_pages.dart b/app/lib/features/settings/settings_topic_pages.dart index 2be494de..8d89bd49 100644 --- a/app/lib/features/settings/settings_topic_pages.dart +++ b/app/lib/features/settings/settings_topic_pages.dart @@ -87,16 +87,11 @@ extension _SettingsTopicPages on _SettingsScreenState { leadingRows: true, children: const [SettingsKeyboardShortcutsSection()], ), - if (widget.onOpenSchedules != null || widget.onOpenTemplates != null) + if (widget.onOpenSchedules case final open?) SettingsGroup( title: 'Library', leadingRows: true, - children: [ - if (widget.onOpenSchedules case final open?) - SettingsSchedulesSection(onOpen: open), - if (widget.onOpenTemplates case final open?) - SettingsTemplatesSection(onOpen: open), - ], + children: [SettingsSchedulesSection(onOpen: open)], ), ], ), diff --git a/app/notes/remove-templates-from-settings.md b/app/notes/remove-templates-from-settings.md new file mode 100644 index 00000000..00e47a74 --- /dev/null +++ b/app/notes/remove-templates-from-settings.md @@ -0,0 +1,58 @@ +# Remove the Templates entry from Settings + +## What changed +- Deleted `lib/features/settings/settings_templates_section.dart` (the + `Browse templates` chevron row and its label constants). +- Removed `SettingsKeys.templates`, the `onOpenTemplates` parameter and its + doc comment from `SettingsScreen`, and the Templates row from the Tools + topic's Library group (`settings_topic_pages.dart`). The Library group now + renders only when a Schedules route is supplied. +- `pipelines_app.dart` no longer passes `onOpenTemplates`. +- `settings_schedules_section.dart`: doc comment no longer refers to the + Templates entry. + +## Kept on purpose +- The Templates destination (`lib/application/templates_destination.dart`), + the `AppRoute.templates` kind, its codec (`/templates`, `/settings/templates` + aliases), `AppRouter.openTemplates`/`closeTemplates`, and the templates + feature under `lib/features/templates/`. They remain reachable by URL + (`/templates`, `/settings/templates`) and by `AppRouter.openTemplates`, so + they are not solely reachable from the removed row. Removing them is a + separate follow-up if the route itself should go. + +## Tests +- `test/application/templates_wiring_test.dart` and + `test/application/templates_behind_bar_test.dart` used to reach Templates by + tapping the Settings row. They now boot at `/pipelines` and push `/templates` + by route, then assert the same embedded page, bar, refresh, detail and + create expectations. The Settings-only assertions (edited server URL + surviving the detour, the Settings row being present, the `ping` answer) + were removed with the row. +- `readTemplates` in `templates_wiring_test.dart` settles the frame after the + list reply before answering `validate`, because the shell's own `ping` + shares the request queue. +- New `test/features/settings/settings_library_test.dart`: Tools shows + `Library` with Schedules and no `Browse templates`; Schedules still calls its + route; without a Schedules route the Library group is absent. + +## Focused results (app/, `tool/memwatch/full.sh`) +- Baseline on the untouched worktree, 4 files: 31 passed, 0 failed. +- After the change, 10 files (the 4 above plus `settings_library_test.dart`, + `settings_topic_restore_test.dart`, `settings_screen_test.dart`, + `settings_layout_test.dart`, `settings_tabs_test.dart`, + `settings_shell_background_test.dart`): 61 passed, 0 failed. +- `tool/analyze.sh`: clean. +- Not run: the whole `test` directory (left to the land gate), and no UI + capture was made. + +## Affected states (not yet captured) +- Settings > Tools: Library group shows Schedules only. +- `/templates` and `/settings/templates` deep links: still open the embedded + Templates page; Back returns to Settings. + +## Known leftovers +- `app/tool/templates_wiring_probe*`, `templates_gallery_probe*` and + `template_create_probe.dart` drive Settings > Templates and will fail + against this build. They were not edited or run here. +- `app/PARITY.md`, `app/WORK.md` and `app/pipelines/flutter-design.md` may + still describe the Settings entry; they were not reviewed. diff --git a/app/test/application/templates_behind_bar_test.dart b/app/test/application/templates_behind_bar_test.dart index 4036a787..1ed93027 100644 --- a/app/test/application/templates_behind_bar_test.dart +++ b/app/test/application/templates_behind_bar_test.dart @@ -8,7 +8,7 @@ import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; import '../core/transport/pipelines_client_test.dart' show FakeChannel; import '../features/pipelines/fixtures.dart'; import 'pipelines_replies.dart'; -import 'templates_wiring_test.dart' show openSettings, openTemplates, pumpApp; +import 'templates_wiring_test.dart' show pumpApp, readTemplates; /// The app-level Templates page: one bar (Back + Refresh), the gallery and an /// open template reach the top edge, start below the bar at rest and scroll @@ -23,8 +23,10 @@ void main() { addTearDown(provider.dispose); await pumpApp(tester, channel: channel, client: client, provider: provider); await replyPipelines(tester, channel, PipelineFixture()); - await openSettings(tester, channel, provider); - await openTemplates(tester, channel, provider); + await provider.didPushRouteInformation( + RouteInformation(uri: Uri.parse('/templates')), + ); + await readTemplates(tester, channel); await tester.pumpAndSettle(); final bar = find.ancestor( diff --git a/app/test/application/templates_wiring_test.dart b/app/test/application/templates_wiring_test.dart index a3afe0dd..20bf9c87 100644 --- a/app/test/application/templates_wiring_test.dart +++ b/app/test/application/templates_wiring_test.dart @@ -5,7 +5,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/application/pipelines_app.dart'; import 'package:pipelines_app/application/templates_destination.dart'; import 'package:pipelines_app/core/transport/pipelines_client.dart'; -import 'package:pipelines_app/features/settings/settings_keys.dart'; import 'package:pipelines_app/features/templates/screen.dart'; import 'package:pipelines_app/features/templates/ui/template_create_wording.dart'; import 'package:pipelines_app/features/templates/ui/template_detail.dart' @@ -18,7 +17,6 @@ import '../features/templates/ui/template_gallery_test_support.dart' show GalleryGateway, galleryTemplates, pumpGallery, templatesReply; import 'pipelines_app_test.dart' show webServer; import 'pipelines_replies.dart'; -import '../features/settings/settings_topic_test_helper.dart'; import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; List> requestsOf(FakeChannel channel, String type) => @@ -85,38 +83,13 @@ Future pumpApp( await tester.pump(); } -Future openSettings( +/// Answers the reads a Templates page makes when it opens by route. +Future readTemplates( WidgetTester tester, - FakeChannel channel, - PlatformRouteInformationProvider provider, -) async { - await tester.tap(find.byKey(const Key('pipelines-open-settings'))); - await tester.pump(); - await tester.pump(); - expect(provider.value.uri.path, '/settings'); - // Settings pings the shared socket; answer it so later reads are not queued. - await reply(tester, channel, 'ping', 1, { - 'type': 'pong', - 'build': {'version': 'probe'}, - 'time': 'fixture', - }); - // Hidden notification settings do not load during this navigation flow. - expect(requestsOf(channel, 'notification_settings'), isEmpty); - await selectSettingsTopic(tester, 'Connection'); -} - -Future openTemplates( - WidgetTester tester, - FakeChannel channel, - PlatformRouteInformationProvider provider, { + FakeChannel channel, { int listRead = 1, }) async { - await selectSettingsTopic(tester, 'Tools'); - await tester.ensureVisible(find.byKey(SettingsKeys.templates)); - await tester.tap(find.byKey(SettingsKeys.templates)); - await tester.pump(); await tester.pump(const Duration(milliseconds: 600)); - expect(provider.value.uri.path, '/templates'); await reply(tester, channel, 'list_templates', listRead, { 'type': 'templates', 'templates': [ @@ -129,6 +102,9 @@ Future openTemplates( }, ], }); + // The shell's own ping shares the request queue; let it go out before the + // gallery's validate reads, as the list read is followed by the shell's ping. + await tester.pumpAndSettle(); await reply(tester, channel, 'validate', listRead, { 'type': 'graph', 'graph': {'stages': []}, @@ -153,7 +129,7 @@ void main() { }); testWidgets( - 'Settings opens the embedded Templates page and Back restores it', + 'a /templates link opens the embedded page and Back restores Settings', (tester) async { final fixture = PipelineFixture(); final channel = FakeChannel()..readyCompleter.complete(); @@ -176,14 +152,12 @@ void main() { provider: provider, ); await replyPipelines(tester, channel, fixture); + await provider.didPushRouteInformation( + RouteInformation(uri: Uri.parse('/templates')), + ); + await readTemplates(tester, channel); + await tester.pumpAndSettle(); - await openSettings(tester, channel, provider); - // An edit that only Settings owns must survive the Templates detour. - await tester.enterText(find.byType(EditableText).first, 'edited url'); - await tester.pump(); - expect(find.text('edited url'), findsOneWidget); - - await openTemplates(tester, channel, provider); final screen = tester.widget( find.byType(TemplatesScreen), ); @@ -214,8 +188,8 @@ void main() { expect(find.byKey(templateDetailBackKey), findsOneWidget); expect(find.byKey(templatesPageBackKey), findsNothing); - // Detail Back returns to the gallery, then the page Back restores the - // same Settings state. + // Detail Back returns to the gallery, then the page Back closes the + // page to Settings. await tester.tap(find.byKey(templateDetailBackKey)); await tester.pump(); // The gallery hands the bar back to the page's Back on the next frame. @@ -225,15 +199,14 @@ void main() { expect(provider.value.uri.path, '/settings'); expect(find.byType(TemplatesScreen), findsNothing); - expect(find.byKey(SettingsKeys.templates), findsOneWidget); - await selectSettingsTopic(tester, 'Connection'); - expect(find.text('edited url'), findsOneWidget); - expect(find.text('Server URL'), findsOneWidget); expect(sockets, 1); - expect(requestsOf(channel, 'ping'), hasLength(1)); // Browser Back from /templates follows the same close path. - await openTemplates(tester, channel, provider, listRead: 2); + await provider.didPushRouteInformation( + RouteInformation(uri: Uri.parse('/templates')), + ); + await readTemplates(tester, channel, listRead: 2); + await tester.pumpAndSettle(); expect(find.byType(TemplatesScreen), findsOneWidget); await provider.didPushRouteInformation( RouteInformation(uri: Uri.parse('/settings')), @@ -241,9 +214,6 @@ void main() { await tester.pumpAndSettle(); expect(provider.value.uri.path, '/settings'); expect(find.byType(TemplatesScreen), findsNothing); - expect(find.byKey(SettingsKeys.templates), findsOneWidget); - await selectSettingsTopic(tester, 'Connection'); - expect(find.text('edited url'), findsOneWidget); expect(requestsOf(channel, 'list_templates'), hasLength(2)); expect(sockets, 1); @@ -271,13 +241,15 @@ void main() { await pumpApp(tester, channel: channel, client: client, provider: provider); await replyPipelines(tester, channel, fixture); + await provider.didPushRouteInformation( + RouteInformation(uri: Uri.parse('/templates')), + ); expect( find.byKey(const Key('pipeline-row-41'), skipOffstage: false), findsNothing, ); - await openSettings(tester, channel, provider); - await openTemplates(tester, channel, provider); + await readTemplates(tester, channel); await tester.tap(find.byKey(templateRowKey('release'))); await tester.pump(); await tester.tap(find.byKey(templateCreateActionKey)); diff --git a/app/test/features/settings/settings_library_test.dart b/app/test/features/settings/settings_library_test.dart new file mode 100644 index 00000000..6fa165b3 --- /dev/null +++ b/app/test/features/settings/settings_library_test.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/core/transport/pipelines_client.dart' + as transport; +import 'package:pipelines_app/features/settings/settings_keys.dart'; +import 'package:pipelines_app/features/settings/settings_screen.dart'; +import 'package:pipelines_app/features/settings/settings_store.dart'; + +import 'fake_channel.dart'; +import 'settings_topic_test_helper.dart'; + +/// The Tools topic's Library group lists Schedules only: Templates left +/// Settings, and Schedules keeps its own route. +void main() { + Future pump( + WidgetTester tester, { + VoidCallback? onOpenSchedules, + }) async { + await tester.binding.setSurfaceSize(const Size(560, 1000)); + addTearDown(() => tester.binding.setSurfaceSize(null)); + final factory = FakeChannelFactory(); + final client = transport.PipelinesClient(channelFactory: factory.call); + addTearDown(client.dispose); + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: SettingsScreen( + client: client, + store: MemorySettingsStore(), + embedded: true, + onOpenSchedules: onOpenSchedules, + ), + ), + ), + ); + await tester.pump(); + await selectSettingsTopic(tester, 'Tools'); + } + + testWidgets('Tools offers Schedules and no Templates entry', (tester) async { + var opened = 0; + await pump(tester, onOpenSchedules: () => opened++); + + expect(find.text('Library'), findsOneWidget); + expect(find.text('Browse templates'), findsNothing); + expect( + find.byKey(const ValueKey('settings.templates')), + findsNothing, + ); + + await tester.ensureVisible(find.byKey(SettingsKeys.schedules)); + await tester.tap(find.byKey(SettingsKeys.schedules)); + await tester.pump(); + expect(opened, 1); + }); + + testWidgets('without a Schedules route the Library group is absent', ( + tester, + ) async { + await pump(tester); + + expect(find.text('Library'), findsNothing); + expect(find.text('Browse templates'), findsNothing); + expect(find.byKey(SettingsKeys.schedules), findsNothing); + }); +}