dont use [...path] routing since it breaks building statically

This commit is contained in:
2025-07-18 11:02:48 +02:00
parent 5ff19ef372
commit ecb201dc69
13 changed files with 300 additions and 188 deletions

View File

@@ -10,20 +10,28 @@ import {
} from '@/components/ui/dialog';
import { createDirectory } from '~/lib/api/warrens';
const warrenRoute = useWarrenRoute();
const warrenStore = useWarrenStore();
const dialog = useCreateDirectoryDialog();
const creating = ref(false);
const directoryNameValid = computed(() => dialog.value.trim().length > 0);
async function submit() {
if (!directoryNameValid.value || creating.value) {
if (
!directoryNameValid.value ||
creating.value ||
warrenStore.current == null
) {
return;
}
creating.value = true;
const { success } = await createDirectory(warrenRoute.value, dialog.value);
const { success } = await createDirectory(
warrenStore.current.warrenId,
warrenStore.current.path,
dialog.value
);
creating.value = false;

View File

@@ -9,21 +9,27 @@ import {
} from '@/components/ui/dialog';
import { renameWarrenEntry } from '~/lib/api/warrens';
const warrenRoute = useWarrenRoute();
const warrenStore = useWarrenStore();
const dialog = useRenameDirectoryDialog();
const renaming = ref(false);
const directoryNameValid = computed(() => dialog.value.trim().length > 0);
async function submit() {
if (dialog.entry == null || !directoryNameValid.value || renaming.value) {
if (
dialog.entry == null ||
!directoryNameValid.value ||
renaming.value ||
warrenStore.current == null
) {
return;
}
renaming.value = true;
const { success } = await renameWarrenEntry(
warrenRoute.value,
warrenStore.current.warrenId,
warrenStore.current.path,
dialog.entry.name,
dialog.value
);

View File

@@ -16,9 +16,16 @@ import { uploadToWarren } from '~/lib/api/warrens';
import { toast } from 'vue-sonner';
import UploadListEntry from './UploadListEntry.vue';
const warrenStore = useWarrenStore();
const uploadStore = useUploadStore();
const warrenRoute = useWarrenRoute();
const currentAndUploadRouteMatch = computed(
() =>
uploadStore.destination != null &&
warrenStore.current != null &&
uploadStore.destination.warrenId == warrenStore.current.warrenId &&
uploadStore.destination.path == warrenStore.current.path
);
const fileInputElement = ref<HTMLInputElement>(
null as unknown as HTMLInputElement
@@ -28,7 +35,7 @@ const uploading = ref(false);
const presentPaths = new Set<string>();
function onFilesChanged(event: Event) {
if (warrenRoute.value == null) {
if (warrenStore.current == null) {
toast.warning('Upload', {
description: 'Enter a warren before attempting to upload files',
});
@@ -45,9 +52,9 @@ function onFilesChanged(event: Event) {
return;
}
if (uploadStore.path == null) {
uploadStore.path = warrenRoute.value;
} else if (uploadStore.path !== warrenRoute.value) {
if (uploadStore.destination == null) {
uploadStore.destination = warrenStore.current;
} else if (currentAndUploadRouteMatch.value) {
toast.warning('Upload', {
description:
'The unfinished items belong to a different directory. Remove them before attempting to upload to a different directory.',
@@ -78,7 +85,7 @@ function removeFile(index: number) {
presentPaths.delete(file.data.name);
if (uploadStore.files.length < 1) {
uploadStore.path = null;
uploadStore.destination = null;
uploadStore.progress = null;
}
}
@@ -94,7 +101,7 @@ function clearCompletedFiles() {
});
if (uploadStore.files.length < 1) {
uploadStore.path = null;
uploadStore.destination = null;
uploadStore.progress = null;
}
}
@@ -126,7 +133,7 @@ function updateFileListStatus(loadedBytes: number, ended: boolean = false) {
}
async function submit() {
if (uploadStore.path == null) {
if (uploadStore.destination == null) {
return;
}
@@ -154,7 +161,8 @@ async function submit() {
};
const { success } = await uploadToWarren(
uploadStore.path,
uploadStore.destination.warrenId,
uploadStore.destination.path,
dt.files,
(loaded, total) => {
if (uploadStore.progress != null) {
@@ -192,10 +200,13 @@ async function submit() {
<DialogDescription
>Upload files to
<span class="text-foreground">{{
uploadStore.path == null ||
warrenRoute === uploadStore.path
currentAndUploadRouteMatch ||
uploadStore.destination == null
? 'the current directory'
: routeWithWarrenName(uploadStore.path)
: routeWithWarrenName(
uploadStore.destination!.warrenId,
uploadStore.destination!.path
)
}}</span></DialogDescription
>
</DialogHeader>