Skip to content

Commit

Permalink
[incubator-kie-kogito-runtimes#3454] GraphQL UI link visible in the l… (
Browse files Browse the repository at this point in the history
apache#3464)

* [incubator-kie-kogito-runtimes#3454] GraphQL UI link visible in the last Quarkus Dev UI

* review suggestions applied and testing fix
  • Loading branch information
nmirasch authored and rgdoliveira committed Apr 16, 2024
1 parent 79a0ade commit 0275906
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@
*/
package org.kie.kogito.quarkus.processes.deployment;

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

import org.kie.kogito.quarkus.processes.devservices.DevModeWorkflowLogger;
import org.kie.kogito.quarkus.workflow.deployment.AbstractDevServicesProcessor;
import org.kie.kogito.quarkus.workflow.deployment.config.KogitoWorkflowBuildTimeConfig;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.SystemPropertyBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.Page;

/**
* Starts a Data Index as dev service if needed.
Expand All @@ -40,4 +48,17 @@ public void logger(BuildProducer<AdditionalBeanBuildItem> additionalBean, Launch
}
}

@BuildStep(onlyIf = { GlobalDevServicesConfig.Enabled.class, IsDevelopment.class })
CardPageBuildItem createDevUILink(List<SystemPropertyBuildItem> systemPropertyBuildItems) {
Optional<String> dataindex_url_prop = getProperty(systemPropertyBuildItems, "kogito.data-index.url");
if (dataindex_url_prop.isPresent()) {
CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI")
.url(dataindex_url_prop.get() + "/q/graphql-ui/")
.isHtmlContent()
.icon("font-awesome-solid:signs-post"));
return cardPageBuildItem;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@
*/
package org.kie.kogito.quarkus.serverless.workflow.deployment;

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

import org.kie.kogito.quarkus.workflow.deployment.AbstractDevServicesProcessor;
import org.kie.kogito.quarkus.workflow.deployment.config.KogitoWorkflowBuildTimeConfig;
import org.kie.kogito.serverless.workflow.devservices.DevModeServerlessWorkflowLogger;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.SystemPropertyBuildItem;
import io.quarkus.deployment.dev.devservices.GlobalDevServicesConfig;
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.Page;

public class ServerlessWorkflowDevServicesProcessor extends AbstractDevServicesProcessor {
@BuildStep
Expand All @@ -36,4 +44,17 @@ public void logger(BuildProducer<AdditionalBeanBuildItem> additionalBean, Launch
}
}

@BuildStep(onlyIf = { GlobalDevServicesConfig.Enabled.class, IsDevelopment.class })
CardPageBuildItem createDevUILink(List<SystemPropertyBuildItem> systemPropertyBuildItems) {
Optional<String> dataindex_url_prop = getProperty(systemPropertyBuildItems, "kogito.data-index.url");
if (dataindex_url_prop.isPresent()) {
CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
cardPageBuildItem.addPage(Page.externalPageBuilder("Data Index GraphQL UI")
.url(dataindex_url_prop.get() + "/q/graphql-ui/")
.isHtmlContent()
.icon("font-awesome-solid:signs-post"));
return cardPageBuildItem;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ protected static boolean shouldInclude(LaunchModeBuildItem launchMode, KogitoWor
return launchMode.getLaunchMode().isDevOrTest() || config.alwaysInclude;
}

protected Optional<String> getProperty(List<SystemPropertyBuildItem> systemPropertyBuildItems, String propertyKey) {
return systemPropertyBuildItems.stream().filter(property -> property.getKey().equals(propertyKey))
.findAny()
.map(SystemPropertyBuildItem::getValue);
}

@BuildStep(onlyIf = { GlobalDevServicesConfig.Enabled.class, IsDevelopment.class })
public void startDataIndexDevService(
BuildProducer<AdditionalBeanBuildItem> additionalBean,
Expand Down

0 comments on commit 0275906

Please sign in to comment.