-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Git Integration - Phase 4 (#12439)
- Loading branch information
1 parent
4785b53
commit 1b24eb0
Showing
14 changed files
with
298 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Files.App.Contexts; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class GitFetchAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext _context; | ||
|
||
public string Label { get; } = "GitFetch".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "GitFetchDescription".GetLocalizedResource(); | ||
|
||
public bool IsExecutable | ||
=> _context.CanExecuteGitAction; | ||
|
||
public GitFetchAction() | ||
{ | ||
_context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
_context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
GitHelpers.FetchOrigin(_context.ShellPage!.InstanceViewModel.GitRepositoryPath); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(IContentPageContext.CanExecuteGitAction)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
} | ||
} |
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,39 @@ | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class GitPullAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext _context; | ||
|
||
public string Label { get; } = "GitPull".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "GitPullDescription".GetLocalizedResource(); | ||
|
||
public RichGlyph Glyph { get; } = new("\uE74B"); | ||
|
||
public bool IsExecutable | ||
=> _context.CanExecuteGitAction; | ||
|
||
public GitPullAction() | ||
{ | ||
_context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
_context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
GitHelpers.PullOrigin(_context.ShellPage!.InstanceViewModel.GitRepositoryPath); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(IContentPageContext.CanExecuteGitAction)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -176,5 +176,9 @@ public enum CommandCodes | |
|
||
// Play | ||
PlayAll, | ||
|
||
// Git | ||
GitFetch, | ||
GitPull, | ||
} | ||
} |
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
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
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
Oops, something went wrong.