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
6 changed files
with
192 additions
and
1 deletion.
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
48 changes: 48 additions & 0 deletions
48
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,48 @@ | ||
<script setup lang="ts"> | ||
import { ConcreteObjectStoreModel } from "@/api"; | ||
import ObjectStoreBadges from "@/components/ObjectStore/ObjectStoreBadges.vue"; | ||
import ProvidedQuotaSourceUsageBar from "@/components/User/DiskUsage/Quota/ProvidedQuotaSourceUsageBar.vue"; | ||
interface RelocateProps { | ||
fromObjectStore: ConcreteObjectStoreModel; | ||
targetObjectStores: ConcreteObjectStoreModel[]; | ||
} | ||
defineProps<RelocateProps>(); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<p>Relocate the target object store:</p> | ||
<b-button-group vertical size="lg" style="width: 100%"> | ||
<b-button | ||
:id="`swap-target-object-store-button-${fromObjectStore.object_store_id}`" | ||
:key="fromObjectStore.object_store_id" | ||
class="swap-target-object-store-select-button" | ||
variant="outline-primary" | ||
:data-object-store-id="fromObjectStore.object_store_id" | ||
>{{ fromObjectStore.name }} | ||
<ObjectStoreBadges :badges="fromObjectStore.badges" size="lg" :more-on-hover="false" /> | ||
<ProvidedQuotaSourceUsageBar :object-store="object_store" :compact="true"> | ||
</ProvidedQuotaSourceUsageBar> | ||
</b-button> | ||
</b-button-group> | ||
<p>Select a new target from:</p> | ||
<b-button-group vertical size="lg" style="width: 100%"> | ||
<b-button | ||
v-for="object_store in targetObjectStores" | ||
:id="`swap-target-object-store-button-${object_store.object_store_id}`" | ||
:key="object_store.object_store_id" | ||
class="swap-target-object-store-select-button" | ||
:data-object-store-id="object_store.object_store_id" | ||
variant="outline-info" | ||
@click="handleSubmit(object_store.object_store_id)" | ||
>{{ object_store.name }} | ||
<ObjectStoreBadges :badges="object_store.badges" size="lg" :more-on-hover="false" /> | ||
<ProvidedQuotaSourceUsageBar :object-store="object_store" :compact="true"> | ||
</ProvidedQuotaSourceUsageBar> | ||
</b-button> | ||
</b-button-group> | ||
</div> | ||
</template> |
83 changes: 83 additions & 0 deletions
83
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,83 @@ | ||
<script setup lang="ts"> | ||
import { storeToRefs } from "pinia"; | ||
import { computed, ref } from "vue"; | ||
import { ConcreteObjectStoreModel, DatasetStorageDetails } from "@/api"; | ||
import { useObjectStoreStore } from "@/stores/objectStoreStore"; | ||
import RelocateModal from "./RelocateModal.vue"; | ||
interface RelocateLinkProps { | ||
datasetStorageDetails: DatasetStorageDetails; | ||
} | ||
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(); | ||
} | ||
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; | ||
}); | ||
</script> | ||
|
||
<template> | ||
<span class="storage-relocate-link"> | ||
<RelocateModal | ||
v-if="currentObjectStore" | ||
ref="relocateModal" | ||
:from-object-store="currentObjectStore" | ||
:target-object-stores="validTargets" /> | ||
<b-link v-if="relocatable" href="#" @click="showRelocateDialog">(relocate)</b-link> | ||
</span> | ||
</template> |
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
<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; | ||
} | ||
const emit = defineEmits<{ | ||
(e: "relocate", value: string): void; | ||
}>(); | ||
function relocate(objectStoreId: string) { | ||
emit("relocate", objectStoreId); | ||
} | ||
const title = "Relocate Dataset Storage"; | ||
defineExpose({ | ||
showModal, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<b-modal v-model="show" hide-footer> | ||
<template v-slot:modal-title> | ||
<h2 class="mb-0">{{ title }}</h2> | ||
<RelocateDialog | ||
:from-object-store="fromObjectStore" | ||
:target-object-stores="targetObjectStores" | ||
@relocate="relocate" /> | ||
</template> | ||
</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