Skip to content

Commit e9bc7fc

Browse files
committed
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>
1 parent a4306fe commit e9bc7fc

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/ViewModels/Fetch.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ public List<Models.Remote> Remotes
1010
get => _repo.Remotes;
1111
}
1212

13+
public bool IsFetchAllRemoteVisible
14+
{
15+
get;
16+
private set;
17+
} = true;
18+
1319
public bool FetchAllRemotes
1420
{
15-
get => _fetchAllRemotes;
16-
set => SetProperty(ref _fetchAllRemotes, value);
17-
}
21+
get;
22+
set;
23+
} = false;
1824

1925
public Models.Remote SelectedRemote
2026
{
@@ -37,7 +43,7 @@ public bool Force
3743
public Fetch(Repository repo, Models.Remote preferredRemote = null)
3844
{
3945
_repo = repo;
40-
_fetchAllRemotes = preferredRemote == null;
46+
IsFetchAllRemoteVisible = repo.Remotes.Count > 1 && preferredRemote == null;
4147

4248
if (preferredRemote != null)
4349
{
@@ -92,6 +98,5 @@ public override async Task<bool> Sure()
9298
}
9399

94100
private readonly Repository _repo = null;
95-
private bool _fetchAllRemotes;
96101
}
97102
}

src/Views/BranchTree.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ private ContextMenu CreateContextMenuForRemote(ViewModels.Repository repo, Model
894894
fetch.Click += (_, e) =>
895895
{
896896
if (repo.CanCreatePopup())
897-
repo.ShowAndStartPopup(new ViewModels.Fetch(repo, remote));
897+
repo.ShowPopup(new ViewModels.Fetch(repo, remote));
898898
e.Handled = true;
899899
};
900900

src/Views/Fetch.axaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<TextBlock FontSize="18"
1212
Classes="bold"
1313
Text="{DynamicResource Text.Fetch.Title}"/>
14-
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32" ColumnDefinitions="120,*">
14+
<Grid Margin="0,16,0,0" RowDefinitions="32,32,Auto,32" ColumnDefinitions="120,*">
1515
<TextBlock Grid.Row="0" Grid.Column="0"
1616
HorizontalAlignment="Right" VerticalAlignment="Center"
1717
Margin="0,0,8,0"
@@ -20,8 +20,13 @@
2020
Height="28" Padding="8,0"
2121
VerticalAlignment="Center" HorizontalAlignment="Stretch"
2222
ItemsSource="{Binding Remotes}"
23-
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}"
24-
IsEnabled="{Binding !FetchAllRemotes}">
23+
SelectedItem="{Binding SelectedRemote, Mode=TwoWay}">
24+
<ComboBox.IsEnabled>
25+
<MultiBinding Converter="{x:Static BoolConverters.And}">
26+
<Binding Path="IsFetchAllRemoteVisible"/>
27+
<Binding Path="FetchAllRemotes" Converter="{x:Static BoolConverters.Not}"/>
28+
</MultiBinding>
29+
</ComboBox.IsEnabled>
2530
<ComboBox.ItemTemplate>
2631
<DataTemplate x:DataType="{x:Type m:Remote}">
2732
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
@@ -38,8 +43,10 @@
3843
ToolTip.Tip="--force"/>
3944

4045
<CheckBox Grid.Row="2" Grid.Column="1"
46+
Height="32"
4147
Content="{DynamicResource Text.Fetch.AllRemotes}"
4248
IsChecked="{Binding FetchAllRemotes, Mode=TwoWay}"
49+
IsVisible="{Binding IsFetchAllRemoteVisible, Mode=OneWay}"
4350
ToolTip.Tip="--all"/>
4451

4552
<CheckBox Grid.Row="3" Grid.Column="1"

0 commit comments

Comments
 (0)