Skip to content

Commit

Permalink
previewbuild started
Browse files Browse the repository at this point in the history
- started the structure for preview build
  • Loading branch information
dnenov committed Oct 10, 2023
1 parent f922975 commit 4f704a7
Show file tree
Hide file tree
Showing 12 changed files with 1,063 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ internal void AddChild(PackageItemRootViewModel elem)

Dictionary<string, PackageItemRootViewModel> existingSubFolders = GetAllSubfolderItems(this);

if (di.FullName == this.DirectoryName)
{
this.ChildItems.Add(elem);
return;
}

while (di.Parent != null)
{
Expand Down
105 changes: 105 additions & 0 deletions src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ public string MarkdownFilesDirectory
/// PackageContents property
/// </summary>
public ObservableCollection<PackageItemRootViewModel> PackageContents { get; set; } = new ObservableCollection<PackageItemRootViewModel>();
public ObservableCollection<PackageItemRootViewModel> PreviewPackageContents { get; set; } = new ObservableCollection<PackageItemRootViewModel>();

private ObservableCollection<PackageItemRootViewModel> _rootContents;
/// <summary>
Expand Down Expand Up @@ -837,6 +838,8 @@ private void RefreshPackageContents()
updatedItems.AddRange(itemsToAdd.Where(pa => pa.DependencyType.Equals(DependencyType.CustomNode)));

foreach (var item in updatedItems) PackageContents.Add(item);

PreviewPackageBuild();
}

private bool IsDuplicateFile(PackageItemRootViewModel item1, PackageItemRootViewModel item2)
Expand Down Expand Up @@ -2009,5 +2012,107 @@ internal void EnableInvalidNameWarningState(string warningMessage)
CurrentWarningMessage = warningMessage;
IsWarningEnabled = true;
}

