Skip to content

Commit

Permalink
add no changes state to diff viewer (#11001) (#11014)
Browse files Browse the repository at this point in the history
* add has changes state to diff viewer

* update text + change engine on accept

* typo

Co-authored-by: Sylvester Knudsen <[email protected]>
  • Loading branch information
mmisol and SHKnudsen authored Aug 17, 2020
1 parent f845916 commit ecf9e76
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/PythonMigrationViewExtension/Controls/BaseDiffViewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,42 @@
<DataTemplate DataType="{x:Type viewModels:SideBySideViewModel}">
<local:SideBySideControl DataContext="{Binding}" />
</DataTemplate>
<Style x:Key="HasDifferenceController"
TargetType="{x:Type ContentControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=CurrentViewModel.HasChanges}"
Value="True">
<Setter Property="Content"
Value="{Binding Path=CurrentViewModel}">
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Path=CurrentViewModel.HasChanges}"
Value="False">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Vertical"
VerticalAlignment="Center"
Width="400">
<TextBlock Text="{x:Static p:Resources.MigrationAssistantNoChangesStateHeader}"
TextAlignment="Center"
HorizontalAlignment="Center"
FontSize="24"
Foreground="{StaticResource WorkspaceTabHeaderActiveTextBrush}"
TextWrapping="Wrap" />
<TextBlock Text="{x:Static p:Resources.MigrationAssistantNoChangesStateMessage}"
TextAlignment="Center"
HorizontalAlignment="Center"
FontSize="14"
Foreground="{StaticResource WorkspaceTabHeaderActiveTextBrush}"
TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</Window.Resources>

Expand Down Expand Up @@ -56,8 +92,9 @@
</Style>
</Grid.Resources>

<ContentControl Content="{Binding CurrentViewModel}"
<ContentControl Style="{StaticResource HasDifferenceController}"
Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>


<!-- Buttons row -->
<Grid HorizontalAlignment="Stretch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public interface IDiffViewViewModel
{
ViewMode ViewMode { get; }
bool HasChanges { get; }
}

public enum ViewMode
Expand Down
1 change: 1 addition & 0 deletions src/PythonMigrationViewExtension/Differ/InLineViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class InLineViewModel : IDiffViewViewModel
{
public ViewMode ViewMode { get; set; }
public DiffPaneModel DiffModel { get; set; }
public bool HasChanges { get { return DiffModel.HasDifferences; } }

public InLineViewModel(SideBySideDiffModel diffModel)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class SideBySideViewModel : IDiffViewViewModel
public SideBySideDiffModel DiffModel { get; set; }
public DiffPaneModel AfterPane { get { return DiffModel.NewText; } }
public DiffPaneModel BeforePane { get { return DiffModel.OldText; } }
public bool HasChanges { get { return DiffModel.NewText.HasDifferences | DiffModel.OldText.HasDifferences; } }

public SideBySideViewModel(SideBySideDiffModel diffModel)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ private void MigrateCode()
/// </summary>
public void ChangeCode()
{
if (!this.CurrentViewModel.HasChanges)
{
if (this.PythonNode.Engine == PythonEngineVersion.CPython3)
return;
this.PythonNode.Engine = PythonEngineVersion.CPython3;
return;
}

if (!Models.DynamoModel.IsTestMode && !File.Exists(GetMigrationAssistantDisclaimerDismissFile()))
{
var warningMessage = new MigrationAssistantDisclaimer(this);
Expand Down
18 changes: 18 additions & 0 deletions src/PythonMigrationViewExtension/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ By clicking “Continue”, you are agreeing to implement the syntax changes to
<data name="MigrationAssistantDisclaimerWindowTitle" xml:space="preserve">
<value>Migration Assistant Disclaimer</value>
</data>
<data name="MigrationAssistantNoChangesStateHeader" xml:space="preserve">
<value>Nothing to see here!</value>
</data>
<data name="MigrationAssistantNoChangesStateMessage" xml:space="preserve">
<value>Your code is ready to run with the Python 3 engine. Click accept and we'll switch to the Python 3 engine for you.</value>
</data>
<data name="PackagedCustomNodesHeader" xml:space="preserve">
<value>Packaged</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions src/PythonMigrationViewExtension/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ By clicking “Continue”, you are agreeing to implement the syntax changes to
<data name="MigrationAssistantDisclaimerWindowTitle" xml:space="preserve">
<value>Migration Assistant Disclaimer</value>
</data>
<data name="MigrationAssistantNoChangesStateHeader" xml:space="preserve">
<value>Nothing to see here!</value>
</data>
<data name="MigrationAssistantNoChangesStateMessage" xml:space="preserve">
<value>Your code is ready to run with the Python 3 engine. Click accept and we'll switch to the Python 3 engine for you.</value>
</data>
<data name="PackagedCustomNodesHeader" xml:space="preserve">
<value>Packaged</value>
</data>
Expand Down

0 comments on commit ecf9e76

Please sign in to comment.