From 0a642811039739d1beac24bf336de0eebbb36c76 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Thu, 30 May 2024 11:07:02 -0500 Subject: [PATCH] fix duplicate modals opening from `HistoryNavigation` Using `v-b-modal:modal-id` had the disadvantage that if we had multiple components containing modals with same ids, they would all open simultaneously. Using `v-modal` to open modals instead removes this side effect. --- .../CurrentHistory/HistoryNavigation.vue | 29 ++++++++++++++----- .../components/History/Modals/CopyModal.vue | 24 +++++++++++++-- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/client/src/components/History/CurrentHistory/HistoryNavigation.vue b/client/src/components/History/CurrentHistory/HistoryNavigation.vue index c87db5961306..784808345cbb 100644 --- a/client/src/components/History/CurrentHistory/HistoryNavigation.vue +++ b/client/src/components/History/CurrentHistory/HistoryNavigation.vue @@ -71,7 +71,12 @@ const props = withDefaults(defineProps(), { minimal: false, }); +// modal refs const showSwitchModal = ref(false); +const showDeleteModal = ref(false); +const showPrivacyModal = ref(false); +const showCopyModal = ref(false); + const purgeHistory = ref(false); const userStore = useUserStore(); @@ -177,14 +182,16 @@ function userTitle(title: string) { + :title="userTitle('Copy History to a New History')" + @click="showCopyModal = !showCopyModal"> Copy this History - + Delete this History @@ -249,9 +256,9 @@ function userTitle(title: string) { + :title="userTitle('Make this History Private')" + @click="showPrivacyModal = !showPrivacyModal"> Make Private @@ -268,13 +275,19 @@ function userTitle(title: string) { :show-modal.sync="showSwitchModal" @selectHistory="historyStore.setCurrentHistory($event.id)" /> - + +

+ History: + {{ history.name }} +

This will make all the data in this history private (excluding library datasets), and will set permissions such that all new data is created as private. Any datasets within that are currently shared @@ -283,7 +296,7 @@ function userTitle(title: string) { (); +const props = withDefaults(defineProps(), { + showModal: false, +}); + +const emit = defineEmits<{ + (e: "update:show-modal", value: boolean): void; +}>(); const userStore = useUserStore(); const historyStore = useHistoryStore(); @@ -32,6 +39,7 @@ const { currentUser, isAnonymous } = storeToRefs(userStore); const name = ref(""); const copyAll = ref(false); const loading = ref(false); +const localShowModal = ref(props.showModal); const title = computed(() => { return `Copying History: ${props.history.name}`; @@ -55,6 +63,18 @@ const formValid = computed(() => { return newNameValid.value; }); +watch( + () => props.showModal, + (newVal) => { + localShowModal.value = newVal; + } +); +watch( + () => localShowModal.value, + (newVal) => { + emit("update:show-modal", newVal); + } +); watch( () => props.history, (newHistory) => { @@ -74,7 +94,7 @@ async function copy(close: () => void) {