fix: Fixed some null issues + added props attribute for dialog prop passing (#2659)

This commit is contained in:
ArthurMousatov 2023-08-23 13:42:29 -04:00
parent df8349e352
commit 8b4b2d6656
9 changed files with 18 additions and 13 deletions

View File

@ -91,9 +91,9 @@ export default {
}, },
watch: { watch: {
currentPrompt(val, old) { currentPrompt(val, old) {
this.active = val.prompt === "search"; this.active = val?.prompt === "search";
if (old.prompt === "search" && !this.active) { if (old?.prompt === "search" && !this.active) {
if (this.reload) { if (this.reload) {
this.setReload(true); this.setReload(true);
} }

View File

@ -135,7 +135,7 @@ export default {
...mapState(["user"]), ...mapState(["user"]),
...mapGetters(["isLogged", "currentPrompt"]), ...mapGetters(["isLogged", "currentPrompt"]),
active() { active() {
return this.currentPrompt.prompt === "sidebar"; return this.currentPrompt?.prompt === "sidebar";
}, },
signup: () => signup, signup: () => signup,
version: () => version, version: () => version,

View File

@ -11,7 +11,7 @@
<slot /> <slot />
<div id="dropdown" :class="{ active: this.currentPrompt.prompt === 'more' }"> <div id="dropdown" :class="{ active: this.currentPromptName === 'more' }">
<slot name="actions" /> <slot name="actions" />
</div> </div>
@ -25,7 +25,7 @@
<div <div
class="overlay" class="overlay"
v-show="this.currentPrompt.prompt == 'more'" v-show="this.currentPromptName == 'more'"
@click="$store.commit('closeHovers')" @click="$store.commit('closeHovers')"
/> />
</header> </header>
@ -54,7 +54,7 @@ export default {
}, },
}, },
computed: { computed: {
...mapGetters(["currentPrompt"]), ...mapGetters(["currentPromptName"]),
} }
}; };
</script> </script>

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<component ref="getCurrentPrompt" :is="getCurrentPrompt"></component> <component v-if="showOverlay" :ref="currentPromptName" :is="currentPromptName" v-bind="currentPrompt.props"></component>
<div v-show="showOverlay" @click="resetPrompts" class="overlay"></div> <div v-show="showOverlay" @click="resetPrompts" class="overlay"></div>
</div> </div>
</template> </template>
@ -83,7 +83,7 @@ export default {
}, },
computed: { computed: {
...mapState(["plugins"]), ...mapState(["plugins"]),
...mapGetters(["currentPrompt"]), ...mapGetters(["currentPrompt", "currentPromptName"]),
showOverlay: function () { showOverlay: function () {
return ( return (
this.currentPrompt !== null && this.currentPrompt !== null &&

View File

@ -46,6 +46,9 @@ const getters = {
currentPrompt: (state) => { currentPrompt: (state) => {
return state.prompts.length > 0 ? state.prompts[state.prompts.length - 1] : null; return state.prompts.length > 0 ? state.prompts[state.prompts.length - 1] : null;
}, },
currentPromptName: (_, getters) => {
return getters.currentPrompt?.prompt;
}
}; };
export default getters; export default getters;

View File

@ -13,12 +13,14 @@ const mutations = {
state.showShell = !state.showShell; state.showShell = !state.showShell;
}, },
showHover: (state, value) => { showHover: (state, value) => {
console.log(value);
if (typeof value !== "object") { if (typeof value !== "object") {
state.show = value; state.show = value;
state.prompts.push({ state.prompts.push({
prompt: value, prompt: value,
confirm: null, confirm: null,
action: null action: null,
props: {}
}); });
return; return;
} }

View File

@ -38,7 +38,7 @@ export default {
$route: function () { $route: function () {
this.$store.commit("resetSelected"); this.$store.commit("resetSelected");
this.$store.commit("multiple", false); this.$store.commit("multiple", false);
if (this.currentPrompt.prompt !== "success") if (this.currentPrompt?.prompt !== "success")
this.$store.commit("closeHovers"); this.$store.commit("closeHovers");
}, },
}, },

View File

@ -196,7 +196,7 @@ export default {
return api.getDownloadURL(this.req, true); return api.getDownloadURL(this.req, true);
}, },
showMore() { showMore() {
return this.currentPrompt.prompt === "more"; return this.currentPrompt?.prompt === "more";
}, },
isResizeEnabled() { isResizeEnabled() {
return resizePreview; return resizePreview;

View File

@ -37,7 +37,7 @@
</form> </form>
</div> </div>
<div v-if="this.currentPrompt.prompt === 'deleteUser'" class="card floating"> <div v-if="this.currentPromptName === 'deleteUser'" class="card floating">
<div class="card-content"> <div class="card-content">
<p>Are you sure you want to delete this user?</p> <p>Are you sure you want to delete this user?</p>
</div> </div>
@ -89,7 +89,7 @@ export default {
return this.$route.path === "/settings/users/new"; return this.$route.path === "/settings/users/new";
}, },
...mapState(["loading"]), ...mapState(["loading"]),
...mapGetters(["currentPrompt"]) ...mapGetters(["currentPrompt", "currentPromptName"])
}, },
watch: { watch: {
$route: "fetchData", $route: "fetchData",