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);
|
||||
}
|
||||
|
||||
public void ResetToSelectedRevision()
|
||||
{
|
||||
new Commands.Checkout(_repo.FullPath).FileWithRevision(_file, $"{_selectedCommit.SHA}");
|
||||
}
|
||||
|
||||
private void RefreshViewContent()
|
||||
{
|
||||
if (_selectedCommit == null)
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
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"
|
||||
Margin="0,8"
|
||||
SelectedIndex="{Binding ViewMode, Mode=TwoWay}"
|
||||
|
@ -211,7 +211,22 @@
|
|||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
<Button Grid.Row="2"
|
||||
Classes="flat primary"
|
||||
Margin="0,0,0,8"
|
||||
HorizontalAlignment="Center"
|
||||
Content="{DynamicResource Text.ChangeCM.CheckoutThisRevision}"
|
||||
Click="OnResetToSelectedRevision"/>
|
||||
</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>
|
||||
</v:ChromelessWindow>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
|
@ -38,5 +39,22 @@ namespace SourceGit.Views
|
|||
|
||||
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