Remove Templates from Settings

Keep the Templates destination available through its direct routes while removing the obsolete Settings entry and wiring. Update navigation coverage and document the preserved route behavior.
This commit is contained in:
2026-11-12 01:02:11 +00:00
parent 4f1b45571f
commit 1e07ab1ddc
10 changed files with 155 additions and 100 deletions
-1
View File
@@ -923,7 +923,6 @@ class _PipelinesAppState extends State<PipelinesApp>
store: SharedPreferencesSettingsStore(
serverId: widget.serverId ?? '',
),
onOpenTemplates: _delegate.openTemplates,
notifications: _notifications,
deliveryService: _deliveryService,
deliveryServiceController: _deliveryController,
@@ -9,7 +9,6 @@ abstract final class SettingsKeys {
static const reconnect = ValueKey<String>('settings.reconnect');
static const workspace = ValueKey<String>('settings.workspace');
static const saveWorkspace = ValueKey<String>('settings.saveWorkspace');
static const templates = ValueKey<String>('settings.templates');
static const schedules = ValueKey<String>('settings.schedules');
static const keyboardShortcuts = ValueKey<String>(
'settings.keyboardShortcuts',
@@ -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.';
@@ -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;
@@ -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,
);
}
@@ -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)],
),
],
),
@@ -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.
@@ -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(
+23 -51
View File
@@ -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<Map<String, dynamic>> requestsOf(FakeChannel channel, String type) =>
@@ -85,38 +83,13 @@ Future<void> pumpApp(
await tester.pump();
}
Future<void> openSettings(
/// Answers the reads a Templates page makes when it opens by route.
Future<void> 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<void> 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<void> 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': <dynamic>[]},
@@ -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<TemplatesScreen>(
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));
@@ -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<void> 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<String>('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);
});
}