Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages expander panel in the Workspace References panel #11744

Merged
merged 7 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/DynamoCore/Graph/Workspaces/PackageDependencyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ internal class PackageDependencyInfo : INodeLibraryDependencyInfo, IPackageInfo
/// </summary>
public string Name => PackageInfo.Name;

/// <summary>
/// Package path.
/// </summary>
public String Path { get; set; }

/// <summary>
/// Version of the package
/// </summary>
Expand Down
37 changes: 37 additions & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,43 @@
</Setter>
</Style>

<!-- This expander style is similar to the MenuExpanderStyle and the only difference is the left-margin spacing -->
<Style TargetType="Expander" x:Key="WorkspaceReferencesExpanderStyle">
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
<Setter Property="Background" Value="{StaticResource SecondaryGray}"/>
<Setter Property="Foreground" Value="{StaticResource PreferencesWindowFontColor}"/>
<Setter Property="Template">
<Setter.Value>
<!-- Control template for expander -->
<ControlTemplate TargetType="Expander" x:Name="exp">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Name="ContentRow" Height="0"/>
</Grid.RowDefinitions>
<Border Name="Border" Grid.Row="0" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="1" CornerRadius="0,0,0,0">
<ToggleButton IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True" Template="{StaticResource ExpanderToggleButton}" Background="#FF4682B4">
<ToggleButton.Content>
<ContentPresenter ContentSource="Header" RecognizesAccessKey="True" />
</ToggleButton.Content>
</ToggleButton>
</Border>
<Border x:Name="Content"
Grid.Row="1"
BorderThickness="1,0,1,1"
CornerRadius="0,0,4,4" >
<ContentPresenter Margin="2,0,0,15" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter TargetName="ContentRow" Property="Height" Value="{Binding ElementName=Content,Path=Height}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="LeftTab"
TargetType="{x:Type TabItem}">
<Setter Property="HorizontalAlignment"
Expand Down

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 @@ -362,8 +362,14 @@
jDoyqebiAAAAAElFTkSuQmCC
</value>
</data>
<data name="PackageHeaderName" xml:space="preserve">
<value>Name</value>
</data>
<data name="PackageHeaderText" xml:space="preserve">
<value>Package</value>
<value>Packages</value>
</data>
<data name="PackagePathText" xml:space="preserve">
<value>Path</value>
</data>
<data name="ProvideFeedbackButton" xml:space="preserve">
<value>Provide Feedback</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,14 @@
jDoyqebiAAAAAElFTkSuQmCC
</value>
</data>
<data name="PackageHeaderName" xml:space="preserve">
<value>Name</value>
</data>
<data name="PackageHeaderText" xml:space="preserve">
<value>Package</value>
<value>Packages</value>
</data>
<data name="PackagePathText" xml:space="preserve">
<value>Path</value>
</data>
<data name="ProvideFeedbackButton" xml:space="preserve">
<value>Provide Feedback</value>
Expand Down
197 changes: 109 additions & 88 deletions src/WorkspaceDependencyViewExtension/WorkspaceDependencyView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:w="clr-namespace:Dynamo.WorkspaceDependency.Properties"
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
xmlns:controls="clr-namespace:Dynamo.Controls;assembly=DynamoCoreWpf"
mc:Ignorable="d"
VerticalAlignment="Top"
HorizontalAlignment="Stretch">
Expand All @@ -16,6 +17,7 @@
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoModernDictionaryUri}" />
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoColorsAndBrushesDictionaryUri}" />
</ResourceDictionary.MergedDictionaries>
<controls:ExpandersBindingConverter x:Key="ExpandersBindingConverter"/>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<!-- DataGrid style -->
<Style x:Key="DataGridStyle1" TargetType="{x:Type DataGrid}">
Expand Down Expand Up @@ -79,102 +81,121 @@
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<DataGrid
Name="PackageDependencyTable"
AutoGenerateColumns="False"
Style="{StaticResource DataGridStyle1}"
CanUserAddRows="False"
GridLinesVisibility ="None"
Background="#353535"
FontSize="13"
VerticalAlignment="Center"
SelectionUnit="FullRow"
SelectionMode="Extended"
ScrollViewer.CanContentScroll="False"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
HeadersVisibility="Column"
Grid.Row="0">
<DataGrid.Columns>
<!-- State Icon -->
<DataGridTemplateColumn
IsReadOnly="True"
Width="38">
<DataGridTemplateColumn.Header>
<fa:ImageAwesome Name="Refresh"
Icon="Refresh"
ToolTip="{x:Static w:Resources.RefreshButtonTooltipText}"
MouseLeftButtonDown="Refresh_MouseLeftButtonDown"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Icon}" Width="18" Height="18" Margin="0,8,0,8"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<!-- Package Name -->
<DataGridTextColumn
Header="{x:Static w:Resources.PackageHeaderText}"
Binding="{Binding Name}"
Foreground="#aaaaaa"
IsReadOnly="True"
Width="*">
<Expander x:Name="Packages"
Grid.Row="0"
Style="{StaticResource WorkspaceReferencesExpanderStyle}"
Header="{x:Static w:Resources.PackageHeaderText}">
<DataGrid
Name="PackageDependencyTable"
AutoGenerateColumns="False"
Style="{StaticResource DataGridStyle1}"
CanUserAddRows="False"
GridLinesVisibility ="None"
Background="#353535"
FontSize="13"
VerticalAlignment="Center"
SelectionUnit="FullRow"
SelectionMode="Extended"
ScrollViewer.CanContentScroll="False"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
HeadersVisibility="Column">
<DataGrid.Columns>
<!-- State Icon -->
<DataGridTemplateColumn
IsReadOnly="True"
Width="38">
<DataGridTemplateColumn.Header>
<fa:ImageAwesome Name="Refresh"
Icon="Refresh"
ToolTip="{x:Static w:Resources.RefreshButtonTooltipText}"
MouseLeftButtonDown="Refresh_MouseLeftButtonDown"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Icon}" Width="18" Height="18" Margin="0,8,0,8"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<!-- Package Name -->
<DataGridTextColumn
Header="{x:Static w:Resources.PackageHeaderName}"
Binding="{Binding Name}"
Foreground="#aaaaaa"
IsReadOnly="True"
Width="*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="10,0,10,0"/>
<Setter Property="ToolTip" Value="{Binding Name}" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<!-- Package Path -->
<DataGridTextColumn
Header="{x:Static w:Resources.PackagePathText}"
Binding="{Binding Path}"
Foreground="#aaaaaa"
IsReadOnly="True"
Width="*">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="10,0,10,0"/>
<Setter Property="ToolTip" Value="{Binding Path}" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<!-- Package Version -->
<DataGridTextColumn
Header="{x:Static w:Resources.VersionHeaderText}"
Binding="{Binding Version}"
Foreground="#aaaaaa"
IsReadOnly="True"
>
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="10,0,10,0"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<!-- Package Version -->
<DataGridTextColumn
Header="{x:Static w:Resources.VersionHeaderText}"
Binding="{Binding Version}"
Foreground="#aaaaaa"
IsReadOnly="True"
>
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="10,0,10,0"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
</DataGrid.Columns>
<!-- Expanded Details -->
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel Background="#252525">
<TextBlock
Text="{Binding DetailsMessage}"
TextWrapping="Wrap"
TextAlignment="Center"
Foreground="{DynamicResource MemberButtonText}"
Margin="10"
FontSize="11">
</TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Style="{StaticResource SmallTextButton}"
Visibility="{Binding Path=ShowDownloadButton, Converter={StaticResource BoolToVis}}"
Name="DownloadPackageButton"
Click="DownloadPackage"
</DataGridTextColumn>
</DataGrid.Columns>
<!-- Expanded Details -->
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel Background="#252525">
<TextBlock
Text="{Binding DetailsMessage}"
TextWrapping="Wrap"
TextAlignment="Center"
Foreground="{DynamicResource MemberButtonText}"
Margin="10"
Content="{x:Static w:Resources.InstallButtonText}"/>
<Button Style="{StaticResource SmallTextButton}"
Visibility="{Binding Path=ShowKeepLocalButton, Converter={StaticResource BoolToVis}}"
Name="KeepLocalPackageButton"
Click="KeepLocalPackage"
Margin="10"
Content="{x:Static w:Resources.KeepLocalButtonText}">
</Button>
FontSize="11">
</TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Button Style="{StaticResource SmallTextButton}"
Visibility="{Binding Path=ShowDownloadButton, Converter={StaticResource BoolToVis}}"
Name="DownloadPackageButton"
Click="DownloadPackage"
Margin="10"
Content="{x:Static w:Resources.InstallButtonText}"/>
<Button Style="{StaticResource SmallTextButton}"
Visibility="{Binding Path=ShowKeepLocalButton, Converter={StaticResource BoolToVis}}"
Name="KeepLocalPackageButton"
Click="KeepLocalPackage"
Margin="10"
Content="{x:Static w:Resources.KeepLocalButtonText}">
</Button>
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>

