mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: add a button in file histories view to reset selected file to selected commit
This commit is contained in:
parent
db8de81120
commit
9a68d70b29
3 changed files with 39 additions and 1 deletions
|
@ -79,6 +79,11 @@ namespace SourceGit.ViewModels
|
||||||
_repo.NavigateToCommit(commit.SHA);
|
_repo.NavigateToCommit(commit.SHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetToSelectedRevision()
|
||||||
|
{
|
||||||
|
new Commands.Checkout(_repo.FullPath).FileWithRevision(_file, $"{_selectedCommit.SHA}");
|
||||||
|
}
|
||||||
|
|
||||||
private void RefreshViewContent()
|
private void RefreshViewContent()
|
||||||
{
|
{
|
||||||
if (_selectedCommit == null)
|
if (_selectedCommit == null)
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
IsVisible="{Binding IsLoading}"/>
|
IsVisible="{Binding IsLoading}"/>
|
||||||
|
|
||||||
<Grid Grid.Column="2" RowDefinitions="Auto,*" IsVisible="{Binding !IsLoading}">
|
<Grid Grid.Column="2" RowDefinitions="Auto,*,Auto" IsVisible="{Binding !IsLoading}">
|
||||||
<ListBox Grid.Row="0"
|
<ListBox Grid.Row="0"
|
||||||
Margin="0,8"
|
Margin="0,8"
|
||||||
SelectedIndex="{Binding ViewMode, Mode=TwoWay}"
|
SelectedIndex="{Binding ViewMode, Mode=TwoWay}"
|
||||||
|
@ -211,7 +211,22 @@
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ContentControl.DataTemplates>
|
</ContentControl.DataTemplates>
|
||||||
</ContentControl>
|
</ContentControl>
|
||||||
|
|
||||||
|
<Button Grid.Row="2"
|
||||||
|
Classes="flat primary"
|
||||||
|
Margin="0,0,0,8"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Content="{DynamicResource Text.ChangeCM.CheckoutThisRevision}"
|
||||||
|
Click="OnResetToSelectedRevision"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Border Grid.Row="1" x:Name="NotifyDonePanel" Background="Transparent" IsVisible="False" PointerPressed="OnCloseNotifyPanel">
|
||||||
|
<Border HorizontalAlignment="Center" VerticalAlignment="Center" Effect="drop-shadow(0 0 12 #80000000)">
|
||||||
|
<Border CornerRadius="8" Background="{DynamicResource Brush.Popup}" Padding="32">
|
||||||
|
<Path Width="52" Height="52" Data="{StaticResource Icons.Check}" Fill="Green"/>
|
||||||
|
</Border>
|
||||||
|
</Border>
|
||||||
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
</v:ChromelessWindow>
|
</v:ChromelessWindow>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
|
||||||
namespace SourceGit.Views
|
namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
|
@ -38,5 +39,22 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnResetToSelectedRevision(object _, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (DataContext is ViewModels.FileHistories vm)
|
||||||
|
{
|
||||||
|
vm.ResetToSelectedRevision();
|
||||||
|
NotifyDonePanel.IsVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCloseNotifyPanel(object _, PointerPressedEventArgs e)
|
||||||
|
{
|
||||||
|
NotifyDonePanel.IsVisible = false;
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue