From b78782875d0788c42c2ff7f55cd41c5dc0660455 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sun, 5 Oct 2025 13:15:48 -0500 Subject: [PATCH] Add remove mount capabilities to CLI and UI #62 --- web/repertory/lib/models/mount.dart | 23 +++++++++++++++++++++ web/repertory/lib/models/mount_list.dart | 5 +++++ web/repertory/lib/widgets/mount_widget.dart | 7 +++++++ 3 files changed, 35 insertions(+) diff --git a/web/repertory/lib/models/mount.dart b/web/repertory/lib/models/mount.dart index 0575c646..1bb9e578 100644 --- a/web/repertory/lib/models/mount.dart +++ b/web/repertory/lib/models/mount.dart @@ -282,6 +282,29 @@ class Mount with ChangeNotifier { _isRefreshing = false; } + Future remove() async { + try { + final auth = await _auth.createAuth(); + final response = await http.delete( + Uri.parse( + Uri.encodeFull( + '${getBaseUri()}/api/v1/remove_mount?auth=$auth&name=$name&type=$type}', + ), + ), + ); + + if (response.statusCode == 401) { + _auth.logoff(); + } + + if (response.statusCode == 200) { + _mountList?.remove(name, type); + } + } catch (e) { + debugPrint('$e'); + } + } + Future setValue(String key, String value) async { try { final auth = await _auth.createAuth(); diff --git a/web/repertory/lib/models/mount_list.dart b/web/repertory/lib/models/mount_list.dart index e1e0a047..72308409 100644 --- a/web/repertory/lib/models/mount_list.dart +++ b/web/repertory/lib/models/mount_list.dart @@ -182,6 +182,11 @@ class MountList with ChangeNotifier { notifyListeners(); } + void remove(String name, String type) { + _mountList.removeWhere((mount) => mount.name == name && mount.type == type); + notifyListeners(); + } + Future reset() async { if (_mountList.isEmpty) { return; diff --git a/web/repertory/lib/widgets/mount_widget.dart b/web/repertory/lib/widgets/mount_widget.dart index 7a48a941..a1e33212 100644 --- a/web/repertory/lib/widgets/mount_widget.dart +++ b/web/repertory/lib/widgets/mount_widget.dart @@ -89,6 +89,13 @@ class _MountWidgetState extends State ], ), ), + if (!mounted) + AppIconButtonFramed( + icon: Icons.delete, + onTap: () async { + return mount.remove(); + }, + ), AppToggleButtonFramed( mounted: mount.mounted, onPressed: _createMountHandler(context, mount),