diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index fea4f5cea3c..8ff65455544 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -1333,6 +1333,24 @@ public static string DownloadWarningMessageBoxTitle { } } + /// + /// Looks up a localized string similar to Files with same name will be overwritten in the final package. To avoid this, rename or discard the duplicate files, or enable the Retain Folder Structure option.\n\n{0} duplicate file(s) found:\n{1}. + /// + public static string DuplicateFilesInPublishWarningMessage { + get { + return ResourceManager.GetString("DuplicateFilesInPublishWarningMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Duplicate Files. + /// + public static string DuplicateFilesInPublishWarningTitle { + get { + return ResourceManager.GetString("DuplicateFilesInPublishWarningTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Show File Trust Warning. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index 1d3c271eb00..f40410b0fd0 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -3983,6 +3983,12 @@ To make this file into a new template, save it to a different folder, then move #Learn more=https://primer2.dynamobim.org/1_developer_primer_intro/3_developing_for_dynamo/updating-your-packages-and-dynamo-libraries-for-dynamo-3x-net8 + + Files with same name will be overwritten in the final package. To avoid this, rename or discard the duplicate files, or enable the Retain Folder Structure option.\n\n{0} duplicate file(s) found:\n{1} + + + Duplicate Files + Failed to create node: diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index 1938f65dbc9..aedca471753 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -3970,6 +3970,12 @@ To make this file into a new template, save it to a different folder, then move #Learn more=https://primer2.dynamobim.org/1_developer_primer_intro/3_developing_for_dynamo/updating-your-packages-and-dynamo-libraries-for-dynamo-3x-net8 + + Files with same name will be overwritten in the final package. To avoid this, rename or discard the duplicate files, or enable the Retain Folder Structure option.\n\n{0} duplicate file(s) found:\n{1} + + + Duplicate Files + Failed to create node: diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index 6ff50196f54..38059d120a9 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -1514,6 +1514,8 @@ Dynamo.UI.IViewModelView.ViewModel.get -> T Dynamo.UI.Prompts.DynamoMessageBox Dynamo.UI.Prompts.DynamoMessageBox.BodyText.get -> string Dynamo.UI.Prompts.DynamoMessageBox.BodyText.set -> void +Dynamo.UI.Prompts.DynamoMessageBox.DialogFlags +Dynamo.UI.Prompts.DynamoMessageBox.DialogFlags.Scrollable = 0 -> Dynamo.UI.Prompts.DynamoMessageBox.DialogFlags Dynamo.UI.Prompts.DynamoMessageBox.DialogResult.get -> bool? Dynamo.UI.Prompts.DynamoMessageBox.DialogResult.set -> void Dynamo.UI.Prompts.DynamoMessageBox.DynamoMessageBox() -> void @@ -4288,6 +4290,7 @@ static Dynamo.UI.Prompts.DynamoMessageBox.Show(string messageBoxText, string cap static Dynamo.UI.Prompts.DynamoMessageBox.Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button) -> System.Windows.MessageBoxResult static Dynamo.UI.Prompts.DynamoMessageBox.Show(string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon, string tooltip = "") -> System.Windows.MessageBoxResult static Dynamo.UI.Prompts.DynamoMessageBox.Show(System.Windows.Window owner, string messageBoxText, string caption, bool showRichTextBox, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon) -> System.Windows.MessageBoxResult +static Dynamo.UI.Prompts.DynamoMessageBox.Show(System.Windows.Window owner, string messageBoxText, string caption, System.Collections.Generic.Dictionary flags, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon) -> System.Windows.MessageBoxResult static Dynamo.UI.Prompts.DynamoMessageBox.Show(System.Windows.Window owner, string messageBoxText, string caption, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage icon) -> System.Windows.MessageBoxResult static Dynamo.UI.SharedDictionaryManager.ConnectorsDictionary.get -> System.Windows.ResourceDictionary static Dynamo.UI.SharedDictionaryManager.ConnectorsDictionaryUri.get -> System.Uri @@ -4473,6 +4476,8 @@ static Dynamo.Wpf.Properties.Resources.DisablePackageInstallIconTooltip.get -> s static Dynamo.Wpf.Properties.Resources.DiscardChangesWarningPopupCaption.get -> string static Dynamo.Wpf.Properties.Resources.DiscardChangesWarningPopupMessage.get -> string static Dynamo.Wpf.Properties.Resources.DownloadWarningMessageBoxTitle.get -> string +static Dynamo.Wpf.Properties.Resources.DuplicateFilesInPublishWarningMessage.get -> string +static Dynamo.Wpf.Properties.Resources.DuplicateFilesInPublishWarningTitle.get -> string static Dynamo.Wpf.Properties.Resources.DynamoShowFileTrustWarning.get -> string static Dynamo.Wpf.Properties.Resources.DynamoUpdateAvailableToolTip.get -> string static Dynamo.Wpf.Properties.Resources.DynamoViewCancelButtonTooltip.get -> string @@ -5502,6 +5507,7 @@ static Dynamo.Wpf.Utilities.MessageBoxService.Show(string msg, string title, boo static Dynamo.Wpf.Utilities.MessageBoxService.Show(string msg, string title, System.Windows.MessageBoxButton button, System.Collections.Generic.IEnumerable buttonNames, System.Windows.MessageBoxImage img) -> System.Windows.MessageBoxResult static Dynamo.Wpf.Utilities.MessageBoxService.Show(string msg, string title, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage img) -> System.Windows.MessageBoxResult static Dynamo.Wpf.Utilities.MessageBoxService.Show(System.Windows.Window owner, string msg, string title, bool showRichTextBox, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage img) -> System.Windows.MessageBoxResult +static Dynamo.Wpf.Utilities.MessageBoxService.Show(System.Windows.Window owner, string msg, string title, System.Collections.Generic.Dictionary flags, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage img) -> System.Windows.MessageBoxResult static Dynamo.Wpf.Utilities.MessageBoxService.Show(System.Windows.Window owner, string msg, string title, System.Windows.MessageBoxButton button, System.Collections.Generic.IEnumerable buttonNames, System.Windows.MessageBoxImage img) -> System.Windows.MessageBoxResult static Dynamo.Wpf.Utilities.MessageBoxService.Show(System.Windows.Window owner, string msg, string title, System.Windows.MessageBoxButton button, System.Windows.MessageBoxImage img) -> System.Windows.MessageBoxResult static Dynamo.Wpf.Utilities.WebView2Utilities.ValidateWebView2RuntimeInstalled() -> bool diff --git a/src/DynamoCoreWpf/UI/Prompts/DynamoMessageBox.xaml b/src/DynamoCoreWpf/UI/Prompts/DynamoMessageBox.xaml index 434fcead8db..a5c05c44a15 100644 --- a/src/DynamoCoreWpf/UI/Prompts/DynamoMessageBox.xaml +++ b/src/DynamoCoreWpf/UI/Prompts/DynamoMessageBox.xaml @@ -139,8 +139,18 @@ + + + + + public string Tooltip { get; private set; } + /// + /// A list of customization options for dialog box + /// + public enum DialogFlags + { + //Enables scrollable text in the message box + Scrollable = 0, + } + #endregion /// @@ -204,6 +213,7 @@ public static MessageBoxResult Show(Window owner, string messageBoxText, string dynamoMessageBox.ShowDialog(); return dynamoMessageBox.CustomDialogResult; } + /// /// Displays a dialog to the user and returns their choice as a MessageBoxResult. /// @@ -234,6 +244,41 @@ public static MessageBoxResult Show(Window owner,string messageBoxText, string c return dynamoMessageBox.CustomDialogResult; } + /// + /// Displays a dialog to the user and returns their choice as a MessageBoxResult. + /// + /// owning window of the messagebox + /// Content of the message + /// MessageBox title + /// Provide a list of flags that can be used to customize the dialog box, e.g Scrollable + /// Type of button shown in the MessageBox: Ok, OkCancel; etc + /// Type of message: Warning, Error + /// + public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, Dictionary flags, MessageBoxButton button, + MessageBoxImage icon) + { + var dynamoMessageBox = new DynamoMessageBox + { + BodyText = messageBoxText, + TitleText = caption, + MessageBoxButton = button, + MessageBoxImage = icon + }; + if (owner != null && owner.IsLoaded) + { + dynamoMessageBox.Owner = owner; + } + + if (flags.TryGetValue(DialogFlags.Scrollable, out bool scrollable) && scrollable) + { + dynamoMessageBox.BodyTextBlock.Visibility = Visibility.Collapsed; + dynamoMessageBox.ScrollableBodyTextBlock.Visibility = Visibility.Visible; + } + dynamoMessageBox.ConfigureButtons(button); + dynamoMessageBox.ShowDialog(); + return dynamoMessageBox.CustomDialogResult; + } + /// /// Displays a dialog to the user and returns their choice as a MessageBoxResult. /// diff --git a/src/DynamoCoreWpf/Utilities/MessageBoxUtilities.cs b/src/DynamoCoreWpf/Utilities/MessageBoxUtilities.cs index 7bb7dde8969..c3da445ea1f 100644 --- a/src/DynamoCoreWpf/Utilities/MessageBoxUtilities.cs +++ b/src/DynamoCoreWpf/Utilities/MessageBoxUtilities.cs @@ -12,6 +12,7 @@ internal interface IMessageBox MessageBoxResult Show(string msg, string title, MessageBoxButton button, MessageBoxImage img); MessageBoxResult Show(string msg, string title, bool showRichTextBox, MessageBoxButton button, MessageBoxImage img); MessageBoxResult Show(Window owner, string msg, string title, bool showRichTextBox, MessageBoxButton button, MessageBoxImage img); + MessageBoxResult Show(Window owner, string msg, string title, Dictionary flags, MessageBoxButton button, MessageBoxImage img); MessageBoxResult Show(Window owner,string msg, string title, MessageBoxButton button, MessageBoxImage img); MessageBoxResult Show(Window owner, string msg, string title, MessageBoxButton button, IEnumerable buttonNames, MessageBoxImage img); MessageBoxResult Show(string msg, string title, MessageBoxButton button, IEnumerable buttonNames, MessageBoxImage img); @@ -34,6 +35,10 @@ MessageBoxResult IMessageBox.Show(Window owner, string msg, string title, bool s { return DynamoMessageBox.Show(owner,msg, title, showRichTextBox, button, img); } + MessageBoxResult IMessageBox.Show(Window owner, string msg, string title, Dictionary flags, MessageBoxButton button, MessageBoxImage img) + { + return DynamoMessageBox.Show(owner, msg, title, flags, button, img); + } public MessageBoxResult Show(Window owner, string msg, string title, MessageBoxButton button, MessageBoxImage img) { @@ -68,6 +73,10 @@ public static MessageBoxResult Show(Window owner, string msg, string title, bool { return (msg_box ?? (msg_box = new DefaultMessageBox())).Show(owner,msg, title, showRichTextBox, button, img); } + public static MessageBoxResult Show(Window owner, string msg, string title, Dictionary flags, MessageBoxButton button, MessageBoxImage img) + { + return (msg_box ?? (msg_box = new DefaultMessageBox())).Show(owner, msg, title, flags, button, img); + } public static MessageBoxResult Show(Window owner,string msg, string title, MessageBoxButton button, MessageBoxImage img) { return (msg_box ?? (msg_box = new DefaultMessageBox())).Show(owner,msg, title, button, img); diff --git a/src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs b/src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs index 869aced73fe..3cb1025dafb 100644 --- a/src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/PackageManager/PublishPackageViewModel.cs @@ -2649,6 +2649,22 @@ private void PreviewPackageBuild() return; var files = GetAllFiles().ToList(); + if (!RetainFolderStructureOverride) + { + //Look for duplicate filenames to alert user + var duplicateFiles = files.GroupBy(x => Path.GetFileName(x)) + .Where(x => x.Count() > 1) + .ToList(); + if (duplicateFiles.Count > 0) + { + if (!DynamoModel.IsTestMode) + { + var DialogOptions = new Dictionary() { { Dynamo.UI.Prompts.DynamoMessageBox.DialogFlags.Scrollable, true } }; + MessageBoxService.Show(System.Windows.Application.Current?.MainWindow, string.Format(Resources.DuplicateFilesInPublishWarningMessage.Replace("\\n", Environment.NewLine), duplicateFiles.Count, string.Join("\n", duplicateFiles.Select(x => x.Key).ToList())), Resources.DuplicateFilesInPublishWarningTitle, DialogOptions, MessageBoxButton.OK, MessageBoxImage.Warning); + } + } + } + files = files.GroupBy(file => Path.GetFileName(file), StringComparer.OrdinalIgnoreCase) .Select(group => group.First()) .ToList();