Skip to content

Commit

Permalink
prompt to remove ceph remount on share deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaboud committed Nov 27, 2024
1 parent faf3a25 commit cc5f85e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
29 changes: 27 additions & 2 deletions file-sharing/src/common/ui/CephOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<void, Error>[];
if (tempOptions.value.remounted && !currentOptions.remounted) {
Expand All @@ -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<number>[] = [
{ label: "MiB", value: 2 },
Expand Down
10 changes: 8 additions & 2 deletions file-sharing/src/tabs/nfs/ui/NFSExportListView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, computed, defineProps } from "vue";
import { ref, computed, defineProps, nextTick } from "vue";
import type { NFSExport } from "@/tabs/nfs/data-types";
import {
CardContainer,
Expand Down Expand Up @@ -80,7 +80,13 @@ const allExportedPaths = computed(() => props.nfsExports.map(({ path }) => path)
<span class="sr-only">Edit</span>
<PencilSquareIcon class="size-icon icon-default" />
</button>
<button @click="emit('removeExport', nfsExport)">
<button
@click="
// for fileystem-specific hooks:
setShowEditor(true);
nextTick(() => emit('removeExport', nfsExport));
"
>
<span class="sr-only">Delete</span>
<TrashIcon class="size-icon icon-danger" />
</button>
Expand Down
10 changes: 8 additions & 2 deletions file-sharing/src/tabs/samba/ui/ShareListView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, computed, defineProps } from "vue";
import { ref, computed, defineProps, nextTick } from "vue";
import type { SambaShareConfig } from "@/tabs/samba/data-types";
import {
CardContainer,
Expand Down Expand Up @@ -86,7 +86,13 @@ const shareNames = computed(() => props.shares.map((s) => s.name));
<span class="sr-only">Edit</span>
<PencilSquareIcon class="size-icon icon-default" />
</button>
<button @click="emit('removeShare', share)">
<button
@click="
// for fileystem-specific hooks:
setShowEditor(true);
nextTick(() => emit('removeShare', share));
"
>
<span class="sr-only">Delete</span>
<TrashIcon class="size-icon icon-danger" />
</button>
Expand Down

0 comments on commit cc5f85e

Please sign in to comment.