fix allowUploads permission

This commit is contained in:
2023-07-12 09:11:04 +10:00
parent 1744d192b5
commit 54aa7e249e

View File

@@ -25,7 +25,7 @@
<SMTab <SMTab
id="tab-upload" id="tab-upload"
label="Upload" label="Upload"
:hide="!props.allowUpload" :hide="!allowUploads"
class="flex flex-1 flex-col flex-items-center flex-justify-center"> class="flex flex-1 flex-col flex-items-center flex-justify-center">
<h2>Drop files to upload</h2> <h2>Drop files to upload</h2>
<p class="text-sm my-2">or</p> <p class="text-sm my-2">or</p>
@@ -39,7 +39,7 @@
{{ max_upload_size }} {{ max_upload_size }}
</p> </p>
<input <input
v-if="props.allowUpload" v-if="allowUploads"
id="file" id="file"
ref="refUploadInput" ref="refUploadInput"
type="file" type="file"
@@ -329,6 +329,7 @@ import { bytesReadable } from "../../helpers/types";
import { SMDate } from "../../helpers/datetime"; import { SMDate } from "../../helpers/datetime";
import { isUUID } from "../../helpers/uuid"; import { isUUID } from "../../helpers/uuid";
import { useToastStore } from "../../store/ToastStore"; import { useToastStore } from "../../store/ToastStore";
import { useUserStore } from "../../store/UserStore";
const props = defineProps({ const props = defineProps({
mime: { mime: {
@@ -355,6 +356,10 @@ const refUploadInput = ref<HTMLInputElement | null>(null);
const refMediaList = ref<HTMLUListElement | null>(null); const refMediaList = ref<HTMLUListElement | null>(null);
const userStore = useUserStore();
const allowUploads = ref(props.allowUpload && userStore.id);
/** /**
* The selected tab * The selected tab
*/ */
@@ -871,13 +876,13 @@ const computedSelectDisabled = computed(() => {
}); });
const handleDragEnter = () => { const handleDragEnter = () => {
if (props.allowUpload && !showFileDrop.value) { if (allowUploads.value && !showFileDrop.value) {
showFileDrop.value = true; showFileDrop.value = true;
} }
}; };
const handleDragOver = () => { const handleDragOver = () => {
if (props.allowUpload && !showFileDrop.value) { if (allowUploads.value && !showFileDrop.value) {
showFileDrop.value = true; showFileDrop.value = true;
} }
}; };
@@ -889,7 +894,7 @@ const handleDragLeave = () => {
}; };
const handleDrop = (event) => { const handleDrop = (event) => {
if (!props.allowUpload) { if (!allowUploads.value) {
return; return;
} }