mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-22 17:11:43 +03:00
update_branch_target to VirtualBranchesStore
This commit is contained in:
parent
b44ede5557
commit
59ddd5cf39
@ -25,7 +25,7 @@
|
||||
|
||||
{#if target}
|
||||
<div class="flex w-full max-w-full">
|
||||
<Tray bind:branches {target} {projectId} remoteBranches={remoteBranchesData} />
|
||||
<Tray bind:branches {target} remoteBranches={remoteBranchesData} {virtualBranches} />
|
||||
<Board bind:branches {projectId} {virtualBranches} on:newBranch={handleNewBranch} />
|
||||
</div>
|
||||
{:else}
|
||||
|
@ -1,32 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { Button, Checkbox } from '$lib/components';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { Branch, BranchData, Target } from './types';
|
||||
import { formatDistanceToNow } from 'date-fns';
|
||||
import { error } from '$lib/toasts';
|
||||
import type { VirtualBranchStore } from './vbranches';
|
||||
|
||||
export let target: Target;
|
||||
export let projectId: string;
|
||||
export let branches: Branch[];
|
||||
export let remoteBranches: BranchData[];
|
||||
|
||||
async function updateBranchTarget(params: { projectId: string }) {
|
||||
return invoke('update_branch_target', params);
|
||||
}
|
||||
|
||||
function updateTarget() {
|
||||
console.log('update');
|
||||
updateBranchTarget({ projectId: projectId }).then(
|
||||
(res) => {
|
||||
// We need to refetch target data here
|
||||
console.log(res);
|
||||
},
|
||||
(e) => {
|
||||
console.log(e);
|
||||
error('Unable to update target!');
|
||||
}
|
||||
);
|
||||
}
|
||||
export let virtualBranches: VirtualBranchStore;
|
||||
</script>
|
||||
|
||||
<div
|
||||
@ -38,7 +19,7 @@
|
||||
{#if target.behind > 0}
|
||||
<div class="flex flex-row justify-between">
|
||||
<div>behind {target.behind}</div>
|
||||
<Button on:click={updateTarget}>Update Target</Button>
|
||||
<Button on:click={virtualBranches.updateBranchTarget}>Update Target</Button>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex flex-row justify-between">
|
||||
|
@ -14,6 +14,7 @@ export interface VirtualBranchStore {
|
||||
setTarget: (branch: string) => Promise<object>;
|
||||
createBranch: (name: string, path: string) => Promise<void | object>;
|
||||
commitBranch: (branch: string, message: string) => Promise<void | object>;
|
||||
updateBranchTarget: () => Promise<void | object>;
|
||||
}
|
||||
|
||||
export function getStore(projectId: string): VirtualBranchStore {
|
||||
@ -53,6 +54,18 @@ export function getStore(projectId: string): VirtualBranchStore {
|
||||
console.log(err);
|
||||
error('Failed to commit files.');
|
||||
});
|
||||
},
|
||||
updateBranchTarget() {
|
||||
return invoke<object>('update_branch_target', { projectId: projectId })
|
||||
.then((res) => {
|
||||
// TODO
|
||||
// We need to refetch target data here
|
||||
console.log(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
error('Unable to update target!');
|
||||
});
|
||||
}
|
||||
};
|
||||
cache.set(projectId, store);
|
||||
|
Loading…
Reference in New Issue
Block a user