Skip to content

Commit

Permalink
Refactor ObjectStore button popover for reuse.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Feb 8, 2024
1 parent 82c33ce commit e3fe2d3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { BButton } from "bootstrap-vue";
import { type ConcreteObjectStoreModel } from "@/api";
import ObjectStoreBadges from "@/components/ObjectStore/ObjectStoreBadges.vue";
Expand Down
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>
31 changes: 11 additions & 20 deletions client/src/components/ObjectStore/SelectObjectStore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { computed, ref } from "vue";
import { useObjectStoreStore } from "@/stores/objectStoreStore";
import ObjectStoreSelectButton from "./ObjectStoreSelectButton.vue";
import ObjectStoreSelectButtonPopover from "./ObjectStoreSelectButtonPopover.vue";
import LoadingSpan from "@/components/LoadingSpan.vue";
import DescribeObjectStore from "@/components/ObjectStore/DescribeObjectStore.vue";
import ObjectStoreSelectButton from "./ObjectStoreSelectButton.vue";
interface SelectObjectStoreProps {
selectedObjectStoreId?: String | null;
Expand All @@ -21,11 +22,6 @@ const props = withDefaults(defineProps<SelectObjectStoreProps>(), {
parentError: null,
});
const popoverProps = {
placement: "rightbottom",
boundary: "window", // don't warp the popover to squeeze it into this modal
};
const store = useObjectStoreStore();
const { isLoading, loadErrorMessage, selectableObjectStores } = storeToRefs(store);
Expand Down Expand Up @@ -94,21 +90,16 @@ async function handleSubmit(preferredObjectStoreId: string) {
</p>
</b-col>
</b-row>
<b-popover target="no-preferred-object-store-button" triggers="hover" v-bind="popoverProps">
<template v-slot:title
><span v-localize>{{ defaultOptionTitle }}</span></template
>
<ObjectStoreSelectButtonPopover target="no-preferred-object-store-button" :title="defaultOptionTitle">
<span v-localize>{{ defaultOptionDescription }}</span>
</b-popover>
<b-popover
v-for="object_store in selectableObjectStores"
:key="object_store.object_store_id"
:target="`preferred-object-store-button-${object_store.object_store_id}`"
triggers="hover"
v-bind="popoverProps">
<template v-slot:title>{{ object_store.name }}</template>
<DescribeObjectStore :what="forWhat" :storage-info="object_store"> </DescribeObjectStore>
</b-popover>
</ObjectStoreSelectButtonPopover>
<ObjectStoreSelectButtonPopover
v-for="objectStore in selectableObjectStores"
:key="objectStore.object_store_id"
:target="`preferred-object-store-button-${objectStore.object_store_id}`"
:title="objectStore.name">
<DescribeObjectStore :what="forWhat" :storage-info="objectStore"> </DescribeObjectStore>
</ObjectStoreSelectButtonPopover>
</div>
</div>
</template>

0 comments on commit e3fe2d3

Please sign in to comment.