From fc26885b868fcff68d9dfd01a5aaee602749a22a Mon Sep 17 00:00:00 2001 From: Jaben Cargman Date: Sat, 6 Dec 2025 23:00:25 -0500 Subject: [PATCH 1/2] Add upgrade dialog with release notes display When clicking the upgrade notification, shows a dialog with: - Current and new version information - Release notes from Velopack (NotesHTML) - Upgrade and Ignore buttons User can review release notes before deciding to upgrade. Closes #344 --- src/Papercut.UI/ViewModels/MainViewModel.cs | 23 +++++ .../ViewModels/UpgradeDialogViewModel.cs | 86 ++++++++++++++++++ src/Papercut.UI/Views/UpgradeDialogView.xaml | 88 +++++++++++++++++++ .../Views/UpgradeDialogView.xaml.cs | 58 ++++++++++++ 4 files changed, 255 insertions(+) create mode 100644 src/Papercut.UI/ViewModels/UpgradeDialogViewModel.cs create mode 100644 src/Papercut.UI/Views/UpgradeDialogView.xaml create mode 100644 src/Papercut.UI/Views/UpgradeDialogView.xaml.cs diff --git a/src/Papercut.UI/ViewModels/MainViewModel.cs b/src/Papercut.UI/ViewModels/MainViewModel.cs index 99d33ea2..22220248 100644 --- a/src/Papercut.UI/ViewModels/MainViewModel.cs +++ b/src/Papercut.UI/ViewModels/MainViewModel.cs @@ -489,6 +489,29 @@ await this.ShowMessageAsync("Update Not Available", return; } + // Get release notes from the update info + var releaseNotesHtml = this._updateInfo.TargetFullRelease.NotesHTML; + var currentVersion = this.GetVersion() ?? "Unknown"; + var newVersion = this._updateInfo.TargetFullRelease.Version.ToString(); + + this._logger.Information("Showing upgrade dialog for version {NewVersion}", newVersion); + + // Create upgrade dialog view model + var upgradeDialog = new UI.ViewModels.UpgradeDialogViewModel(currentVersion, newVersion, releaseNotesHtml); + + // Get the window manager from DI and show the dialog manually + var windowManager = new Caliburn.Micro.WindowManager(); + var dialogResult = await windowManager.ShowDialogAsync(upgradeDialog); + + // Check user's choice + if (upgradeDialog.UserChoice != UI.ViewModels.UpgradeChoice.Upgrade) + { + this._logger.Information("User chose to ignore upgrade to version {Version}", newVersion); + return; + } + + this._logger.Information("User chose to upgrade to version {Version}", newVersion); + using var cancellationSource = new CancellationTokenSource(); var progressDialog = await this.ShowProgress("Updating", "Downloading Updates...", true, diff --git a/src/Papercut.UI/ViewModels/UpgradeDialogViewModel.cs b/src/Papercut.UI/ViewModels/UpgradeDialogViewModel.cs new file mode 100644 index 00000000..76433b24 --- /dev/null +++ b/src/Papercut.UI/ViewModels/UpgradeDialogViewModel.cs @@ -0,0 +1,86 @@ +// Papercut +// +// Copyright © 2008 - 2012 Ken Robertson +// Copyright © 2013 - 2024 Jaben Cargman +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Papercut.UI.ViewModels; + +using Caliburn.Micro; + +public class UpgradeDialogViewModel : Screen +{ + public UpgradeDialogViewModel( + string currentVersion, + string newVersion, + string? releaseNotesHtml) + { + this.CurrentVersion = currentVersion; + this.NewVersion = newVersion; + + // Use provided HTML or fallback message + if (string.IsNullOrWhiteSpace(releaseNotesHtml)) + { + this.ReleaseNotesHtml = @" + + + + + +

No release notes available.

+ + "; + } + else + { + this.ReleaseNotesHtml = releaseNotesHtml; + } + + this.UserChoice = UpgradeChoice.None; + } + + public string CurrentVersion { get; } + + public string NewVersion { get; } + + public string ReleaseNotesHtml { get; } + + public UpgradeChoice UserChoice { get; private set; } + + public void Upgrade() + { + this.UserChoice = UpgradeChoice.Upgrade; + this.TryCloseAsync(true); + } + + public void Ignore() + { + this.UserChoice = UpgradeChoice.Ignore; + this.TryCloseAsync(false); + } +} + +public enum UpgradeChoice +{ + None, + Upgrade, + Ignore +} diff --git a/src/Papercut.UI/Views/UpgradeDialogView.xaml b/src/Papercut.UI/Views/UpgradeDialogView.xaml new file mode 100644 index 00000000..079b79e3 --- /dev/null +++ b/src/Papercut.UI/Views/UpgradeDialogView.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +