Skip to content

Commit 424b8fb

Browse files
authored
Merge pull request chocolatey#952 from corbob/919-global-confirmation
2 parents 927e8b7 + a7d63a3 commit 424b8fb

File tree

8 files changed

+102
-48
lines changed

8 files changed

+102
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ If you would like to contribute code or help squash a bug or two, that's awesome
8585
refreshenv
8686
```
8787
* Install WiX toolset integration for your Visual Studio Integration from [here](https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2019Extension)
88-
* From and **Administrative** PowerShell Window, navigate to the folder where you have cloned the Chocolatey GUI repository and run `build.ps1`, this will run Cake and it will go through the build script.
88+
* From an **Administrative** PowerShell Window, navigate to the folder where you have cloned the Chocolatey GUI repository and run `build.ps1`, this will run Cake and it will go through the build script.
8989
```
9090
./build.ps1
9191
```

Source/ChocolateyGui.Common.Windows/ViewModels/Items/PackageViewModel.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,13 @@ public async Task Reinstall()
479479
{
480480
try
481481
{
482-
var confirmationResult = await _dialogService.ShowConfirmationMessageAsync(
483-
L(nameof(Resources.Dialog_AreYouSureTitle)),
484-
L(nameof(Resources.Dialog_AreYouSureReinstallMessage), Id));
482+
var confirmationResult = MessageDialogResult.Affirmative;
483+
if (!_configService.GetEffectiveConfiguration().SkipModalDialogConfirmation.GetValueOrDefault(false))
484+
{
485+
confirmationResult = await _dialogService.ShowConfirmationMessageAsync(
486+
L(nameof(Resources.Dialog_AreYouSureTitle)),
487+
L(nameof(Resources.Dialog_AreYouSureReinstallMessage), Id));
488+
}
485489

486490
if (confirmationResult == MessageDialogResult.Affirmative)
487491
{
@@ -506,9 +510,13 @@ public async Task Uninstall()
506510
{
507511
try
508512
{
509-
var confirmationResult = await _dialogService.ShowConfirmationMessageAsync(
513+
var confirmationResult = MessageDialogResult.Affirmative;
514+
if (!_configService.GetEffectiveConfiguration().SkipModalDialogConfirmation.GetValueOrDefault(false))
515+
{
516+
confirmationResult = await _dialogService.ShowConfirmationMessageAsync(
510517
L(nameof(Resources.Dialog_AreYouSureTitle)),
511518
L(nameof(Resources.Dialog_AreYouSureUninstallMessage), Id));
519+
}
512520

513521
if (confirmationResult == MessageDialogResult.Affirmative)
514522
{

Source/ChocolateyGui.Common.Windows/ViewModels/LocalSourceViewModel.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,13 @@ public async void UpdateAll()
205205
{
206206
try
207207
{
208-
var result = await _dialogService.ShowConfirmationMessageAsync(
209-
L(nameof(Resources.Dialog_AreYouSureTitle)),
210-
L(nameof(Resources.Dialog_AreYouSureUpdateAllMessage)));
208+
var result = MessageDialogResult.Affirmative;
209+
if (!_configService.GetEffectiveConfiguration().SkipModalDialogConfirmation.GetValueOrDefault(false))
210+
{
211+
result = await _dialogService.ShowConfirmationMessageAsync(
212+
L(nameof(Resources.Dialog_AreYouSureTitle)),
213+
L(nameof(Resources.Dialog_AreYouSureUpdateAllMessage)));
214+
}
211215

212216
if (result == MessageDialogResult.Affirmative)
213217
{

Source/ChocolateyGui.Common.Windows/ViewModels/SettingsViewModel.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,13 @@ public async Task UpdateChocolateySetting(ChocolateySetting setting)
365365

366366
public async Task PurgeIconCache()
367367
{
368-
var result = await _dialogService.ShowConfirmationMessageAsync(
369-
L(nameof(Resources.Dialog_AreYouSureTitle)),
370-
L(nameof(Resources.Dialog_AreYouSureIconsMessage)));
368+
var result = MessageDialogResult.Affirmative;
369+
if (!_config.SkipModalDialogConfirmation.GetValueOrDefault(false))
370+
{
371+
result = await _dialogService.ShowConfirmationMessageAsync(
372+
L(nameof(Resources.Dialog_AreYouSureTitle)),
373+
L(nameof(Resources.Dialog_AreYouSureIconsMessage)));
374+
}
371375

372376
if (result == MessageDialogResult.Affirmative)
373377
{
@@ -377,9 +381,13 @@ public async Task PurgeIconCache()
377381

378382
public async Task PurgeOutdatedPackagesCache()
379383
{
380-
var result = await _dialogService.ShowConfirmationMessageAsync(
381-
L(nameof(Resources.Dialog_AreYouSureTitle)),
382-
L(nameof(Resources.Dialog_AreYouSureOutdatedPackagesMessage)));
384+
var result = MessageDialogResult.Affirmative;
385+
if (!_config.SkipModalDialogConfirmation.GetValueOrDefault(false))
386+
{
387+
result = await _dialogService.ShowConfirmationMessageAsync(
388+
L(nameof(Resources.Dialog_AreYouSureTitle)),
389+
L(nameof(Resources.Dialog_AreYouSureOutdatedPackagesMessage)));
390+
}
383391

384392
if (result == MessageDialogResult.Affirmative)
385393
{
@@ -462,9 +470,13 @@ await _dialogService.ShowMessageAsync(
462470

463471
public async Task Remove()
464472
{
465-
var result = await _dialogService.ShowConfirmationMessageAsync(
466-
L(nameof(Resources.Dialog_AreYouSureTitle)),
467-
L(nameof(Resources.Dialog_AreYourSureRemoveSourceMessage), _originalId));
473+
var result = MessageDialogResult.Affirmative;
474+
if (!_config.SkipModalDialogConfirmation.GetValueOrDefault(false))
475+
{
476+
result = await _dialogService.ShowConfirmationMessageAsync(
477+
L(nameof(Resources.Dialog_AreYouSureTitle)),
478+
L(nameof(Resources.Dialog_AreYourSureRemoveSourceMessage), _originalId));
479+
}
468480

469481
if (result == MessageDialogResult.Affirmative)
470482
{

Source/ChocolateyGui.Common/Models/AppConfiguration.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ public class AppConfiguration
9696
[Feature]
9797
public bool? PreventUsageOfUpdateAllButton { get; set; }
9898

99+
[LocalizedDescription(nameof(Resources.SettingsView_ToggleSkipModalDialogConfirmationDescription))]
100+
[Feature]
101+
public bool? SkipModalDialogConfirmation { get; set; }
102+
99103
public override string ToString()
100104
{
101105
return @"
@@ -119,6 +123,7 @@ public override string ToString()
119123
DefaultToDarkMode: {17}
120124
HideThisPCSource: {18}
121125
PreventUsageOfUpdateAllButton: {19}
126+
SkipModalDialogConfirmation: {20}
122127
".format_with(
123128
OutdatedPackagesCacheDurationInMinutes,
124129
DefaultSourceName,
@@ -139,7 +144,8 @@ public override string ToString()
139144
HideAllRemoteChocolateySources,
140145
DefaultToDarkMode,
141146
HideThisPCSource,
142-
PreventUsageOfUpdateAllButton);
147+
PreventUsageOfUpdateAllButton,
148+
SkipModalDialogConfirmation);
143149
}
144150
}
145151
}

Source/ChocolateyGui.Common/Properties/Resources.Designer.cs

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/ChocolateyGui.Common/Properties/Resources.resx

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
4-
Microsoft ResX Schema
5-
3+
<!--
4+
Microsoft ResX Schema
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
@@ -1241,6 +1241,9 @@ Please contact your System Administrator to enable this operation.</value>
12411241
<data name="SettingsView_TogglePreventUsageOfUpdateAllButtonDescription" xml:space="preserve">
12421242
<value>Prevents the ability for user to use the Update All button. NOTE: This feature will only work with Chocolatey for Business and the Chocolatey GUI licensed extension installed.</value>
12431243
</data>
1244+
<data name="SettingsView_ToggleSkipModalDialogConfirmationDescription" xml:space="preserve">
1245+
<value>Skip modal dialog confirmations when performing potentially destructive actions.</value>
1246+
</data>
12441247
<data name="LocalSourceViewModel_ExportComplete" xml:space="preserve">
12451248
<value>All the currently installed packages have been exported to {0}</value>
12461249
<comment>{0} = The path to where the exported packages have been placed</comment>
@@ -1302,6 +1305,9 @@ Please contact your System Administrator to enable this operation.</value>
13021305
<data name="ChocolateyGUI_PreventUsageOfUpdateAllButtonTitle" xml:space="preserve">
13031306
<value>Prevent Usage of Update All Button</value>
13041307
</data>
1308+
<data name="ChocolateyGUI_SkipModalDialogConfirmationTitle" xml:space="preserve">
1309+
<value>Skip Modal Dialog Confirmation</value>
1310+
</data>
13051311
<data name="ChocolateyGUI_ShowAdditionalPackageInformationTitle" xml:space="preserve">
13061312
<value>Show Additional Package Information</value>
13071313
</data>

recipe.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#load nuget:?package=Chocolatey.Cake.Recipe&version=0.4.2
1+
#load nuget:?package=Chocolatey.Cake.Recipe&version=0.16.0
22

33
///////////////////////////////////////////////////////////////////////////////
44
// MODULES

0 commit comments

Comments
 (0)