Skip to content

Commit dfa1ddb

Browse files
authored
Fix presets (#1461)
* Fix stream presets * Preset Fixes
1 parent 5a655e3 commit dfa1ddb

File tree

11 files changed

+49
-18
lines changed

11 files changed

+49
-18
lines changed

acceptance-test/src/main/java/io/quarkus/code/testing/AcceptanceTestApp.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class AcceptanceTestApp implements QuarkusApplication {
3333
private static final Logger LOG = LoggerFactory.getLogger(AcceptanceTestApp.class);
3434

3535
private static final String GENERATE_YOUR_APPLICATION_TEXT = "generate your application";
36+
public static final String LABEL_TOGGLE_FULL_LIST = "[aria-label='Toggle full list of extensions']";
3637
public static final String LABEL_DOWNLOAD_THE_ZIP = "[aria-label='Download the zip']";
3738
private static final int DEFAULT_MIN_EXTENSIONS = 50;
3839
private static final int DEFAULT_MIN_STREAMS = 1;
@@ -80,7 +81,7 @@ public int run(String... args) throws Exception {
8081
} else {
8182
LOG.info("{} streams found", streams.size());
8283
}
83-
84+
page.waitForSelector(LABEL_TOGGLE_FULL_LIST).click();
8485
page.waitForSelector(".extensions-picker .extension-row");
8586
final List<ElementHandle> extensions = page.querySelectorAll(".extensions-picker .extension-row");
8687
final Integer minExtensions = testConfig.getMinExtensions().orElse(DEFAULT_MIN_EXTENSIONS);

base/src/main/java/io/quarkus/code/rest/CodeQuarkusResource.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.time.format.DateTimeFormatter;
3030
import java.util.ArrayList;
3131
import java.util.List;
32+
import java.util.Map;
3233
import java.util.logging.Logger;
3334
import java.util.stream.Collectors;
3435

@@ -154,23 +155,31 @@ public Uni<Response> extensionsForStream(
154155
@Tag(name = "Presets", description = "Preset related endpoints")
155156
@APIResponse(responseCode = "200", description = "List of Presets", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Preset.class, type = SchemaType.ARRAY)))
156157
public Uni<Response> presets() {
157-
String lastUpdated = platformService.cacheLastUpdated().format(FORMATTER);
158-
Response response = Response.ok(PRESETS)
159-
.header(LAST_MODIFIED_HEADER, lastUpdated)
160-
.build();
161-
return Uni.createFrom().item(response);
158+
return presets(platformService.recommendedPlatformInfo().extensionsById());
162159
}
163160

164161
@GET
165-
@Path("/extensions/presets/{streamKey}")
162+
@Path("/presets/stream/{streamKey}")
166163
@Produces(MediaType.APPLICATION_JSON)
167164
@NoCache
168165
@Operation(operationId = "presetsForStream", summary = "Get the Quarkus Launcher list of Presets")
169166
@Tag(name = "Presets", description = "Preset related endpoints")
170167
@APIResponse(responseCode = "200", description = "List of Presets for a certain stream", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Preset.class, type = SchemaType.ARRAY)))
171168
public Uni<Response> presetsForStream(
172169
@PathParam("streamKey") String streamKey) {
173-
return presets();
170+
171+
final Map<String, ExtensionRef> extensionsById = platformService.platformInfo(streamKey).extensionsById();
172+
return presets(extensionsById);
173+
}
174+
175+
private Uni<Response> presets(Map<String, ExtensionRef> extensionsById) {
176+
String lastUpdated = platformService.cacheLastUpdated().format(FORMATTER);
177+
final List<Preset> presets = PRESETS.stream().filter(p -> p.extensions().stream().allMatch(extensionsById::containsKey))
178+
.toList();
179+
Response response = Response.ok(presets)
180+
.header(LAST_MODIFIED_HEADER, lastUpdated)
181+
.build();
182+
return Uni.createFrom().item(response);
174183
}
175184

