From 7a73c83a8486d42718f434bfd04b5a1b854922db 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, 42 insertions(+), 11 deletions(-) diff --git a/client/src/components/History/CurrentHistory/HistoryNavigation.vue b/client/src/components/History/CurrentHistory/HistoryNavigation.vue index 7420c8f2e53c..7084e2713bfe 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(); @@ -202,17 +207,17 @@ function userTitle(title: string) { + :title="userTitle('Copy History to a New History')" + @click="showCopyModal = !showCopyModal"> Copy this History + :title="localize('Permanently Delete History')" + @click="showDeleteModal = !showDeleteModal"> Delete this History @@ -278,9 +283,9 @@ function userTitle(title: string) { + :title="userTitle('Make this History Private')" + @click="showPrivacyModal = !showPrivacyModal"> Make Private @@ -297,13 +302,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 @@ -312,7 +323,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) {