dnd dropzone uses virtualbranch create

This commit is contained in:
Kiril Videlov 2023-06-27 18:23:58 +02:00 committed by Kiril Videlov
parent bf7d62b62b
commit ca155eeeb8
3 changed files with 5 additions and 18 deletions

View File

@ -2,7 +2,6 @@
import Board from './Board.svelte';
import Tray from './Tray.svelte';
import type { PageData } from './$types';
import type { Branch } from './types';
import { getStore } from './vbranches';
import { Value } from 'svelte-loadable-store';
@ -15,18 +14,12 @@
? $virtualBranches.value
: [];
let targetChoice = 'origin/master'; // prob should check if it exists
function handleNewBranch(e: CustomEvent<Branch[]>) {
let name = e.detail[0].name;
let path = e.detail[0].files[0].path;
virtualBranches.createBranch(name, path);
}
</script>
{#if target}
<div class="flex w-full max-w-full">
<Tray bind:branches {target} remoteBranches={remoteBranchesData} {virtualBranches} />
<Board bind:branches {projectId} {virtualBranches} on:newBranch={handleNewBranch} />
<Board bind:branches {projectId} {virtualBranches} />
</div>
{:else}
<div class="m-auto flex flex-col space-y-2">

View File

@ -28,11 +28,6 @@
}
branches = branches;
}
function handleUpdateRequest() {
// TODO: pass this as prop to components and refresh whenever we perform updates
virtualBranches.refresh();
}
</script>
<div
@ -62,7 +57,7 @@
{virtualBranches}
/>
{/each}
<NewBranchDropZone on:newBranch on:update={handleUpdateRequest} />
<NewBranchDropZone {virtualBranches} />
</div>
<style lang="postcss">

View File

@ -3,10 +3,10 @@
import { Branch, File, Hunk } from './types';
import type { DndEvent } from 'svelte-dnd-action/typings';
import { createBranch, createFile } from './helpers';
import { createEventDispatcher } from 'svelte';
import { Button } from '$lib/components';
import type { VirtualBranchStore } from './vbranches';
const dispatch = createEventDispatcher();
export let virtualBranches: VirtualBranchStore;
let items: Branch[] = [];
function handleDndFinalize(e: CustomEvent<DndEvent<Branch | File | Hunk>>) {
@ -24,8 +24,7 @@
}
if (e.type == 'finalize') {
dispatch('newBranch', branchItems);
dispatch('update');
virtualBranches.createBranch(branchItems[0].name, branchItems[0].files[0].path);
items = [];
return;
}