mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-23 10:22:13 +08:00
refactor: disable --all by default while fetching (#1647)
- If there's only one remote or we have selected the remote to fetch changes from, do not show `Fetch all remotes` option - Disable `--all` by default Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -10,11 +10,17 @@ namespace SourceGit.ViewModels
|
||||
get => _repo.Remotes;
|
||||
}
|
||||
|
||||
public bool IsFetchAllRemoteVisible
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = true;
|
||||
|
||||
public bool FetchAllRemotes
|
||||
{
|
||||
get => _fetchAllRemotes;
|
||||
set => SetProperty(ref _fetchAllRemotes, value);
|
||||
}
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
|
||||
public Models.Remote SelectedRemote
|
||||
{
|
||||
@@ -37,7 +43,7 @@ namespace SourceGit.ViewModels
|
||||
public Fetch(Repository repo, Models.Remote preferredRemote = null)
|
||||
{
|
||||
_repo = repo;
|
||||
_fetchAllRemotes = preferredRemote == null;
|
||||
IsFetchAllRemoteVisible = repo.Remotes.Count > 1 && preferredRemote == null;
|
||||
|
||||
if (preferredRemote != null)
|
||||
{
|
||||
@@ -92,6 +98,5 @@ namespace SourceGit.ViewModels
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
private bool _fetchAllRemotes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -894,7 +894,7 @@ namespace SourceGit.Views
|
||||
fetch.Click += (_, e) =>
|
||||
{
|
||||
if (repo.CanCreatePopup())
|
||||
repo.ShowAndStartPopup(new ViewModels.Fetch(repo, remote));
|
||||
repo.ShowPopup(new ViewModels.Fetch(repo, remote));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<TextBlock FontSize="18"
|
||||
Classes="bold"
|
||||
Text="{DynamicResource Text.Fetch.Title}"/>
|
||||
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32" ColumnDefinitions="120,*">
|
||||
<Grid Margin="0,16,0,0" RowDefinitions="32,32,Auto,32" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
@@ -20,8 +20,13 @@
|
||||
Height="28" Padding="8,0"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding Remotes}"
|
||||
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}"
|
||||
IsEnabled="{Binding !FetchAllRemotes}">
|
||||
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}">
|
||||
<ComboBox.IsEnabled>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
<Binding Path="IsFetchAllRemoteVisible"/>
|
||||
<Binding Path="FetchAllRemotes" Converter="{x:Static BoolConverters.Not}"/>
|
||||
</MultiBinding>
|
||||
</ComboBox.IsEnabled>
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="{x:Type m:Remote}">
|
||||
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
|
||||
@@ -38,8 +43,10 @@
|
||||
ToolTip.Tip="--force"/>
|
||||
|
||||
<CheckBox Grid.Row="2" Grid.Column="1"
|
||||
Height="32"
|
||||
Content="{DynamicResource Text.Fetch.AllRemotes}"
|
||||
IsChecked="{Binding FetchAllRemotes, Mode=TwoWay}"
|
||||
IsVisible="{Binding IsFetchAllRemoteVisible, Mode=OneWay}"
|
||||
ToolTip.Tip="--all"/>
|
||||
|
||||
<CheckBox Grid.Row="3" Grid.Column="1"
|
||||
|
||||
Reference in New Issue
Block a user