From fe2e13a2dd8a8f9e39813ef0a4aa4179c344bd02 Mon Sep 17 00:00:00 2001 From: Andrei Serban Date: Thu, 26 Dec 2024 22:32:06 +0200 Subject: [PATCH] Add checkout --- index.html | 5 +- src/App.vue | 5 +- src/components/Dialogs/ContextMenu.vue | 53 +++++++++++++++++++ .../Project/Commit/CommitListItem.vue | 7 ++- src/stores/dialogs.ts | 30 ++++++++++- src/types/tauri.ts | 2 + 6 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 src/components/Dialogs/ContextMenu.vue diff --git a/index.html b/index.html index 99f203f..53c071c 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,10 @@ - Tauri + Vue + Typescript App + BranchWise + diff --git a/src/App.vue b/src/App.vue index 2ac836b..4c28747 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,11 +13,13 @@ {{ snackbar.text }} + diff --git a/src/components/Project/Commit/CommitListItem.vue b/src/components/Project/Commit/CommitListItem.vue index e7464d4..340a804 100644 --- a/src/components/Project/Commit/CommitListItem.vue +++ b/src/components/Project/Commit/CommitListItem.vue @@ -5,6 +5,7 @@ style="height: 10vh;" :class="commitClass" @click="setCommit" + @click.right="showContextMenu" > diff --git a/src/stores/dialogs.ts b/src/stores/dialogs.ts index efdac05..b0581b2 100644 --- a/src/stores/dialogs.ts +++ b/src/stores/dialogs.ts @@ -13,7 +13,15 @@ interface IDialogState { title: string; message: string; onConfirm: () => void; - } + }, + contextMenu: { + isOpen: boolean; + commitHash: string; + position: { + x: number; + y: number; + }; + } } export const useDialogStore = defineStore("dialog", { @@ -30,6 +38,13 @@ export const useDialogStore = defineStore("dialog", { title: "", message: "", onConfirm: () => { return; } + }, + contextMenu: { + isOpen: false, + position: { + x: 0, + y: 0 + } } }), actions: { @@ -57,6 +72,19 @@ export const useDialogStore = defineStore("dialog", { }, closeConfirmationDialog() { this.confirmationDialog.isOpen = false; + }, + showContextMenu(hash: string, x: number, y: number) { + this.contextMenu = { + position: { + x, + y + }, + commitHash: hash, + isOpen: true + }; + }, + closeContextMenu() { + this.contextMenu.isOpen = false; } } }); diff --git a/src/types/tauri.ts b/src/types/tauri.ts index 8d678c4..9f2d13d 100644 --- a/src/types/tauri.ts +++ b/src/types/tauri.ts @@ -5,6 +5,8 @@ export enum TauriCommands { RemoveDatabaseProject = "remove_database_project", SetCurrentBranch = "set_current_branch", SetCurrentProject = "set_current_project", + CheckoutBranch = "checkout_branch", + CheckoutCommit = "checkout_commit", } export enum TauriListen {