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-tauri/src/main.rs b/src-tauri/src/main.rs index 7fadae7..da0ee95 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -11,7 +11,7 @@ use database::storage::DATABASE; use errors::git_error::GitErrorProject; use git::project_folder::{ get_commit_history, get_database_projects, open_git_project, remove_database_project, - set_current_project, + set_current_project, checkout_branch, checkout_commit }; use tauri::{AppHandle, Emitter, Manager}; @@ -89,6 +89,8 @@ fn main() { remove_database_project, set_current_project, get_commit_history, + checkout_branch, + checkout_commit ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); 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 {