diff --git a/web/repertory/lib/models/mount.dart b/web/repertory/lib/models/mount.dart index 0b06b4bb..349b213e 100644 --- a/web/repertory/lib/models/mount.dart +++ b/web/repertory/lib/models/mount.dart @@ -253,4 +253,33 @@ class Mount with ChangeNotifier { debugPrint('$e'); } } + + Future clearPath() async { + try { + mountConfig.path = ""; + + final auth = await _auth.createAuth(); + final response = await http.delete( + Uri.parse( + Uri.encodeFull( + '${getBaseUri()}/api/v1/mount_location?auth=$auth&name=$name&type=$type', + ), + ), + ); + + if (response.statusCode == 401) { + _auth.logoff(); + return; + } + + if (response.statusCode == 404) { + _mountList?.reset(); + return; + } + + return refresh(); + } catch (e) { + debugPrint('$e'); + } + } } diff --git a/web/repertory/lib/widgets/mount_widget.dart b/web/repertory/lib/widgets/mount_widget.dart index 966e0705..608f2e24 100644 --- a/web/repertory/lib/widgets/mount_widget.dart +++ b/web/repertory/lib/widgets/mount_widget.dart @@ -61,19 +61,28 @@ class _MountWidgetState extends State { mount.provider, style: TextStyle(color: textColor, fontWeight: FontWeight.bold), ), - trailing: IconButton( - icon: Icon( - mount.mounted == null - ? Icons.hourglass_top - : mount.mounted! - ? Icons.toggle_on - : Icons.toggle_off, - color: - mount.mounted ?? false - ? Color.fromARGB(255, 163, 96, 76) - : subTextColor, - ), - onPressed: _createMountHandler(context, mount), + trailing: Row( + children: [ + if (mount.mounted != null && !mount.mounted!) + IconButton( + icon: Icon(Icons.clear), + onPressed: () => mount.clearPath(), + ), + IconButton( + icon: Icon( + mount.mounted == null + ? Icons.hourglass_top + : mount.mounted! + ? Icons.toggle_on + : Icons.toggle_off, + color: + mount.mounted ?? false + ? Color.fromARGB(255, 163, 96, 76) + : subTextColor, + ), + onPressed: _createMountHandler(context, mount), + ), + ], ), ); },