From cc5f85efcc7694d7b649a26192f3f7943444991f Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Wed, 27 Nov 2024 18:09:14 -0400 Subject: [PATCH] prompt to remove ceph remount on share deletion --- file-sharing/src/common/ui/CephOptions.vue | 29 +++++++++++++++++-- .../src/tabs/nfs/ui/NFSExportListView.vue | 10 +++++-- .../src/tabs/samba/ui/ShareListView.vue | 10 +++++-- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/file-sharing/src/common/ui/CephOptions.vue b/file-sharing/src/common/ui/CephOptions.vue index bb0de9a..90067aa 100644 --- a/file-sharing/src/common/ui/CephOptions.vue +++ b/file-sharing/src/common/ui/CephOptions.vue @@ -20,11 +20,12 @@ import { reportSuccess, SelectMenu, type SelectMenuOption, + confirm, } from "@45drives/houston-common-ui"; import { Maybe } from "monet"; import { getCephOptionManager } from "@/common/ceph-option-manager"; import { Hooks, useHookCallback } from "@/common/hooks"; -import { ok, ResultAsync } from "neverthrow"; +import { ok, ResultAsync, okAsync } from "neverthrow"; import { useTempObjectStaging } from "@45drives/houston-common-ui"; const _ = cockpit.gettext; @@ -179,7 +180,7 @@ watch( useHookCallback([Hooks.BeforeAddShare, Hooks.BeforeEditShare], (_, share) => { if (!modified.value || share.path != path.value) { - return; + return okAsync(undefined); } const results = [] as ResultAsync[]; if (tempOptions.value.remounted && !currentOptions.remounted) { @@ -206,6 +207,30 @@ useHookCallback([Hooks.BeforeAddShare, Hooks.BeforeEditShare], (_, share) => { return ResultAsync.combine(results).map(() => {}); }); +useHookCallback(Hooks.BeforeRemoveShare, (_server, share) => { + if ( + share.path != path.value || + !(currentOptions.remounted && remountManagedByFileSharing.value) + ) { + return okAsync(undefined); + } + return confirm({ + header: _("Remove Ceph Remount?"), + body: _( + `Share was remounted by File Sharing for proper reporting of quotas. +If this path is shared in another tab, you may want to keep it.` + ), + dangerous: true, + confirmButtonText: _("Remove"), + cancelButtonText: _("Keep"), + }).andThen((remove) => { + if (remove) { + return actions.removeRemount(); + } + return okAsync(undefined); + }); +}); + const quotaUnitBase = 1024; const quotaUnitExponentOptions: SelectMenuOption[] = [ { label: "MiB", value: 2 }, diff --git a/file-sharing/src/tabs/nfs/ui/NFSExportListView.vue b/file-sharing/src/tabs/nfs/ui/NFSExportListView.vue index 43729ff..03738d8 100644 --- a/file-sharing/src/tabs/nfs/ui/NFSExportListView.vue +++ b/file-sharing/src/tabs/nfs/ui/NFSExportListView.vue @@ -1,5 +1,5 @@