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

Commit 2c87346

Browse files
committed
Hide hyperlinks when disabled.
WPF doesn't make this easy as there's no Hyperlink.Visibility property. Hack around it for now...
1 parent 6d98cdd commit 2c87346

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/GitHub.VisualStudio/UI/Views/PullRequestDetailView.xaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
<d:DesignProperties.DataContext>
2020
<Binding>
2121
<Binding.Source>
22-
<sampleData:PullRequestDetailViewModelDesigner CheckoutMode="Push"
23-
CommitsBehind="2"/>
22+
<sampleData:PullRequestDetailViewModelDesigner CheckoutMode="NeedsPull"
23+
CommitsBehind="2"
24+
CheckoutDisabledMessage="Cannot update branch as your working directory has uncommitted changes."/>
2425
</Binding.Source>
2526
</Binding>
2627
</d:DesignProperties.DataContext>
@@ -80,6 +81,17 @@
8081
<Style x:Key="CheckoutMessage" TargetType="TextBlock">
8182
<Setter Property="Margin" Value="0 4"/>
8283
</Style>
84+
85+
<!-- Hyperlink has no Visibility property, sigh. Hack around this by making the text
86+
transparent and 1 px in size. -->
87+
<Style x:Key="HyperlinkHiddenWhenDisabled" TargetType="Hyperlink">
88+
<Style.Triggers>
89+
<Trigger Property="IsEnabled" Value="False">
90+
<Setter Property="Foreground" Value="Transparent"/>
91+
<Setter Property="FontSize" Value="1"/>
92+
</Trigger>
93+
</Style.Triggers>
94+
</Style>
8395
</ResourceDictionary>
8496
</Control.Resources>
8597

@@ -191,7 +203,7 @@
191203
<ui:OcticonImage Icon="sync" Foreground="Orange" Margin="0 0 0 -4"/>
192204
<Run>Your local branch is behind by</Run>
193205
<Run FontWeight="Bold" Text="{Binding CommitsBehind, StringFormat={}{0} commits.}"/>
194-
<Hyperlink Command="{Binding Checkout}">Update</Hyperlink>
206+
<Hyperlink Command="{Binding Checkout}" Style="{StaticResource HyperlinkHiddenWhenDisabled}">Update</Hyperlink>
195207
<TextBlock.Style>
196208
<Style TargetType="TextBlock" BasedOn="{StaticResource CheckoutMessage}">
197209
<Setter Property="Visibility" Value="Collapsed"/>
@@ -207,7 +219,7 @@
207219
<!-- Local branch exists but is not checked out -->
208220
<TextBlock TextWrapping="Wrap">
209221
<Run BaselineAlignment="Top">This branch is not currently checked out.</Run>
210-
<Hyperlink Command="{Binding Checkout}">Switch branch</Hyperlink>
222+
<Hyperlink Command="{Binding Checkout}" Style="{StaticResource HyperlinkHiddenWhenDisabled}">Switch branch</Hyperlink>
211223
<TextBlock.Style>
212224
<Style TargetType="TextBlock" BasedOn="{StaticResource CheckoutMessage}">
213225
<Setter Property="Visibility" Value="Collapsed"/>
@@ -224,7 +236,7 @@
224236
<TextBlock TextWrapping="Wrap">
225237
<ui:OcticonImage Icon="alert" Foreground="Orange" Margin="0 0 0 -4"/>
226238
<Run BaselineAlignment="Top">The pull request branch has local changes.</Run>
227-
<Hyperlink Command="{Binding Checkout}">Checkout to a new branch</Hyperlink>
239+
<Hyperlink Command="{Binding Checkout}" Style="{StaticResource HyperlinkHiddenWhenDisabled}">Checkout to a new branch</Hyperlink>
228240
<TextBlock.Style>
229241
<Style TargetType="TextBlock" BasedOn="{StaticResource CheckoutMessage}">
230242
<Setter Property="Visibility" Value="Collapsed"/>

0 commit comments

Comments
 (0)