private void PreviewPackageBuild()
{
if (PackageContents?.Count == 0) return;

var publishPath = !String.IsNullOrEmpty(rootFolder) ? rootFolder : PackageContents.First().DirectoryName;
if (string.IsNullOrEmpty(publishPath))
return;

var files = GetAllFiles().ToList();

try
{
var unqualifiedFiles = GetAllUnqualifiedFiles();

// if the unqualified files are bigger than 0, error message is triggered.
// At the same time, as unqualified files existed,
// files returned from BuildPackage() is 0.
// This is caused by the package file is not existed or it has already been in a package.
// files.Count() is also checking for the exception that was caught in BuildPackage().
// The scenario can be user trying to publish unsaved workspace.
if (files == null || files.Count() < 1 || unqualifiedFiles.Count() > 0)
{
string filesCannotBePublished = null;
foreach (var file in unqualifiedFiles)
{
filesCannotBePublished = filesCannotBePublished + file + "\n";
}
string FileNotPublishMessage = string.Format(Resources.FileNotPublishMessage, filesCannotBePublished);
UploadState = PackageUploadHandle.State.Error;
MessageBoxResult response = DynamoModel.IsTestMode ? MessageBoxResult.OK : MessageBoxService.Show(FileNotPublishMessage, Resources.FileNotPublishCaption, MessageBoxButton.OK, MessageBoxImage.Error);

return;
}

var packageName = !string.IsNullOrEmpty(Description) ? Description : Path.GetFileName(publishPath);
PackageDirectoryBuilder.PreBuildDirectory(packageName, publishPath, files, MarkdownFiles,
out string rootDir, out string dyfDir, out string binDir, out string extraDir, out string docDir);

var rootItemPreview = new PackageItemRootViewModel(rootDir);
var dyfItemPreview = new PackageItemRootViewModel(dyfDir) { isChild = true };
var binItemPreview = new PackageItemRootViewModel(binDir) { isChild = true };
var extraItemPreview = new PackageItemRootViewModel(extraDir) { isChild = true };
var docItemPreview = new PackageItemRootViewModel(docDir) { isChild = true };


var pkg = new PackageItemRootViewModel(new FileInfo(Path.Combine(rootDir, "pkg.json")));
rootItemPreview.AddChild(pkg);

foreach(var file in files)
{
var fileName = Path.GetFileName(file);
if (Path.GetDirectoryName(file).EndsWith("doc"))
{
var doc = new PackageItemRootViewModel(new FileInfo(Path.Combine(binDir, packageName, fileName)));
docItemPreview.AddChild(doc);
}
else if (file.EndsWith(".dyf"))
{
var customNodeDefinition = CustomNodeDefinitions.FirstOrDefault(x => x.DisplayName.Equals(Path.GetFileNameWithoutExtension(fileName)));
if (customNodeDefinition == null) continue;
var dyf = new PackageItemRootViewModel(customNodeDefinition);
//dyfItemPreview.AddChild(dyf);
}
else if (file.EndsWith(".dll") || PackageDirectoryBuilder.IsXmlDocFile(file, files) || PackageDirectoryBuilder.IsDynamoCustomizationFile(file, files))
{
var assembly = Assemblies.FirstOrDefault(x => x.Name.Equals(Path.GetFileNameWithoutExtension(fileName)));
if (assembly == null)
{
var extra = new PackageItemRootViewModel(new FileInfo(Path.Combine(extraDir, packageName, fileName)));
extraItemPreview.AddChild(extra);
}
}
else
{
var extra = new PackageItemRootViewModel(new FileInfo(Path.Combine(extraDir, packageName, fileName)));
extraItemPreview.AddChild(extra);
}
}

rootItemPreview.AddChild(dyfItemPreview);
rootItemPreview.AddChild(binItemPreview);
rootItemPreview.AddChild(extraItemPreview);
rootItemPreview.AddChild(docItemPreview);

if (PreviewPackageContents == null) PreviewPackageContents = new ObservableCollection<PackageItemRootViewModel> { rootItemPreview };
else
{
PreviewPackageContents.Clear();
PreviewPackageContents.Add(rootItemPreview);
}

RaisePropertyChanged(nameof(PreviewPackageContents));
}
catch (Exception e)
{
UploadState = PackageUploadHandle.State.Error;
ErrorString = e.Message;
dynamoViewModel.Model.Logger.Log(e);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@
<Trigger Property="IsExpanded" Value="False">
<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
</Trigger>
<Trigger Property="HasItems" Value="False">
<!--<Trigger Property="HasItems" Value="False">
<Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
</Trigger>
</Trigger>-->
<Trigger Property="HasItems" Value="True">
<Setter Property="Height" TargetName="VerticalMarker" Value="12"/>
</Trigger>
Expand Down Expand Up @@ -660,9 +660,10 @@
<Setter Property="FontSize" Value="12"/>
<Setter Property="Foreground" Value="#F5F5F5"/>
<Style.Triggers>
<Trigger Property="HasItems" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
<DataTrigger Binding="{Binding DependencyType, Converter={StaticResource DependencyTypeToVisibilityConverter}, ConverterParameter=Folder}"
Value="Collapsed">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>

Expand All @@ -683,7 +684,7 @@
FontSize="14"
SnapsToDevicePixels="True"
UseLayoutRounding="True"
FontFamily="{StaticResource ArtifaktElementRegular}" />
FontFamily="{StaticResource ArtifaktElementRegular}"/>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</ResourceDictionary.MergedDictionaries>
<controls:EmptyStringToFalseConverter x:Key="EmptyStringToFalseConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<SolidColorBrush x:Key="DetailsButtonBorderColorBrush" Color="#808080" Opacity="0.5"/>
<ControlTemplate x:Key="ComboBoxToggleButton"
TargetType="{x:Type ToggleButton}">
<Grid Height="29px"
Expand Down Expand Up @@ -296,30 +297,40 @@
BorderThickness="0"
BorderBrush="#7E7E7E">

<Grid Name="mainGrid" >
<Grid Name="mainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="66px" />
</Grid.RowDefinitions>

<StackPanel UseLayoutRounding="True" Margin="2">
<ItemsControl ItemsSource="{Binding Path=Breadcrumbs, RelativeSource={RelativeSource AncestorType=UserControl}}">
<ItemsControl.ItemTemplate>
<StackPanel UseLayoutRounding="True"
Margin="2">
<ItemsControl ItemsSource="{Binding Path=Breadcrumbs, RelativeSource={RelativeSource AncestorType=UserControl}}"
Name="breadcrumbsNavigation"
Visibility="Collapsed">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="/" FontSize="12" Margin="5,0,5,0" Foreground="#F5F5F5">
<TextBlock Text="/"
FontSize="12"
Margin="5,0,5,0"
Foreground="#F5F5F5">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource PreviousData}}" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" />
<DataTrigger Binding="{Binding RelativeSource={RelativeSource PreviousData}}"
Value="{x:Null}">
<Setter Property="Visibility"
Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<Button Content="{Binding}" Tag="{Binding}" Click="BreadcrumbButton_Click"
<Button Content="{Binding}"
Tag="{Binding}"
Click="BreadcrumbButton_Click"
Foreground="#F5F5F5"
FontSize="12"
FontFamily="{StaticResource ArtifaktElementRegular}"
Expand All @@ -338,49 +349,116 @@
<!-- Main navigation frame hosting the pages -->
<Frame x:Name="mainFrame"
Grid.Row="1"
NavigationUIVisibility="Hidden" />

NavigationUIVisibility="Hidden"
Navigated="mainFrame_Navigated"/>