</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
</Expander>
<!-- Fill Space -->
<Grid x:Name="container"
Background="Transparent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Dynamo.Controls;
using Dynamo.Graph.Workspaces;
using Dynamo.Logging;
using Dynamo.PackageManager;
using Dynamo.Utilities;
using Dynamo.ViewModels;
using Dynamo.Wpf.Extensions;
Expand Down Expand Up @@ -148,6 +149,19 @@ internal void DependencyRegen(WorkspaceModel ws)
this.RestartBanner.Visibility = hasPackageMarkedForUninstall ? Visibility.Visible: Visibility.Hidden;
}

var pmExtension = dependencyViewExtension.pmExtension;
if (pmExtension != null)
{
foreach (PackageDependencyInfo packageDependencyInfo in packageDependencies)
{
var targetInfo = pmExtension.PackageLoader.LocalPackages.Where(x => x.Name == packageDependencyInfo.Name).FirstOrDefault();
if (targetInfo != null)
{
packageDependencyInfo.Path = targetInfo.RootDirectory;
}
}
}

dataRows = packageDependencies.Select(d => new PackageDependencyRow(d as PackageDependencyInfo));
PackageDependencyTable.ItemsSource = dataRows;
}
Expand Down Expand Up @@ -251,6 +265,7 @@ internal void UpdateWorkspaceToUseInstalledPackage(PackageDependencyInfo info)
{
info.Version = new Version(targetInfo.VersionName);
info.State = PackageDependencyState.Loaded;
info.Path = targetInfo.RootDirectory;
// Mark the current workspace dirty for save
currentWorkspace.HasUnsavedChanges = true;
DependencyRegen(currentWorkspace);
Expand Down Expand Up @@ -295,6 +310,11 @@ internal PackageDependencyRow(PackageDependencyInfo nodeLibraryDependencyInfo)
/// </summary>
public string Name => DependencyInfo.Name;

/// <summary>
/// {ackage dependency path
/// </summary>
public string Path => DependencyInfo.Path;

/// <summary>
/// Version of this package dependency
/// </summary>
Expand Down