-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
104f72c
commit e8c8b77
Showing
5 changed files
with
156 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Source/Lib/Ide/Ide.RazorLib/Gits/Displays/GitDiffDisplay.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="luth_ide_git-diff"> | ||
GitDiffDisplay | ||
|
||
<button class="luth_button" @onclick="ShowOriginalFromGitOnClick"> | ||
ShowOriginalFromGitOnClick | ||
</button> | ||
</div> |
55 changes: 55 additions & 0 deletions
55
Source/Lib/Ide/Ide.RazorLib/Gits/Displays/GitDiffDisplay.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Fluxor; | ||
using Luthetus.Common.RazorLib.FileSystems.Models; | ||
using Luthetus.Common.RazorLib.Keys.Models; | ||
using Luthetus.Ide.RazorLib.CommandLines.Models; | ||
using Luthetus.Ide.RazorLib.Gits.Models; | ||
using Luthetus.Ide.RazorLib.Gits.States; | ||
using Luthetus.Ide.RazorLib.Terminals.Models; | ||
using Luthetus.Ide.RazorLib.Terminals.States; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace Luthetus.Ide.RazorLib.Gits.Displays; | ||
|
||
public partial class GitDiffDisplay : ComponentBase | ||
{ | ||
[Inject] | ||
private IState<TerminalState> TerminalStateWrap { get; set; } = null!; | ||
[Inject] | ||
private IDispatcher Dispatcher { get; set; } = null!; | ||
[Inject] | ||
private IEnvironmentProvider EnvironmentProvider { get; set; } = null!; | ||
[Inject] | ||
private IState<GitState> GitStateWrap { get; set; } = null!; | ||
|
||
[Parameter, EditorRequired] | ||
public GitFile GitFile { get; set; } = null!; | ||
|
||
public Key<TerminalCommand> GitLogTerminalCommandKey { get; } = Key<TerminalCommand>.NewKey(); | ||
|
||
private async Task ShowOriginalFromGitOnClick() | ||
{ | ||
var localGitState = GitStateWrap.Value; | ||
var localGitFile = GitFile; | ||
|
||
if (localGitState.GitFolderAbsolutePath?.ParentDirectory is null) | ||
return; | ||
|
||
var parentDirectory = localGitState.GitFolderAbsolutePath.ParentDirectory; | ||
|
||
var gitLogArgs = $"log -p {localGitFile.RelativePathString}"; | ||
var formattedCommand = new FormattedCommand( | ||
GitCliFacts.TARGET_FILE_NAME, | ||
new string[] { gitLogArgs }) | ||
{ | ||
HACK_ArgumentsString = gitLogArgs | ||
}; | ||
|
||
var gitStatusCommand = new TerminalCommand( | ||
GitLogTerminalCommandKey, | ||
formattedCommand, | ||
parentDirectory.Value); | ||
|
||
var generalTerminal = TerminalStateWrap.Value.TerminalMap[TerminalFacts.GENERAL_TERMINAL_KEY]; | ||
await generalTerminal.EnqueueCommandAsync(gitStatusCommand); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Source/Lib/Ide/Ide.RazorLib/Gits/Models/GitTreeViewMouseEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Fluxor; | ||
using Luthetus.Common.RazorLib.BackgroundTasks.Models; | ||
using Luthetus.Common.RazorLib.Commands.Models; | ||
using Luthetus.Common.RazorLib.Dialogs.Models; | ||
using Luthetus.Common.RazorLib.Dialogs.States; | ||
using Luthetus.Common.RazorLib.Dynamics.Models; | ||
using Luthetus.Common.RazorLib.Keys.Models; | ||
using Luthetus.Common.RazorLib.TreeViews.Models; | ||
using Luthetus.Ide.RazorLib.Gits.Displays; | ||
using Luthetus.Ide.RazorLib.Gits.States; | ||
using Luthetus.Ide.RazorLib.TreeViewImplementations.Models; | ||
using System.Reactive; | ||
|
||
namespace Luthetus.Ide.RazorLib.Gits.Models; | ||
|
||
public class GitTreeViewMouseEventHandler : TreeViewMouseEventHandler | ||
{ | ||
private readonly IState<GitState> _gitStateWrap; | ||
private readonly IDispatcher _dispatcher; | ||
|
||
public GitTreeViewMouseEventHandler( | ||
ITreeViewService treeViewService, | ||
IBackgroundTaskService backgroundTaskService, | ||
IState<GitState> gitStateWrap, | ||
IDispatcher dispatcher) | ||
: base(treeViewService, backgroundTaskService) | ||
{ | ||
_gitStateWrap = gitStateWrap; | ||
_dispatcher = dispatcher; | ||
} | ||
|
||
public override void OnDoubleClick(TreeViewCommandArgs commandArgs) | ||
{ | ||
base.OnDoubleClick(commandArgs); | ||
|
||
if (commandArgs.NodeThatReceivedMouseEvent is not TreeViewGitFile treeViewGitFile) | ||
return; | ||
|
||
var dialogViewModel = new DialogViewModel( | ||
Key<IDynamicViewModel>.NewKey(), | ||
$"Diff: {treeViewGitFile.Item.AbsolutePath.NameWithExtension}", | ||
typeof(GitDiffDisplay), | ||
new Dictionary<string, object?> | ||
{ | ||
{ | ||
nameof(GitDiffDisplay.GitFile), | ||
treeViewGitFile.Item | ||
} | ||
}, | ||
null, | ||
true); | ||
|
||
_dispatcher.Dispatch(new DialogState.RegisterAction(dialogViewModel)); | ||
} | ||
} |