mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
Add uninstalled plugins to pending resource
This commit is contained in:
@@ -61,16 +61,24 @@ public class PendingPluginResource {
|
||||
Stream<InstalledPlugin> updatePlugins = installed
|
||||
.stream()
|
||||
.filter(i -> contains(pending, i));
|
||||
Stream<InstalledPlugin> uninstallPlugins = installed
|
||||
.stream()
|
||||
.filter(InstalledPlugin::isMarkedForUninstall);
|
||||
|
||||
Links.Builder linksBuilder = linkingTo().self(resourceLinks.pendingPluginCollection().self());
|
||||
|
||||
if (!pending.isEmpty()) {
|
||||
List<PluginDto> installDtos = newPlugins.map(mapper::mapAvailable).collect(toList());
|
||||
List<PluginDto> updateDtos = updatePlugins.map(i -> mapper.mapInstalled(i, pending)).collect(toList());
|
||||
List<PluginDto> uninstallDtos = uninstallPlugins.map(i -> mapper.mapInstalled(i, pending)).collect(toList());
|
||||
|
||||
if (!installDtos.isEmpty() || !updateDtos.isEmpty() || !uninstallDtos.isEmpty()) {
|
||||
linksBuilder.single(link("install", resourceLinks.pendingPluginCollection().installPending()));
|
||||
}
|
||||
|
||||
Embedded.Builder embedded = Embedded.embeddedBuilder();
|
||||
embedded.with("new", newPlugins.map(mapper::mapAvailable).collect(toList()));
|
||||
embedded.with("update", updatePlugins.map(i -> mapper.mapInstalled(i, pending)).collect(toList()));
|
||||
embedded.with("new", installDtos);
|
||||
embedded.with("update", updateDtos);
|
||||
embedded.with("uninstall", uninstallDtos);
|
||||
|
||||
return Response.ok(new HalRepresentation(linksBuilder.build(), embedded.build())).build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user