176185
private Uni<Response> extensions(

base/src/main/java/io/quarkus/code/service/PlatformService.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,34 @@
4949
public class PlatformService {
5050

5151
public static final List<Preset> PRESETS = List.of(
52-
new Preset("db-service", "Microservice with database", "/static/media/presets/db-service.svg",
52+
new Preset("db-service-reactive", "Microservice with database",
53+
"https://raw.githubusercontent.com/quarkusio/code.quarkus.io/main/base/assets/icons/presets/db-service.svg",
54+
List.of("io.quarkus:quarkus-resteasy-reactive", "io.quarkus:quarkus-resteasy-reactive-jackson",
55+
"io.quarkus:quarkus-hibernate-reactive-panache", "io.quarkus:quarkus-jdbc-postgresql")),
56+
new Preset("webapp-npm-reactive", "Web app with NPM UI",
57+
"https://raw.githubusercontent.com/quarkusio/code.quarkus.io/main/base/assets/icons/presets/webapp-npm.svg",
58+
List.of("io.quarkus:quarkus-resteasy-reactive", "io.quarkus:quarkus-resteasy-reactive-jackson",
59+
"io.quarkiverse.quinoa:quarkus-quinoa")),
60+
new Preset("event-driven-reactive-kafka", "Event driven service with Kafka",
61+
"https://raw.githubusercontent.com/quarkusio/code.quarkus.io/main/base/assets/icons/presets/event-driven-kafka.svg",
62+
List.of("io.quarkus:quarkus-smallrye-reactive-messaging-kafka")),
63+
new Preset("db-service", "Microservice with database",
64+
"https://raw.githubusercontent.com/quarkusio/code.quarkus.io/main/base/assets/icons/presets/db-service.svg",
5365
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
5466
"io.quarkus:quarkus-hibernate-orm-panache", "io.quarkus:quarkus-jdbc-postgresql")),
55-
new Preset("event-driven-kafka", "Event driven service with Kafka", "/static/media/presets/event-driven-kafka.svg",
67+
new Preset("event-driven-kafka", "Event driven service with Kafka",
68+
"https://raw.githubusercontent.com/quarkusio/code.quarkus.io/main/base/assets/icons/presets/event-driven-kafka.svg",
5669
List.of("io.quarkus:quarkus-messaging-kafka")),
57-
new Preset("cli", "Command-line tool", "/static/media/presets/cli.svg",
70+
new Preset("cli", "Command-line tool",
71+
"https://raw.githubusercontent.com/quarkusio/code.quarkus.io/main/base/assets/icons/presets/cli.svg",
5872
List.of("io.quarkus:quarkus-picocli")),
59-
new Preset("webapp-mvc", "Web app with Model-View-Controller", "/static/media/presets/webapp-mvc.svg",
73+
new Preset("webapp-mvc", "Web app with Model-View-Controller",
74+
"https://raw.githubusercontent.com/quarkusio/code.quarkus.io/main/base/assets/icons/presets/webapp-mvc.svg",
6075
List.of("io.quarkiverse.renarde:quarkus-renarde", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
61-
new Preset("webapp-npm", "Web app with NPM UI", "/static/media/presets/webapp-npm.svg",
62-
List.of("io.quarkus:quarkus-rest", "io.quarkiverse.quinoa:quarkus-quinoa")),
76+
new Preset("webapp-npm", "Web app with NPM UI",
77+
"https://raw.githubusercontent.com/quarkusio/code.quarkus.io/main/base/assets/icons/presets/webapp-npm.svg",
78+
List.of("io.quarkus:quarkus-rest", "io.quarkus:quarkus-rest-jackson",
79+
"io.quarkiverse.quinoa:quarkus-quinoa")),
6380
new Preset("webapp-qute", "Web app with ServerSide Rendering", "static/media/presets/webapp-qute.svg",
6481
List.of("io.quarkiverse.qute.web:quarkus-qute-web", "io.quarkiverse.web-bundler:quarkus-web-bundler")),
6582
new Preset("ai-infused", "AI Infused service", "static/media/presets/ai-infused.svg",

0 commit comments

Comments
 (0)