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

(GH-588) Add option to search packages in all available repositories #591

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/ChocolateyGui/Models/AppConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public class AppConfiguration
public bool DefaultToTileViewForRemoteSource { get; set; }

public bool UseDelayedSearch { get; set; }

public bool SearchInAllRepositories { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Is this the right terms here? Chocolatey GUI doesn't refer to repositories, but rather Sources. Should this be SearchInAllRepositories?

Copy link
Member

Choose a reason for hiding this comment

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

I'm with @gep13 , so SearchInAllSources could be the name...

}
}
6 changes: 5 additions & 1 deletion Source/ChocolateyGui/Models/PackageSearchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public struct PackageSearchOptions
bool includePrerelease,
bool includeAllVersions,
bool matchWord,
string source)
string source,
bool searchInALlRepos)
Copy link
Member

Choose a reason for hiding this comment

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

In addition to the other comment, this should be 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
Original file line number Diff line number Diff line change
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>
Copy link
Member

Choose a reason for hiding this comment

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

Depending on the outcome of the above, we will likely want to change this text as well.

</data>
</root>
5 changes: 4 additions & 1 deletion Source/ChocolateyGui/Services/ChocolateyService.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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