feat(app): delete a page from its menu, next to the hub conversions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 03:55:01 +01:00
1 parent d76f40bebb
commit 3d754a83e6
3 files changed
+58 -1

No files matched your search

+32 -1
View File
@@ -9,6 +9,7 @@ import '../widgets/common.dart';
import '../widgets/dates.dart';
import '../widgets/pickers.dart';
import '../widgets/tags.dart';
import 'all_pages_view.dart' show DeletePagesDialog;
import 'convert_dialog.dart';
import 'graph_view.dart';
import 'hub_screen.dart';
@@ -661,7 +662,7 @@ class InHubs extends StatelessWidget {
}
}
/// The page's "⋯" menu: hub conversion and hub membership.
/// The page's "⋯" menu: hub conversion, hub membership and deletion.
class PageMenu extends StatelessWidget {
const PageMenu({super.key, required this.page, required this.structure});
final PageDto page;
@@ -724,6 +725,26 @@ class PageMenu extends StatelessWidget {
}
}
Future<void> _delete(BuildContext context) async {
final app = AppScope.read(context);
final messenger = ScaffoldMessenger.of(context);
final ok = await showDialog<bool>(
context: context,
builder: (_) => DeletePagesDialog(pages: [page]),
);
if (ok != true) return;
try {
await app.queue.run(() => app.backend.deletePage(page.id));
} catch (e) {
messenger.showSnackBar(SnackBar(content: Text(errorText(e))));
app.reload();
return;
}
// Tabs showing the page step back (or fall back to Journals); recents drop it.
app.pagesDeleted([page.id]);
messenger.showSnackBar(SnackBar(content: Text('Deleted "${page.title}"')));
}
@override
Widget build(BuildContext context) => PopupMenuButton<String>(
key: const ValueKey('page-menu'),
@@ -732,6 +753,7 @@ class PageMenu extends StatelessWidget {
onSelected: (v) => switch (v) {
'hub' => _toHub(context),
'note' => _toNote(context),
'delete' => _delete(context),
_ => _addToHub(context),
},
itemBuilder: (_) => [
@@ -740,6 +762,15 @@ class PageMenu extends StatelessWidget {
if (page.isHub)
const PopupMenuItem(value: 'note', child: Text('Convert to note')),
const PopupMenuItem(value: 'add', child: Text('Add to hub…')),
const PopupMenuDivider(),
PopupMenuItem(
key: const ValueKey('page-delete'),
value: 'delete',
child: Text(
'Delete page…',
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
),
],
);
}
+24
View File
@@ -241,6 +241,30 @@ void main() {
expect(() => b.addToHub(fun.id, tv.id), throwsException);
});
testWidgets('a page can be deleted from its menu, after confirming', (
tester,
) async {
final b = demo();
final games = byTitle(b, 'Games');
final app = await pump(tester, b, route: PageTarget(id: games.id));
await tester.tap(find.byKey(const ValueKey('page-menu')));
await settle(tester);
await tester.tap(find.byKey(const ValueKey('page-delete')));
await settle(tester);
// Cancel keeps it.
await tester.tap(find.text('Cancel'));
await settle(tester);
expect(b.pages.containsKey(games.id), isTrue);
await tester.tap(find.byKey(const ValueKey('page-menu')));
await settle(tester);
await tester.tap(find.byKey(const ValueKey('page-delete')));
await settle(tester);
await tester.tap(find.byKey(const ValueKey('confirm-delete')));
await settle(tester);
expect(b.pages.containsKey(games.id), isFalse);
expect(app.route, isNot(PageTarget(id: games.id)));
});
testWidgets('note page: In chips can be removed, no hub pill', (
tester,
) async {
+2
View File
@@ -164,6 +164,8 @@ Both are plain names with no page, shown as one row of pills under the title.
- Notes: namespace breadcrumb, "In: ..." chips with a × to leave a hub, and a `⋯` menu
with "Convert to hub…" (dialog: shortened title, description, member checklist, optional
note that keeps the original outline; title clashes are shown inline) and "Add to hub…".
- Every page's `⋯` menu (notes and hubs) ends with "Delete page…": the same confirmation as
All pages; tabs showing it step back (or fall back to Journals) and recents drop it.
- All pages ▸ "Clean up": dialog listing legacy Logseq pages (`contents`, `hls__...`, pages
with `type:: system`, ...) with checkboxes; "Delete (n)" removes only the checked ones
and their blocks.