forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI for "relocating" a dataset's object store.
- Loading branch information
Showing
9 changed files
with
280 additions
and
16 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
67 changes: 67 additions & 0 deletions
67
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,67 @@ | ||
<script setup lang="ts"> | ||
import { ConcreteObjectStoreModel } from "@/api"; | ||
import DescribeObjectStore from "@/components/ObjectStore/DescribeObjectStore.vue"; | ||
import ObjectStoreSelectButton from "@/components/ObjectStore/ObjectStoreSelectButton.vue"; | ||
import ObjectStoreSelectButtonPopover from "@/components/ObjectStore/ObjectStoreSelectButtonPopover.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 | ||
:id="`swap-target-object-store-button-${fromObjectStore.object_store_id}`" | ||
:key="fromObjectStore.object_store_id" | ||
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" | ||
:id="`swap-target-object-store-button-${objectStore.object_store_id}`" | ||
:key="objectStore.object_store_id" | ||
class="swap-target-object-store-select-button" | ||
:data-object-store-id="objectStore.object_store_id" | ||
variant="outline-primary" | ||
:objectStore="objectStore" | ||
@click="emit('relocate', objectStore.object_store_id)" /> | ||
</b-button-group> | ||
<ObjectStoreSelectButtonPopover | ||
:target="`swap-target-object-store-button-${fromObjectStore.object_store_id}`" | ||
:title="fromObjectStore.name"> | ||
<DescribeObjectStore :what="fromWhat" :storage-info="fromObjectStore"> </DescribeObjectStore> | ||
</ObjectStoreSelectButtonPopover> | ||
<ObjectStoreSelectButtonPopover | ||
v-for="objectStore in targetObjectStores" | ||
:key="objectStore.object_store_id" | ||
:target="`swap-target-object-store-button-${objectStore.object_store_id}`" | ||
:title="objectStore.name"> | ||
<DescribeObjectStore :what="toWhat" :storage-info="objectStore"> </DescribeObjectStore> | ||
</ObjectStoreSelectButtonPopover> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.select-button-group { | ||
display: block; | ||
margin: auto; | ||
width: 400px; | ||
} | ||
</style> |
107 changes: 107 additions & 0 deletions
107
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,107 @@ | ||
<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 RelocateModal from "./RelocateModal.vue"; | ||
interface RelocateLinkProps { | ||
datasetStorageDetails: DatasetStorageDetails; | ||
datasetId: string; | ||
} | ||
const props = defineProps<RelocateLinkProps>(); | ||
const relocateModal = ref<InstanceType<typeof RelocateModal> | null>(null); | ||
function showRelocateDialog() { | ||
// This should work - does it work in proper Vue 3 or something? | ||
// https://vuejs.org/guide/typescript/composition-api.html#typing-component-template-refs | ||
// @ts-ignore | ||
relocateModal.value?.showModal(); | ||
} | ||
function hideRelocateDialog() { | ||
// This should work - does it work in proper Vue 3 or something? | ||
// https://vuejs.org/guide/typescript/composition-api.html#typing-component-template-refs | ||
// @ts-ignore | ||
relocateModal.value?.hideModal(); | ||
} | ||
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); | ||
hideRelocateDialog(); | ||
emit("relocated"); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<span class="storage-relocate-link"> | ||
<RelocateModal | ||
v-if="currentObjectStore" | ||
ref="relocateModal" | ||
:from-object-store="currentObjectStore" | ||
:target-object-stores="validTargets" | ||
@relocate="relocate" /> | ||
<b-link v-if="relocatable" href="#" @click="showRelocateDialog">(relocate)</b-link> | ||
</span> | ||
</template> |
51 changes: 51 additions & 0 deletions
51
client/src/components/Dataset/DatasetStorage/RelocateModal.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,51 @@ | ||
<script setup lang="ts"> | ||
import { ref } from "vue"; | ||
import { ConcreteObjectStoreModel } from "@/api"; | ||
import RelocateDialog from "./RelocateDialog.vue"; | ||
interface RelocateModalProps { | ||
fromObjectStore: ConcreteObjectStoreModel; | ||
targetObjectStores: ConcreteObjectStoreModel[]; | ||
} | ||
defineProps<RelocateModalProps>(); | ||
const show = ref(false); | ||
function showModal() { | ||
show.value = true; | ||
} | ||
function hideModal() { | ||
show.value = false; | ||
} | ||
const emit = defineEmits<{ | ||
(e: "relocate", value: string): void; | ||
}>(); | ||
function relocate(objectStoreId: string) { | ||
emit("relocate", objectStoreId); | ||
} | ||
const title = "Relocate Dataset Storage"; | ||
defineExpose({ | ||
showModal, | ||
hideModal, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<b-modal v-model="show" hide-footer> | ||
<template v-slot:modal-title> | ||
<h2>{{ title }}</h2> | ||
</template> | ||
<RelocateDialog | ||
:from-object-store="fromObjectStore" | ||
:target-object-stores="targetObjectStores" | ||
@relocate="relocate" /> | ||
</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
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