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

Additional Presets #1538

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.code.config;

import java.util.List;
import java.util.Optional;

import io.smallrye.config.ConfigMapping;
Expand All @@ -20,4 +21,6 @@ public interface CodeQuarkusConfig {
Optional<String> hostname();

UIConfig ui();

List<PresetConfig> presets();
}
14 changes: 14 additions & 0 deletions base/src/main/java/io/quarkus/code/config/PresetConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.quarkus.code.config;

import java.util.List;

public interface PresetConfig {

String key();

String title();

String icon();

List<String> extensions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,22 @@ public Uni<Response> presetsForStream(

private Uni<Response> presets(Map<String, ExtensionRef> extensionsById) {
String lastUpdated = platformService.cacheLastUpdated().format(FORMATTER);
final List<Preset> presets = PRESETS.stream().filter(p -> p.extensions().stream().allMatch(extensionsById::containsKey))
final List<Preset> presets = getAllPresets().stream()
.filter(p -> p.extensions().stream().allMatch(extensionsById::containsKey))
.toList();
Response response = Response.ok(presets)
.header(LAST_MODIFIED_HEADER, lastUpdated)
.build();
return Uni.createFrom().item(response);
}

List<Preset> getAllPresets() {
List<Preset> presets = new ArrayList<>(PRESETS);
config.presets().stream().map(presetConfig -> new Preset(presetConfig.key(), presetConfig.title(), presetConfig.icon(),
presetConfig.extensions())).forEach(presets::add);
return presets;
}

private Uni<Response> extensions(
boolean platformOnly,
List<CodeQuarkusExtension> extensions,
Expand Down
Loading