Skip to content

Commit

Permalink
Merge branch 'release/0.19.0'
Browse files Browse the repository at this point in the history
* release/0.19.0:
  (#882) Make use of OSS Export Command
  (#883 #884) Add package parameters for features
  (#884) Add feature toggle for Update All button
  (#884) Add feature toggle for This PC source
  (#881) Add IsUpgradeAllCommandAllowed to interface
  (#882) Use latest chocolatey.lib nuget package
  (#869) Update to use latest version of log4net
  (#882) Bump chocolatey dependency
  • Loading branch information
gep13 committed Sep 6, 2021
2 parents 3dff7ef + 8a1f75b commit 03ce669
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
<Reference Include="Caliburn.Micro.Platform, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net40\Caliburn.Micro.Platform.dll</HintPath>
</Reference>
<Reference Include="chocolatey, Version=0.10.15.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb, processorArchitecture=MSIL">
<HintPath>..\packages\chocolatey.lib.0.10.15\lib\chocolatey.dll</HintPath>
<Reference Include="chocolatey, Version=0.11.1.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb, processorArchitecture=MSIL">
<HintPath>..\packages\chocolatey.lib.0.11.1\lib\chocolatey.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
Expand All @@ -78,8 +78,8 @@
<Reference Include="LiteDB, Version=5.0.5.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.5\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro, Version=2.0.0.0, Culture=neutral, PublicKeyToken=51482d6f650b2b3f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.2.4.4\lib\net452\MahApps.Metro.dll</HintPath>
Expand Down
13 changes: 13 additions & 0 deletions Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,19 @@ public async Task<bool> RemoveSource(string id)
}
}

public async Task ExportPackages(string exportFilePath, bool includeVersionNumbers)
{
_choco.Set(
config =>
{
config.CommandName = "export";
config.ExportCommand.OutputFilePath = exportFilePath;
config.ExportCommand.IncludeVersionNumbers = includeVersionNumbers;
});

await _choco.RunAsync();
}

private static Package GetMappedPackage(GetChocolatey choco, PackageResult package, IMapper mapper, bool forceInstalled = false)
{
var mappedPackage = package == null ? null : mapper.Map<Package>(package.Package);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,14 @@ public Stream SaveFile(string defaultExtension, string filter)

return result != null && result.Value ? fd.OpenFile() : null;
}

public string GetFilePath(string defaultExtension, string filter)
{
var fd = new SaveFileDialog { DefaultExt = defaultExtension, Filter = filter };

var result = fd.ShowDialog();

return result != null && result.Value ? fd.FileName : null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,14 @@ public bool IsUpgradeAllowed
get { return _allowedCommandsService.IsUpgradeCommandAllowed; }
}

public bool IsUpgradeAllAllowed
{
get { return _allowedCommandsService.IsUpgradeAllCommandAllowed; }
}

public bool CanUpdateAll()
{
return Packages.Any(p => p.CanUpdate) && _allowedCommandsService.IsUpgradeCommandAllowed;
return Packages.Any(p => p.CanUpdate) && _allowedCommandsService.IsUpgradeCommandAllowed && _allowedCommandsService.IsUpgradeAllCommandAllowed;
}

public async void UpdateAll()
Expand Down Expand Up @@ -214,37 +219,25 @@ public async void UpdateAll()
}
}

public void ExportAll()
public async void ExportAll()
{
_exportAll = false;

try
{
using (var fileStream = _persistenceService.SaveFile("*.config", Resources.LocalSourceViewModel_ConfigFiles.format_with("(.config)|*.config")))
{
if (fileStream == null)
{
return;
}
var exportFilePath = _persistenceService.GetFilePath("*.config", Resources.LocalSourceViewModel_ConfigFiles.format_with("(.config)|*.config"));

var settings = new XmlWriterSettings { Indent = true };

using (var xw = XmlWriter.Create(fileStream, settings))
{
xw.WriteStartDocument();
xw.WriteStartElement("packages");
if (string.IsNullOrEmpty(exportFilePath))
{
return;
}

foreach (var package in Packages)
{
xw.WriteStartElement("package");
xw.WriteAttributeString("id", package.Id);
xw.WriteAttributeString("version", package.Version.ToString());
xw.WriteEndElement();
}
await _chocolateyService.ExportPackages(exportFilePath, true);

xw.WriteEndElement();
}
}
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
_progressService.ShowMessageAsync(Resources.LocalSourceView_ButtonExport, string.Format(Resources.LocalSourceViewModel_ExportComplete, exportFilePath))
.ConfigureAwait(false);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
VerticalAlignment="Center"
Style="{DynamicResource IconFlatButtonStyle}"
ToolTip=""
Visibility="{Binding IsUpgradeAllAllowed, Converter={StaticResource BooleanToVisibility}}"
Margin="2,0,2,0">
<i:Interaction.Behaviors>
<utilities:ToolTipBehavior EnabledToolTip="{x:Static properties:Resources.LocalSourceView_ButtonUpdateAll}"
Expand Down
4 changes: 2 additions & 2 deletions Source/ChocolateyGui.Common.Windows/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<package id="BuildTools.FxCop" version="1.0.1" targetFramework="net40" />
<package id="Caliburn.Micro" version="3.2.0" targetFramework="net40" requireReinstallation="true" />
<package id="Caliburn.Micro.Core" version="3.2.0" targetFramework="net40" requireReinstallation="true" />
<package id="chocolatey.lib" version="0.10.15" targetFramework="net452" />
<package id="chocolatey.lib" version="0.11.1" targetFramework="net452" />
<package id="ControlzEx" version="4.4.0" targetFramework="net452" />
<package id="Fizzler" version="1.2.0" targetFramework="net452" />
<package id="HarfBuzzSharp" version="2.6.1.4" targetFramework="net452" />
<package id="LiteDB" version="5.0.5" targetFramework="net452" />
<package id="log4net" version="2.0.3" targetFramework="net452" />
<package id="log4net" version="2.0.12" targetFramework="net452" />
<package id="MahApps.Metro" version="2.4.4" targetFramework="net452" />
<package id="MahApps.Metro.IconPacks.BoxIcons" version="4.8.0" targetFramework="net452" />
<package id="MahApps.Metro.IconPacks.Entypo" version="4.8.0" targetFramework="net452" />
Expand Down
12 changes: 8 additions & 4 deletions Source/ChocolateyGui.Common/ChocolateyGui.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@
<Reference Include="AutoMapper, Version=7.0.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.7.0.1\lib\net45\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="chocolatey, Version=0.10.15.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb, processorArchitecture=MSIL">
<HintPath>..\packages\chocolatey.lib.0.10.15\lib\chocolatey.dll</HintPath>
<Reference Include="chocolatey, Version=0.11.1.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb, processorArchitecture=MSIL">
<HintPath>..\packages\chocolatey.lib.0.11.1\lib\chocolatey.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="LiteDB, Version=5.0.5.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.5\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Threading, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Threading.15.4.4\lib\net45\Microsoft.VisualStudio.Threading.dll</HintPath>
Expand Down Expand Up @@ -91,13 +91,15 @@
<HintPath>..\packages\Serilog.Sinks.RollingFile.3.3.0\lib\net45\Serilog.Sinks.RollingFile.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -222,6 +224,8 @@
</ItemGroup>
<ItemGroup>
<SourceRoot Include="$(MSBuildThisFileDirectory)/../" />
</ItemGroup>
<ItemGroup>
<Folder Include="Startup\Adapters\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
14 changes: 13 additions & 1 deletion Source/ChocolateyGui.Common/Models/AppConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public class AppConfiguration
[Feature]
public bool? DefaultToDarkMode { get; set; }

[LocalizedDescription("SettingsView_ToggleHideThisPCSourceDescription")]
[Feature]
public bool? HideThisPCSource { get; set; }

[LocalizedDescription("SettingsView_TogglePreventUsageOfUpdateAllButtonDescription")]
[Feature]
public bool? PreventUsageOfUpdateAllButton { get; set; }

public override string ToString()
{
return @"
Expand All @@ -102,6 +110,8 @@ public override string ToString()
PreventAllPackageIconDownloads: {14}
HideAllRemoteChocolateySources: {15}
DefaultToDarkMode: {16}
HideThisPCSource: {17}
PreventUsageOfUpdateAllButton: {18}
".format_with(
OutdatedPackagesCacheDurationInMinutes,
DefaultSourceName,
Expand All @@ -119,7 +129,9 @@ public override string ToString()
HidePackageDownloadCount,
PreventAllPackageIconDownloads,
HideAllRemoteChocolateySources,
DefaultToDarkMode);
DefaultToDarkMode,
HideThisPCSource,
PreventUsageOfUpdateAllButton);
}
}
}
27 changes: 27 additions & 0 deletions Source/ChocolateyGui.Common/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Source/ChocolateyGui.Common/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1040,4 +1040,14 @@ Please contact your System Administrator to enable this operation.</value>
<data name="LocalSourceView_ButtonUpdateAllDisabled" xml:space="preserve">
<value>No packages need to be updated</value>
</data>
<data name="SettingsView_ToggleHideThisPCSourceDescription" xml:space="preserve">
<value>Controls whether or not the This PC source is displayed in Chocolatey GUI. Enabling this feature means that Chocolatey GUI will no longer show a list of all the currently installed packages on the machine. NOTE: This feature will only work with Chocolatey for Business and the Chocolatey GUI licensed extension installed.</value>
</data>
<data name="SettingsView_TogglePreventUsageOfUpdateAllButtonDescription" xml:space="preserve">
<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>
</data>
<data name="LocalSourceViewModel_ExportComplete" xml:space="preserve">
<value>All the currrently installed packages have been exported to {0}</value>
<comment>{0} = The path to where the exported packages have been placed</comment>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@ public bool IsUpgradeCommandAllowed
{
get { return true; }
}

public bool IsUpgradeAllCommandAllowed
{
get { return true; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ public interface IAllowedCommandsService
bool IsUninstallCommandAllowed { get; }

bool IsUpgradeCommandAllowed { get; }

bool IsUpgradeAllCommandAllowed { get; }
}
}
2 changes: 2 additions & 0 deletions Source/ChocolateyGui.Common/Services/IChocolateyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ Task<PackageOperationResult> InstallPackage(
Task DisableSource(string id);

Task<bool> RemoveSource(string id);

Task ExportPackages(string exportFilePath, bool includeVersionNumbers);
}
}
2 changes: 2 additions & 0 deletions Source/ChocolateyGui.Common/Services/IPersistenceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ public interface IPersistenceService
Stream OpenFile(string defaultExtension, string filter);

Stream SaveFile(string defaultExtension, string filter);

string GetFilePath(string defaultExtension, string filter);
}
}
4 changes: 2 additions & 2 deletions Source/ChocolateyGui.Common/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<package id="Autofac" version="4.6.1" targetFramework="net452" />
<package id="AutoMapper" version="7.0.1" targetFramework="net452" />
<package id="BuildTools.FxCop" version="1.0.1" targetFramework="net452" />
<package id="chocolatey.lib" version="0.10.15" targetFramework="net452" />
<package id="chocolatey.lib" version="0.11.1" targetFramework="net452" />
<package id="LiteDB" version="5.0.5" targetFramework="net452" />
<package id="log4net" version="2.0.3" targetFramework="net452" />
<package id="log4net" version="2.0.12" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Threading" version="15.4.4" targetFramework="net452" />
<package id="Microsoft.VisualStudio.Validation" version="15.3.32" targetFramework="net452" />
<package id="Serilog" version="2.5.0" targetFramework="net452" />
Expand Down
8 changes: 4 additions & 4 deletions Source/ChocolateyGui/ChocolateyGui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
<Reference Include="Caliburn.Micro.Platform.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
</Reference>
<Reference Include="chocolatey, Version=0.10.15.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb, processorArchitecture=MSIL">
<HintPath>..\packages\chocolatey.lib.0.10.15\lib\chocolatey.dll</HintPath>
<Reference Include="chocolatey, Version=0.11.1.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb, processorArchitecture=MSIL">
<HintPath>..\packages\chocolatey.lib.0.11.1\lib\chocolatey.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
Expand All @@ -135,8 +135,8 @@
<Reference Include="LiteDB, Version=5.0.5.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.5\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro, Version=2.0.0.0, Culture=neutral, PublicKeyToken=51482d6f650b2b3f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.2.4.4\lib\net452\MahApps.Metro.dll</HintPath>
Expand Down
Loading

0 comments on commit 03ce669

Please sign in to comment.