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

Show error if creating a widget fails #2264

Merged
merged 1 commit into from
Feb 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,12 @@
<value>Selected</value>
<comment>State of selected size for automatiom purposes</comment>
</data>
<data name="CouldNotCreateWidgetError" xml:space="preserve">
<value>Dev Home encountered an error. The widget could not be created.</value>
<comment>Error that pops up in a message dialog when the user tries to pin a widget but the widget could not be created.</comment>
</data>
<data name="CloseButtonText" xml:space="preserve">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the dialog would come with a close button and the button was set to the correct content?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not automatic, the ShowErrorMessageDialogAsync() method requires ButtonText. BUT, the (now) three places in the code all use "Close". Sounds like the best thing to do would be to make the button text optional with a default of "Close".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<value>Close</value>
<comment>Text for a button to close a content dialog.</comment>
</data>
</root>
10 changes: 10 additions & 0 deletions tools/Dashboard/DevHome.Dashboard/Views/DashboardView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Microsoft.Windows.Widgets;
using Microsoft.Windows.Widgets.Hosts;
using Windows.System;
using WinUIEx;
using Log = DevHome.Dashboard.Helpers.Log;

namespace DevHome.Dashboard.Views;
Expand Down Expand Up @@ -383,6 +384,15 @@ public async Task AddWidgetClickAsync()
catch (Exception ex)
{
Log.Logger()?.ReportWarn("AddWidgetDialog", $"Creating widget failed: ", ex);
var mainWindow = Application.Current.GetService<WindowEx>();
var resourceLoader =
new Microsoft.Windows.ApplicationModel.Resources.ResourceLoader(
"DevHome.Dashboard.pri",
"DevHome.Dashboard/Resources");
await mainWindow.ShowErrorMessageDialogAsync(
title: string.Empty,
content: resourceLoader.GetString("CouldNotCreateWidgetError"),
buttonText: resourceLoader.GetString("CloseButtonText"));
}
}
}
Expand Down
Loading