<!-- Bottom Section: Publish Buttons + Status Label -->
<DockPanel Grid.Row="2"
Margin="25,0"
VerticalAlignment="Center">
<DockPanel VerticalAlignment="Center"
Grid.Row="2"
Margin="25,0">

<StackPanel DockPanel.Dock="Right"
x:Name="PublishPageButtonStack"
Orientation="Horizontal">
<!-- Publish Online -->
<Button Command="{Binding Path=SubmitCommand}"
Content="{x:Static p:Resources.PublishPackage}"
DockPanel.Dock="Right"
Background="#0696D7"
Foreground="White"
BorderBrush="#0696D7"
Margin="0,0,-5,0"
Style="{StaticResource CtaButtonStyle}"
TabIndex="20" />

<!-- Publish Locally -->
<Button Command="{Binding Path=PublishLocallyCommand}"
Content="{x:Static p:Resources.PublishPackageLocally}"
DockPanel.Dock="Right"
Margin="0,0,2,0"
Background="#0696D7"
Foreground="White"
BorderBrush="#0696D7"
Style="{StaticResource CtaButtonStyle}"
TabIndex="19" />
</StackPanel>

<StackPanel DockPanel.Dock="Right"
x:Name="SelectPageButtonStack"
Orientation="Horizontal"
Visibility="Collapsed">


<!-- Publish Online -->
<Button Command="{Binding Path=SubmitCommand}"
Content="{x:Static p:Resources.PublishPackage}"
DockPanel.Dock="Right"
Background="#0696D7"
Foreground="White"
BorderBrush="#0696D7"
Margin="0,0,-5,0"
Style="{StaticResource CtaButtonStyle}"
TabIndex="20" />
<!-- Back to Details -->
<Button Content="Back to Package Details"
Tag="Back"
Click="BreadcrumbButton_Click"
DockPanel.Dock="Right"
Background="Transparent"
Foreground="White"
BorderBrush="{StaticResource DetailsButtonBorderColorBrush}"
Margin="0,0,-5,0"
Style="{StaticResource CtaButtonStyle}"
TabIndex="20" />

<!-- Next -->
<Button Content="Next"
Tag="Next"
Click="BreadcrumbButton_Click"
DockPanel.Dock="Right"
Margin="0,0,2,0"
Background="#0696D7"
Foreground="White"
BorderBrush="#0696D7"
Style="{StaticResource CtaButtonStyle}"
TabIndex="19" />
</StackPanel>

<!-- Publish Locally -->
<Button Command="{Binding Path=PublishLocallyCommand}"
Content="{x:Static p:Resources.PublishPackageLocally}"
DockPanel.Dock="Right"
Margin="0,0,2,0"
Background="#0696D7"
Foreground="White"
BorderBrush="#0696D7"
Style="{StaticResource CtaButtonStyle}"
TabIndex="19" />
<StackPanel DockPanel.Dock="Right"
x:Name="PreviewPageButtonStack"
Orientation="Horizontal"
Visibility="Collapsed">

<!-- Back to Selection -->
<Button Content="Back to File Selection"
Tag="Back"
Click="BreadcrumbButton_Click"
DockPanel.Dock="Right"
Background="Transparent"
Foreground="White"
BorderBrush="{StaticResource DetailsButtonBorderColorBrush}"
Margin="0,0,-5,0"
Style="{StaticResource CtaButtonStyle}"
TabIndex="20" />

<!-- Finish -->
<Button Content="Finish"
Tag="Next"
Click="BreadcrumbButton_Click"
DockPanel.Dock="Right"
Margin="0,0,2,0"
Background="#0696D7"
Foreground="White"
BorderBrush="#0696D7"
Style="{StaticResource CtaButtonStyle}"
TabIndex="19" />
</StackPanel>

<!-- Status Label -->
<TextBlock Name="statusLabel"
Margin="0,4,0,0"
VerticalAlignment="Center"
FontFamily="{StaticResource ArtifaktElementRegular}"
Style="{StaticResource LabelStyle}"
Text="{Binding ErrorString, UpdateSourceTrigger=PropertyChanged}"
TextTrimming="CharacterEllipsis">
<TextBlock Margin="0,4,0,0"
VerticalAlignment="Center"
FontFamily="{StaticResource ArtifaktElementRegular}"
Style="{StaticResource LabelStyle}"
Text="{Binding ErrorString, UpdateSourceTrigger=PropertyChanged}"
TextTrimming="CharacterEllipsis">
<TextBlock.ToolTip>
<ToolTip Content="{Binding ErrorString, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource GenericToolTipLight}" />
Style="{StaticResource GenericToolTipLight}" />
</TextBlock.ToolTip>
</TextBlock>
</DockPanel>


</Grid>
</Border>
</UserControl>
Loading

0 comments on commit 4f704a7

Please sign in to comment.