Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 1cccfe2

Browse files
authored
Merge pull request #1015 from github/fixes/1014-remove-2fa-progressbar
Hide additional progress bar in 2FA dialog.
2 parents 06b4c7d + 471b51e commit 1cccfe2

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

src/GitHub.UI.Reactive/Controls/ViewBase.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ public class ViewBase : ContentControl
4242
typeof(ViewBase),
4343
new FrameworkPropertyMetadata());
4444

45+
static readonly DependencyProperty ShowBusyStateProperty =
46+
DependencyProperty.Register(
47+
nameof(ShowBusyState),
48+
typeof(bool),
49+
typeof(ViewBase),
50+
new FrameworkPropertyMetadata(true));
51+
4552
public static readonly DependencyProperty HasBusyStateProperty = HasBusyStatePropertyKey.DependencyProperty;
4653
public static readonly DependencyProperty IsBusyProperty = IsBusyPropertyKey.DependencyProperty;
4754
public static readonly DependencyProperty IsLoadingProperty = IsLoadingPropertyKey.DependencyProperty;
@@ -83,6 +90,15 @@ public bool IsLoading
8390
protected set { SetValue(IsLoadingPropertyKey, value); }
8491
}
8592

93+
/// <summary>
94+
/// Gets or sets a value indicating whether to display the view model's busy state.
95+
/// </summary>
96+
public bool ShowBusyState
97+
{
98+
get { return (bool)GetValue(ShowBusyStateProperty); }
99+
set { SetValue(ShowBusyStateProperty, value); }
100+
}
101+
86102
internal ViewBase()
87103
{
88104
}

src/GitHub.UI.Reactive/Themes/Generic.xaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,28 @@
3232

3333
<ui:GitHubProgressBar Foreground="{DynamicResource GitHubAccentBrush}"
3434
IsIndeterminate="True"
35-
Style="{DynamicResource GitHubProgressBar}"
36-
Visibility="{TemplateBinding IsBusy, Converter={ui:BooleanToHiddenVisibilityConverter}}"/>
35+
Style="{DynamicResource GitHubProgressBar}">
36+
<ui:GitHubProgressBar.Visibility>
37+
<MultiBinding Converter="{ui:MultiBooleanToVisibilityConverter}">
38+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="IsBusy"/>
39+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ShowBusyState"/>
40+
</MultiBinding>
41+
</ui:GitHubProgressBar.Visibility>
42+
</ui:GitHubProgressBar>
3743

3844
<c:Spinner Name="spinner"
3945
Grid.Row="1"
4046
Width="48"
4147
Height="48"
4248
HorizontalAlignment="Center"
43-
VerticalAlignment="Center"
44-
Visibility="{TemplateBinding IsLoading, Converter={ui:BooleanToVisibilityConverter}}"/>
49+
VerticalAlignment="Center">
50+
<c:Spinner.Visibility>
51+
<MultiBinding Converter="{ui:MultiBooleanToVisibilityConverter}">
52+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="IsLoading"/>
53+
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ShowBusyState"/>
54+
</MultiBinding>
55+
</c:Spinner.Visibility>
56+
</c:Spinner>
4557

4658
<ContentPresenter Grid.Row="1"
4759
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Linq;
4+
using System.Windows;
5+
using NullGuard;
6+
7+
namespace GitHub.UI
8+
{
9+
[Localizability(LocalizationCategory.NeverLocalize)]
10+
public sealed class MultiBooleanToVisibilityConverter : MultiValueConverterMarkupExtension<MultiBooleanToVisibilityConverter>
11+
{
12+
readonly System.Windows.Controls.BooleanToVisibilityConverter converter = new System.Windows.Controls.BooleanToVisibilityConverter();
13+
14+
public override object Convert(
15+
[AllowNull]object[] value,
16+
[AllowNull]Type targetType,
17+
[AllowNull]object parameter,
18+
[AllowNull]CultureInfo culture)
19+
{
20+
return value.OfType<bool>().All(x => x) ? Visibility.Visible : Visibility.Collapsed;
21+
}
22+
23+
public override object[] ConvertBack(
24+
[AllowNull]object value,
25+
[AllowNull]Type[] targetType,
26+
[AllowNull]object parameter,
27+
[AllowNull]CultureInfo culture)
28+
{
29+
return null;
30+
}
31+
}
32+
}

src/GitHub.UI/GitHub.UI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<DependentUpon>Spinner.xaml</DependentUpon>
9292
</Compile>
9393
<Compile Include="Converters\AllCapsConverter.cs" />
94+
<Compile Include="Converters\MultiBooleanToVisibilityConverter.cs" />
9495
<Compile Include="Converters\NullToVisibilityConverter.cs" />
9596
<Compile Include="Converters\BranchNameConverter.cs" />
9697
<Compile Include="Converters\CountToVisibilityConverter.cs" />

src/GitHub.VisualStudio/UI/Views/Controls/TwoFactorControl.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
d:DesignWidth="414"
1616
d:DesignHeight="440"
1717
Style="{DynamicResource DialogUserControl}"
18+
ShowBusyState="False"
1819
AutomationProperties.AutomationId="{x:Static automation:AutomationIDs.TwoFactorAuthenticationCustom}" >
1920

2021
<Control.Resources>

0 commit comments

Comments
 (0)