mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-12 21:22:58 +00:00
fix: prompts disappearing on copy / move / upload (#3537)
--------- Co-authored-by: Ryan Miller <ryan.miller@infinitetactics.com> Co-authored-by: Oleg Lobanov <oleg@lobanov.me>
This commit is contained in:
parent
e92dbb4bb8
commit
d1c84a8412
@ -1,7 +1,8 @@
|
|||||||
import { createURL, fetchURL, removePrefix } from "./utils";
|
|
||||||
import { baseURL } from "@/utils/constants";
|
|
||||||
import { useAuthStore } from "@/stores/auth";
|
import { useAuthStore } from "@/stores/auth";
|
||||||
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
|
import { baseURL } from "@/utils/constants";
|
||||||
import { upload as postTus, useTus } from "./tus";
|
import { upload as postTus, useTus } from "./tus";
|
||||||
|
import { createURL, fetchURL, removePrefix } from "./utils";
|
||||||
|
|
||||||
export async function fetch(url: string) {
|
export async function fetch(url: string) {
|
||||||
url = removePrefix(url);
|
url = removePrefix(url);
|
||||||
@ -156,6 +157,7 @@ function moveCopy(
|
|||||||
overwrite = false,
|
overwrite = false,
|
||||||
rename = false
|
rename = false
|
||||||
) {
|
) {
|
||||||
|
const layoutStore = useLayoutStore();
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
@ -166,7 +168,7 @@ function moveCopy(
|
|||||||
}&destination=${to}&override=${overwrite}&rename=${rename}`;
|
}&destination=${to}&override=${overwrite}&rename=${rename}`;
|
||||||
promises.push(resourceAction(url, "PATCH"));
|
promises.push(resourceAction(url, "PATCH"));
|
||||||
}
|
}
|
||||||
|
layoutStore.closeHovers();
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
href="https://github.com/filebrowser/filebrowser"
|
href="https://github.com/filebrowser/filebrowser"
|
||||||
>File Browser</a
|
>File Browser</a
|
||||||
>
|
>
|
||||||
<span> {{ ' ' }} {{ version }}</span>
|
<span> {{ " " }} {{ version }}</span>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<a @click="help">{{ $t("sidebar.help") }}</a>
|
<a @click="help">{{ $t("sidebar.help") }}</a>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from "vue";
|
import { watch } from "vue";
|
||||||
import { ModalsContainer, useModal } from "vue-final-modal";
|
import { ModalsContainer, useModal } from "vue-final-modal";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { useLayoutStore } from "@/stores/layout";
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
@ -30,8 +30,6 @@ const layoutStore = useLayoutStore();
|
|||||||
|
|
||||||
const { currentPromptName } = storeToRefs(layoutStore);
|
const { currentPromptName } = storeToRefs(layoutStore);
|
||||||
|
|
||||||
const closeModal = ref<() => Promise<string>>();
|
|
||||||
|
|
||||||
const components = new Map<string, any>([
|
const components = new Map<string, any>([
|
||||||
["info", Info],
|
["info", Info],
|
||||||
["help", Help],
|
["help", Help],
|
||||||
@ -52,11 +50,6 @@ const components = new Map<string, any>([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
watch(currentPromptName, (newValue) => {
|
watch(currentPromptName, (newValue) => {
|
||||||
if (closeModal.value) {
|
|
||||||
closeModal.value();
|
|
||||||
closeModal.value = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
const modal = components.get(newValue!);
|
const modal = components.get(newValue!);
|
||||||
if (!modal) return;
|
if (!modal) return;
|
||||||
|
|
||||||
@ -67,7 +60,7 @@ watch(currentPromptName, (newValue) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
closeModal.value = close;
|
layoutStore.setCloseOnPrompt(close, newValue!);
|
||||||
open();
|
open();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,8 +48,6 @@ const layoutStore = useLayoutStore();
|
|||||||
|
|
||||||
// TODO: this is a copy of the same function in FileListing.vue
|
// TODO: this is a copy of the same function in FileListing.vue
|
||||||
const uploadInput = (event: Event) => {
|
const uploadInput = (event: Event) => {
|
||||||
layoutStore.closeHovers();
|
|
||||||
|
|
||||||
let files = (event.currentTarget as HTMLInputElement)?.files;
|
let files = (event.currentTarget as HTMLInputElement)?.files;
|
||||||
if (files === null) return;
|
if (files === null) return;
|
||||||
|
|
||||||
|
@ -29,6 +29,12 @@ export const useLayoutStore = defineStore("layout", {
|
|||||||
toggleShell() {
|
toggleShell() {
|
||||||
this.showShell = !this.showShell;
|
this.showShell = !this.showShell;
|
||||||
},
|
},
|
||||||
|
setCloseOnPrompt(closeFunction: () => Promise<string>, onPrompt: string) {
|
||||||
|
const prompt = this.prompts.find((prompt) => prompt.prompt === onPrompt);
|
||||||
|
if (prompt) {
|
||||||
|
prompt.close = closeFunction;
|
||||||
|
}
|
||||||
|
},
|
||||||
showHover(value: PopupProps | string) {
|
showHover(value: PopupProps | string) {
|
||||||
if (typeof value !== "object") {
|
if (typeof value !== "object") {
|
||||||
this.prompts.push({
|
this.prompts.push({
|
||||||
@ -36,6 +42,7 @@ export const useLayoutStore = defineStore("layout", {
|
|||||||
confirm: null,
|
confirm: null,
|
||||||
action: undefined,
|
action: undefined,
|
||||||
props: null,
|
props: null,
|
||||||
|
close: null,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -45,6 +52,7 @@ export const useLayoutStore = defineStore("layout", {
|
|||||||
confirm: value?.confirm,
|
confirm: value?.confirm,
|
||||||
action: value?.action,
|
action: value?.action,
|
||||||
props: value?.props,
|
props: value?.props,
|
||||||
|
close: value?.close,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showError() {
|
showError() {
|
||||||
@ -53,6 +61,7 @@ export const useLayoutStore = defineStore("layout", {
|
|||||||
confirm: null,
|
confirm: null,
|
||||||
action: undefined,
|
action: undefined,
|
||||||
props: null,
|
props: null,
|
||||||
|
close: null,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showSuccess() {
|
showSuccess() {
|
||||||
@ -61,10 +70,11 @@ export const useLayoutStore = defineStore("layout", {
|
|||||||
confirm: null,
|
confirm: null,
|
||||||
action: undefined,
|
action: undefined,
|
||||||
props: null,
|
props: null,
|
||||||
|
close: null,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
closeHovers() {
|
closeHovers() {
|
||||||
this.prompts.pop();
|
this.prompts.shift()?.close?.();
|
||||||
},
|
},
|
||||||
// easily reset state using `$reset`
|
// easily reset state using `$reset`
|
||||||
clearLayout() {
|
clearLayout() {
|
||||||
|
1
frontend/src/types/layout.d.ts
vendored
1
frontend/src/types/layout.d.ts
vendored
@ -3,6 +3,7 @@ interface PopupProps {
|
|||||||
confirm?: any;
|
confirm?: any;
|
||||||
action?: PopupAction;
|
action?: PopupAction;
|
||||||
props?: any;
|
props?: any;
|
||||||
|
close?: (() => Promise<string>) | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
type PopupAction = (e: Event) => void;
|
type PopupAction = (e: Event) => void;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { useLayoutStore } from "@/stores/layout";
|
||||||
import { useUploadStore } from "@/stores/upload";
|
import { useUploadStore } from "@/stores/upload";
|
||||||
import url from "@/utils/url";
|
import url from "@/utils/url";
|
||||||
|
|
||||||
@ -126,6 +127,9 @@ export function handleFiles(
|
|||||||
overwrite = false
|
overwrite = false
|
||||||
) {
|
) {
|
||||||
const uploadStore = useUploadStore();
|
const uploadStore = useUploadStore();
|
||||||
|
const layoutStore = useLayoutStore();
|
||||||
|
|
||||||
|
layoutStore.closeHovers();
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const id = uploadStore.id;
|
const id = uploadStore.id;
|
||||||
|
@ -753,8 +753,6 @@ const drop = async (event: DragEvent) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const uploadInput = (event: Event) => {
|
const uploadInput = (event: Event) => {
|
||||||
layoutStore.closeHovers();
|
|
||||||
|
|
||||||
let files = (event.currentTarget as HTMLInputElement)?.files;
|
let files = (event.currentTarget as HTMLInputElement)?.files;
|
||||||
if (files === null) return;
|
if (files === null) return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user