-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17437 from jmchilton/change_os_gui
UI for "relocating" a dataset to a new object store (when safe)
- Loading branch information
Showing
17 changed files
with
413 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
client/src/components/Dataset/DatasetStorage/RelocateDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<script setup lang="ts"> | ||
import { ConcreteObjectStoreModel } from "@/api"; | ||
import ObjectStoreSelectButton from "@/components/ObjectStore/ObjectStoreSelectButton.vue"; | ||
import ObjectStoreSelectButtonDescribePopover from "@/components/ObjectStore/ObjectStoreSelectButtonDescribePopover.vue"; | ||
interface RelocateProps { | ||
fromObjectStore: ConcreteObjectStoreModel; | ||
targetObjectStores: ConcreteObjectStoreModel[]; | ||
} | ||
defineProps<RelocateProps>(); | ||
const emit = defineEmits<{ | ||
(e: "relocate", value: string): void; | ||
}>(); | ||
const fromWhat = "This dataset location in a"; | ||
const toWhat = "This dataset will be relocated to"; | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<p>Relocate the dataset's current object store of:</p> | ||
<b-button-group vertical size="lg" class="select-button-group"> | ||
<ObjectStoreSelectButton | ||
:key="fromObjectStore.object_store_id" | ||
id-prefix="swap-target" | ||
class="swap-target-object-store-select-button" | ||
variant="info" | ||
:object-store="fromObjectStore" /> | ||
</b-button-group> | ||
<p>Select a new object store below to relocate the dataset</p> | ||
<b-button-group vertical size="lg" class="select-button-group"> | ||
<ObjectStoreSelectButton | ||
v-for="objectStore in targetObjectStores" | ||
:key="objectStore.object_store_id" | ||
id-prefix="swap-target" | ||
class="swap-target-object-store-select-button" | ||
variant="outline-primary" | ||
:object-store="objectStore" | ||
@click="emit('relocate', objectStore.object_store_id)" /> | ||
</b-button-group> | ||
<ObjectStoreSelectButtonDescribePopover | ||
id-prefix="swap-target" | ||
:what="fromWhat" | ||
:object-store="fromObjectStore" /> | ||
<ObjectStoreSelectButtonDescribePopover | ||
v-for="objectStore in targetObjectStores" | ||
:key="objectStore.object_store_id" | ||
id-prefix="swap-target" | ||
:what="toWhat" | ||
:object-store="objectStore" /> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.select-button-group { | ||
display: block; | ||
margin: auto; | ||
width: 400px; | ||
} | ||
</style> |
95 changes: 95 additions & 0 deletions
95
client/src/components/Dataset/DatasetStorage/RelocateLink.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<script setup lang="ts"> | ||
import { storeToRefs } from "pinia"; | ||
import { computed, ref } from "vue"; | ||
import { ConcreteObjectStoreModel, DatasetStorageDetails } from "@/api"; | ||
import { updateObjectStore } from "@/api/objectStores"; | ||
import { useObjectStoreStore } from "@/stores/objectStoreStore"; | ||
import RelocateDialog from "./RelocateDialog.vue"; | ||
import SelectModal from "./SelectModal.vue"; | ||
interface RelocateLinkProps { | ||
datasetStorageDetails: DatasetStorageDetails; | ||
datasetId: string; | ||
} | ||
const props = defineProps<RelocateLinkProps>(); | ||
const showModal = ref(false); | ||
const store = useObjectStoreStore(); | ||
const { isLoaded, selectableObjectStores } = storeToRefs(store); | ||
const currentObjectStore = computed<ConcreteObjectStoreModel | null>(() => { | ||
const isLoadedVal = isLoaded.value; | ||
const objectStores = selectableObjectStores.value; | ||
const currentObjectStoreId = props.datasetStorageDetails.object_store_id; | ||
if (!isLoadedVal) { | ||
return null; | ||
} | ||
if (!objectStores) { | ||
return null; | ||
} | ||
const filtered: ConcreteObjectStoreModel[] = objectStores.filter( | ||
(objectStore) => objectStore.object_store_id == currentObjectStoreId | ||
); | ||
return filtered && filtered.length > 0 ? (filtered[0] as ConcreteObjectStoreModel) : null; | ||
}); | ||
const validTargets = computed<ConcreteObjectStoreModel[]>(() => { | ||
const isLoadedVal = isLoaded.value; | ||
const objectStores = selectableObjectStores.value; | ||
const currentObjectStoreId = props.datasetStorageDetails.object_store_id; | ||
if (!isLoadedVal) { | ||
return []; | ||
} | ||
if (!objectStores) { | ||
return []; | ||
} | ||
if (!currentObjectStore.value) { | ||
return []; | ||
} | ||
const currentDevice = currentObjectStore.value.device; | ||
if (!currentDevice) { | ||
return []; | ||
} | ||
const validTargets: ConcreteObjectStoreModel[] = objectStores.filter( | ||
(objectStore) => objectStore.device == currentDevice && objectStore.object_store_id != currentObjectStoreId | ||
); | ||
return validTargets as ConcreteObjectStoreModel[]; | ||
}); | ||
const relocatable = computed(() => { | ||
return validTargets.value.length > 0; | ||
}); | ||
const emit = defineEmits<{ | ||
(e: "relocated"): void; | ||
}>(); | ||
async function relocate(objectStoreId: string) { | ||
try { | ||
await updateObjectStore(props.datasetId, objectStoreId); | ||
emit("relocated"); | ||
} catch (err) { | ||
console.log(err); | ||
} finally { | ||
showModal.value = false; | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<span class="storage-relocate-link"> | ||
<SelectModal v-if="currentObjectStore" v-model="showModal" title="Relocate Dataset Storage"> | ||
<RelocateDialog | ||
:from-object-store="currentObjectStore" | ||
:target-object-stores="validTargets" | ||
@relocate="relocate" /> | ||
</SelectModal> | ||
<b-link v-if="relocatable" href="#" @click="showModal = true">(relocate)</b-link> | ||
</span> | ||
</template> |
33 changes: 33 additions & 0 deletions
33
client/src/components/Dataset/DatasetStorage/SelectModal.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<script setup lang="ts"> | ||
import { ref, watch } from "vue"; | ||
interface SelectModalProps { | ||
value: boolean; | ||
title: string; | ||
} | ||
const props = defineProps<SelectModalProps>(); | ||
const show = ref(props.value); | ||
watch(props, () => { | ||
show.value = props.value; | ||
}); | ||
const emit = defineEmits<{ | ||
(e: "input", value: boolean): void; | ||
}>(); | ||
watch(show, () => { | ||
emit("input", show.value); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<b-modal v-model="show" hide-footer> | ||
<template v-slot:modal-title> | ||
<h2>{{ title }}</h2> | ||
</template> | ||
<slot /> | ||
</b-modal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
client/src/components/ObjectStore/ObjectStoreSelectButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script setup lang="ts"> | ||
import { BButton } from "bootstrap-vue"; | ||
import { type ConcreteObjectStoreModel } from "@/api"; | ||
import ObjectStoreBadges from "@/components/ObjectStore/ObjectStoreBadges.vue"; | ||
import ProvidedQuotaSourceUsageBar from "@/components/User/DiskUsage/Quota/ProvidedQuotaSourceUsageBar.vue"; | ||
interface ObjectStoreSelectButtonProps { | ||
objectStore: ConcreteObjectStoreModel; | ||
variant: string; | ||
idPrefix: string; | ||
} | ||
defineProps<ObjectStoreSelectButtonProps>(); | ||
const emit = defineEmits<{ | ||
(e: "click", value: string): void; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<BButton | ||
:id="`${idPrefix}-object-store-button-${objectStore.object_store_id}`" | ||
:variant="variant" | ||
:data-object-store-id="objectStore.object_store_id" | ||
@click="emit('click', objectStore.object_store_id)" | ||
>{{ objectStore.name }} | ||
<ObjectStoreBadges :badges="objectStore.badges" size="lg" :more-on-hover="false" /> | ||
<ProvidedQuotaSourceUsageBar :object-store="objectStore" :compact="true"> </ProvidedQuotaSourceUsageBar> | ||
</BButton> | ||
</template> |
29 changes: 29 additions & 0 deletions
29
client/src/components/ObjectStore/ObjectStoreSelectButtonDescribePopover.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { type ConcreteObjectStoreModel } from "@/api"; | ||
import DescribeObjectStore from "./DescribeObjectStore.vue"; | ||
import ObjectStoreSelectButtonPopover from "./ObjectStoreSelectButtonPopover.vue"; | ||
interface ObjectStoreSelectButtonPopoverDescribeProps { | ||
idPrefix: string; | ||
what: string; | ||
objectStore: ConcreteObjectStoreModel; | ||
} | ||
const props = defineProps<ObjectStoreSelectButtonPopoverDescribeProps>(); | ||
const target = computed(() => { | ||
return `${props.idPrefix}-object-store-button-${props.objectStore.object_store_id}`; | ||
}); | ||
const title = computed(() => { | ||
return props.objectStore.name; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<ObjectStoreSelectButtonPopover :target="target" :title="title"> | ||
<DescribeObjectStore :what="what" :storage-info="objectStore"> </DescribeObjectStore> | ||
</ObjectStoreSelectButtonPopover> | ||
</template> |
19 changes: 19 additions & 0 deletions
19
client/src/components/ObjectStore/ObjectStoreSelectButtonPopover.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script setup lang="ts"> | ||
import { BPopover } from "bootstrap-vue"; | ||
interface ObjectStoreSelectButtonPopoverProps { | ||
target: string; | ||
title: string; | ||
} | ||
defineProps<ObjectStoreSelectButtonPopoverProps>(); | ||
const boundary = "window"; // don't warp the popover to squeeze it into this modal | ||
</script> | ||
|
||
<template> | ||
<BPopover :target="target" triggers="hover" placement="rightbottom" :boundary="boundary"> | ||
<template v-slot:title>{{ title }}</template> | ||
<slot /> | ||
</BPopover> | ||
</template> |
Oops, something went wrong.