copy files
This commit is contained in:
@@ -6,11 +6,35 @@ import {
|
||||
ContextMenuItem,
|
||||
} from '@/components/ui/context-menu';
|
||||
|
||||
const dialog = useCreateDirectoryDialog();
|
||||
const warrenStore = useWarrenStore();
|
||||
const copyStore = useCopyStore();
|
||||
const createDirectoryDialog = useCreateDirectoryDialog();
|
||||
|
||||
const pasting = ref<boolean>(false);
|
||||
const validPaste = computed(
|
||||
() =>
|
||||
!pasting.value && copyStore.file != null && warrenStore.current != null
|
||||
);
|
||||
|
||||
const props = defineProps<{
|
||||
class?: string;
|
||||
}>();
|
||||
|
||||
async function onPaste() {
|
||||
if (!validPaste.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
pasting.value = true;
|
||||
|
||||
await pasteFile(copyStore.file!, {
|
||||
warrenId: warrenStore.current!.warrenId,
|
||||
name: copyStore.file!.name,
|
||||
path: warrenStore.current!.path,
|
||||
});
|
||||
|
||||
pasting.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -19,7 +43,11 @@ const props = defineProps<{
|
||||
<slot />
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent>
|
||||
<ContextMenuItem @select="dialog.openDialog">
|
||||
<ContextMenuItem @disabled="!validPaste" @select="onPaste">
|
||||
<Icon name="lucide:clipboard-paste" />
|
||||
Paste
|
||||
</ContextMenuItem>
|
||||
<ContextMenuItem @select="createDirectoryDialog.openDialog">
|
||||
<Icon name="lucide:folder-plus" />
|
||||
Create directory
|
||||
</ContextMenuItem>
|
||||
|
||||
Reference in New Issue
Block a user