Skip to content

Commit

Permalink
(GH-588) Add option to search packages in all available repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
mwallner committed Jan 26, 2019
1 parent 6cabc8c commit b200c1a
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Source/ChocolateyGui/Models/AppConfiguration.cs
Expand Up @@ -17,5 +17,7 @@ public class AppConfiguration
public bool DefaultToTileViewForRemoteSource { get; set; }

public bool UseDelayedSearch { get; set; }

public bool SearchInAllRepositories { get; set; }
}
}
6 changes: 5 additions & 1 deletion Source/ChocolateyGui/Models/PackageSearchOptions.cs
Expand Up @@ -15,7 +15,8 @@ public struct PackageSearchOptions
bool includePrerelease,
bool includeAllVersions,
bool matchWord,
string source)
string source,
bool searchInALlRepos)
: this()
{
PageSize = pageSize;
Expand All @@ -25,6 +26,7 @@ public struct PackageSearchOptions
IncludePrerelease = includePrerelease;
MatchQuery = matchWord;
Source = source;
SearchInAllRepos = searchInALlRepos;
}

public int CurrentPage { get; set; }
Expand All @@ -33,6 +35,8 @@ public struct PackageSearchOptions

public bool IncludePrerelease { get; set; }

public bool SearchInAllRepos { get; set; }

public bool MatchQuery { get; set; }

public string Source { get; set; }
Expand Down
9 changes: 9 additions & 0 deletions Source/ChocolateyGui/Properties/Resources.Designer.cs

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

3 changes: 3 additions & 0 deletions Source/ChocolateyGui/Properties/Resources.resx
Expand Up @@ -642,4 +642,7 @@ NOTE: Probably only necessary to change in RTL languages.</comment>
<data name="PackageView_Version" xml:space="preserve">
<value>Version</value>
</data>
<data name="SettingsView_SearchInAllRepos" xml:space="preserve">
<value>Search in all Repos</value>
</data>
</root>
5 changes: 4 additions & 1 deletion Source/ChocolateyGui/Services/ChocolateyService.cs
Expand Up @@ -164,7 +164,10 @@ public async Task<PackageResults> Search(string query, PackageSearchOptions opti
config.ListCommand.Exact = options.MatchQuery;
if (!string.IsNullOrWhiteSpace(options.Source))
{
config.Sources = options.Source;
if (string.IsNullOrEmpty(query) || !options.SearchInAllRepos)
{
config.Sources = options.Source;
}
}
#if !DEBUG
config.Verbose = false;
Expand Down
3 changes: 2 additions & 1 deletion Source/ChocolateyGui/ViewModels/RemoteSourceViewModel.cs
Expand Up @@ -232,7 +232,8 @@ public async Task LoadPackages()
IncludePrerelease,
IncludeAllVersions,
MatchWord,
Source.Value));
Source.Value,
_configService.GetSettings().SearchInAllRepositories));
var installed = await _chocolateyPackageService.GetInstalledPackages();
var outdated = await _chocolateyPackageService.GetOutdatedPackages();

Expand Down
17 changes: 16 additions & 1 deletion Source/ChocolateyGui/ViewModels/SettingsViewModel.cs
Expand Up @@ -32,7 +32,8 @@ public sealed class SettingsViewModel : Screen
nameof(ShowConsoleOutput),
nameof(DefaultToTileViewForLocalSource),
nameof(DefaultToTileViewForRemoteSource),
nameof(UseDelayedSearch)
nameof(UseDelayedSearch),
nameof(SearchInAllRepositories)
};

private readonly IChocolateyService _packageService;
Expand Down Expand Up @@ -126,6 +127,20 @@ public bool UseDelayedSearch
}
}

public bool SearchInAllRepositories
{
get
{
return _config.SearchInAllRepositories;
}

set
{
_config.SearchInAllRepositories = value;
NotifyOfPropertyChange();
}
}

public bool CanSave => SelectedSource != null;

public bool CanRemove => SelectedSource != null && !_isNewItem;
Expand Down
1 change: 1 addition & 0 deletions Source/ChocolateyGui/Views/SettingsView.xaml
Expand Up @@ -49,6 +49,7 @@
<metro:ToggleSwitch Header="{x:Static lang:Resources.SettingsView_ToggleDefaultTileViewLocal}" IsChecked="{Binding DefaultToTileViewForLocalSource}"/>
<metro:ToggleSwitch Header="{x:Static lang:Resources.SettingsView_ToggleDefaultTileViewRemote}" IsChecked="{Binding DefaultToTileViewForRemoteSource}"/>
<metro:ToggleSwitch Header="{x:Static lang:Resources.SettingsView_UseDelayedSearch}" IsChecked="{Binding UseDelayedSearch}" />
<metro:ToggleSwitch Header="{x:Static lang:Resources.SettingsView_SearchInAllRepos}" IsChecked="{Binding SearchInAllRepositories}" />
</StackPanel>
</Grid>
<Grid Grid.Column="1" Background="White" Margin="5">
Expand Down

1 comment on commit b200c1a

@mwallner
Copy link
Member Author

Choose a reason for hiding this comment

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

squashed 4 commits so this is "nicer" to rebase onto current develop

Please sign in to comment.