This is an automated email from the ASF dual-hosted git repository.
paulovmr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-apps.git
The following commit(s) were added to refs/heads/main by this push:
new 8c1d7192e KOGITO-10047: Enable SWF Dev UI extension for Quarkus 3
(#1982)
8c1d7192e is described below
commit 8c1d7192e7890d4cd36479fb28838952f6be3492
Author: Paulo Martins <[email protected]>
AuthorDate: Thu Feb 15 14:38:04 2024 -0300
KOGITO-10047: Enable SWF Dev UI extension for Quarkus 3 (#1982)
* KOGITO-10047: Enable SWF Dev UI extension for Quarkus 3
* KOGITO-10047: Enable SWF Dev UI extension for Quarkus 3
---
.../pom.xml | 24 +++++++-
.../swf/tools/deployment/DevConsoleProcessor.java | 70 ++++++++++++++++++++--
.../src/main/resources/static/index.html | 48 +++++++++++++++
.../dashboard/impl/CustomDashboardStorageImpl.java | 4 ++
.../runtime-tools-dev-ui-webapp/package.json | 2 +-
.../src/channel/apis/apis.tsx | 66 ++++++++++++--------
.../src/channel/apis/tests/apis.test.tsx | 3 +
ui-packages/pnpm-lock.yaml | 14 ++---
8 files changed, 187 insertions(+), 44 deletions(-)
diff --git
a/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/pom.xml
b/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/pom.xml
index de3cd1776..39d488086 100644
---
a/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/pom.xml
+++
b/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/pom.xml
@@ -130,7 +130,7 @@
<goal>copy-resources</goal>
</goals>
<configuration>
-
<outputDirectory>${basedir}/target/classes/dev-static/webapp</outputDirectory>
+
<outputDirectory>${basedir}/target/classes/dev-static/resources/webapp</outputDirectory>
<resources>
<resource>
<directory>${path.to.webapp.app}/dist/resources/webapp</directory>
@@ -143,6 +143,7 @@
</resources>
</configuration>
</execution>
+
<execution>
<id>copy-envelope-resources</id>
<phase>process-resources</phase>
@@ -150,7 +151,7 @@
<goal>copy-resources</goal>
</goals>
<configuration>
-
<outputDirectory>${basedir}/target/classes/dev-static/</outputDirectory>
+
<outputDirectory>${basedir}/target/classes/dev-static/resources</outputDirectory>
<resources>
<resource>
<directory>${path.to.webapp.app}/dist/resources</directory>
@@ -175,6 +176,25 @@
</resources>
</configuration>
</execution>
+
+ <execution>
+ <id>copy-index</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+
<outputDirectory>${basedir}/target/classes/dev-static</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/target/classes/static</directory>
+ <includes>
+ <include>index.html</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
diff --git
a/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/src/main/java/org/kie/kogito/swf/tools/deployment/DevConsoleProcessor.java
b/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/src/main/java/org/kie/kogito/swf/tools/deployment/DevConsoleProcessor.java
index effce8f5a..8c21398e4 100644
---
a/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/src/main/java/org/kie/kogito/swf/tools/deployment/DevConsoleProcessor.java
+++
b/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/src/main/java/org/kie/kogito/swf/tools/deployment/DevConsoleProcessor.java
@@ -19,6 +19,8 @@
package org.kie.kogito.swf.tools.deployment;
import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.nio.file.Path;
import java.util.Optional;
@@ -30,15 +32,20 @@ import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.ConfigurationBuildItem;
import io.quarkus.deployment.builditem.LaunchModeBuildItem;
import io.quarkus.deployment.builditem.LiveReloadBuildItem;
import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.deployment.util.WebJarUtil;
import io.quarkus.devconsole.spi.DevConsoleTemplateInfoBuildItem;
+import io.quarkus.devui.spi.page.CardPageBuildItem;
+import io.quarkus.devui.spi.page.Page;
import io.quarkus.maven.dependency.ResolvedDependency;
+import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;
import io.quarkus.vertx.http.deployment.RouteBuildItem;
import io.quarkus.vertx.http.runtime.devmode.DevConsoleRecorder;
+import
io.quarkus.vertx.http.runtime.management.ManagementInterfaceBuildTimeConfig;
public class DevConsoleProcessor {
@@ -46,6 +53,36 @@ public class DevConsoleProcessor {
private static final String BASE_RELATIVE_URL =
"/q/dev-v1/org.kie.kogito.kogito-quarkus-serverless-workflow-devui";
private static final String DATA_INDEX_CAPABILITY =
"org.kie.kogito.data-index";
+ @BuildStep(onlyIf = IsDevelopment.class)
+ public CardPageBuildItem pages(NonApplicationRootPathBuildItem
nonApplicationRootPathBuildItem,
+ ManagementInterfaceBuildTimeConfig
managementInterfaceBuildTimeConfig,
+ LaunchModeBuildItem launchModeBuildItem,
+ ConfigurationBuildItem configurationBuildItem) throws
UnsupportedEncodingException {
+
+ String uiPath =
nonApplicationRootPathBuildItem.resolveManagementPath(BASE_RELATIVE_URL,
+ managementInterfaceBuildTimeConfig, launchModeBuildItem, true);
+
+ String devUIUrl = getProperty(configurationBuildItem,
"kogito.dev-ui.url");
+ String devUIUrlQueryParam = devUIUrl != null ? "&devUIUrl=" +
URLEncoder.encode(devUIUrl, "UTF-8") : "";
+
+ String dataIndexUrl = getProperty(configurationBuildItem,
"kogito.data-index.url");
+ String dataIndexUrlQueryParam = dataIndexUrl != null ?
"&dataIndexUrl=" + URLEncoder.encode(dataIndexUrl, "UTF-8") : "";
+
+ CardPageBuildItem cardPageBuildItem = new CardPageBuildItem();
+
+ cardPageBuildItem.addPage(Page.externalPageBuilder("Workflows")
+ .url(uiPath + "/index.html?page=Processes" +
devUIUrlQueryParam + dataIndexUrlQueryParam, uiPath)
+ .isHtmlContent()
+ .icon("font-awesome-solid:diagram-project"));
+
+ cardPageBuildItem.addPage(Page.externalPageBuilder("Monitoring")
+ .url(uiPath + "/index.html?page=Monitoring" +
devUIUrlQueryParam + dataIndexUrlQueryParam, uiPath)
+ .isHtmlContent()
+ .icon("font-awesome-solid:gauge-high"));
+
+ return cardPageBuildItem;
+ }
+
@BuildStep(onlyIf = IsDevelopment.class)
@Record(ExecutionTime.RUNTIME_INIT)
public void deployStaticResources(final DevConsoleRecorder recorder,
@@ -66,12 +103,6 @@ public class DevConsoleProcessor {
STATIC_RESOURCES_PATH,
true);
- routeBuildItemBuildProducer.produce(new RouteBuildItem.Builder()
- .route(BASE_RELATIVE_URL + "/resources/*")
-
.handler(recorder.devConsoleHandler(devConsoleStaticResourcesDeploymentPath.toString(),
- shutdownContext))
- .build());
-
routeBuildItemBuildProducer.produce(new RouteBuildItem.Builder()
.route(BASE_RELATIVE_URL + "/*")
.handler(recorder.devConsoleHandler(devConsoleStaticResourcesDeploymentPath.toString(),
@@ -87,4 +118,31 @@ public class DevConsoleProcessor {
devConsoleTemplateInfoBuildItemBuildProducer.produce(new
DevConsoleTemplateInfoBuildItem("isDataIndexAvailable",
dataIndexServiceAvailableBuildItem.isPresent() ||
capabilities.isPresent(DATA_INDEX_CAPABILITY)));
}
+
+ private static String getProperty(ConfigurationBuildItem
configurationBuildItem,
+ String propertyKey) {
+
+ String propertyValue = configurationBuildItem
+ .getReadResult()
+ .getAllBuildTimeValues()
+ .get(propertyKey);
+
+ if (propertyValue == null) {
+ propertyValue = configurationBuildItem
+ .getReadResult()
+ .getBuildTimeRunTimeValues()
+ .get(propertyKey);
+ } else {
+ return propertyValue;
+ }
+
+ if (propertyValue == null) {
+ propertyValue = configurationBuildItem
+ .getReadResult()
+ .getRunTimeDefaultValues()
+ .get(propertyKey);
+ }
+
+ return propertyValue;
+ }
}
diff --git
a/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/src/main/resources/static/index.html
b/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/src/main/resources/static/index.html
new file mode 100644
index 000000000..4040f1fbe
--- /dev/null
+++
b/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui-deployment/src/main/resources/static/index.html
@@ -0,0 +1,48 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<div id="envelope-app"></div>
+
+<script src="resources/webapp/standalone.js"></script>
+<script>
+ const urlParams = new URLSearchParams(window.location.search);
+ const page = urlParams.get("page");
+ const devUIUrl = urlParams.get("devUIUrl");
+ const dataIndexUrl = urlParams.get("dataIndexUrl");
+
+ const devUI = RuntimeToolsDevUI.open({
+ container: document.getElementById("envelope-app"),
+ isDataIndexAvailable: true,
+ dataIndexUrl: (dataIndexUrl ? dataIndexUrl : "") + "/graphql",
+ page: page,
+ devUIUrl: devUIUrl ? devUIUrl : window.location.origin,
+ openApiPath: "q/openapi.json",
+ availablePages: ["Processes", "Monitoring", "CustomDashboard"],
+ customLabels: {
+ singularProcessLabel: "Workflow",
+ pluralProcessLabel: "Workflows",
+ },
+ omittedProcessTimelineEvents: ["EmbeddedStart", "EmbeddedEnd", "Script"],
+ diagramPreviewSize: {
+ width: 1000,
+ height: 1000,
+ },
+ });
+</script>
diff --git
a/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui/src/main/java/org/kie/kogito/swf/tools/custom/dashboard/impl/CustomDashboardStorageImpl.java
b/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui/src/main/java/org/kie/kogito/swf/tools/custom/dashboard/impl/CustomDashboardStorageImpl.java
index 3afdcf16d..a2a00437c 100644
---
a/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui/src/main/java/org/kie/kogito/swf/tools/custom/dashboard/impl/CustomDashboardStorageImpl.java
+++
b/kogito-quarkus-serverless-workflow-devui-parent/kogito-quarkus-serverless-workflow-devui/src/main/java/org/kie/kogito/swf/tools/custom/dashboard/impl/CustomDashboardStorageImpl.java
@@ -90,6 +90,10 @@ public class CustomDashboardStorageImpl implements
CustomDashboardStorage {
} catch (Exception ex) {
LOGGER.warn("Couldn't properly initialize
CustomDashboardStorageImpl");
} finally {
+ if (classLoaderCustomDashboardUrl == null) {
+ return;
+ }
+
init(readCustomDashboardResources());
String storageUrl = getStorageUrl(classLoaderCustomDashboardUrl);
Thread t = new Thread(new DashboardFilesWatcher(reload(),
storageUrl));
diff --git a/ui-packages/packages/runtime-tools-dev-ui-webapp/package.json
b/ui-packages/packages/runtime-tools-dev-ui-webapp/package.json
index 3151e8ed1..a3d380faf 100644
--- a/ui-packages/packages/runtime-tools-dev-ui-webapp/package.json
+++ b/ui-packages/packages/runtime-tools-dev-ui-webapp/package.json
@@ -127,7 +127,7 @@
"mini-css-extract-plugin": "^2.7.6",
"node-polyfill-webpack-plugin": "^2.0.1",
"nodemon": "^2.0.22",
- "openapi-types": "^9.3.1",
+ "openapi-types": "^7.0.1",
"raw-loader": "^4.0.2",
"rimraf": "^3.0.2",
"sass-loader": "^12.6.0",
diff --git
a/ui-packages/packages/runtime-tools-dev-ui-webapp/src/channel/apis/apis.tsx
b/ui-packages/packages/runtime-tools-dev-ui-webapp/src/channel/apis/apis.tsx
index f142094ce..b7faaa24e 100755
--- a/ui-packages/packages/runtime-tools-dev-ui-webapp/src/channel/apis/apis.tsx
+++ b/ui-packages/packages/runtime-tools-dev-ui-webapp/src/channel/apis/apis.tsx
@@ -16,6 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
+
+import { OpenAPI } from 'openapi-types';
import { GraphQL } from '@kogito-apps/consoles-common/dist/graphql';
import {
BulkProcessInstanceActionResponse,
@@ -542,38 +544,50 @@ export const getCustomDashboardContent = (name: string):
Promise<string> => {
});
};
-export const getCustomWorkflowSchema = (
+export const getCustomWorkflowSchemaFromApi = async (
+ api: OpenAPI.Document,
+ workflowName: string
+): Promise<Record<string, any>> => {
+ let schema = {};
+
+ try {
+ const schemaFromRequestBody =
+ api.paths['/' +
workflowName].post.requestBody.content['application/json']
+ .schema;
+
+ if (schemaFromRequestBody.type) {
+ schema = {
+ type: schemaFromRequestBody.type,
+ properties: schemaFromRequestBody.properties
+ };
+ } else {
+ schema = (api as any).components.schemas[workflowName + '_input'];
+ }
+ } catch (e) {
+ console.log(e);
+ schema = (api as any).components.schemas[workflowName + '_input'];
+ }
+
+ // Components can contain the content of internal refs ($ref)
+ // This keeps the refs working while avoiding circular refs with the
workflow itself
+ if (schema) {
+ const { [workflowName + '_input']: _, ...schemas } =
+ (api as any).components?.schemas ?? {};
+ (schema as any)['components'] = { schemas };
+ }
+
+ return schema ?? null;
+};
+
+export const getCustomWorkflowSchema = async (
devUIUrl: string,
openApiPath: string,
workflowName: string
): Promise<Record<string, any>> => {
return new Promise((resolve, reject) => {
SwaggerParser.parse(`${devUIUrl}/${openApiPath}`)
- .then((response: any) => {
- let schema = {};
- try {
- const schemaFromRequestBody =
- response.paths['/' + workflowName].post.requestBody.content[
- 'application/json'
- ].schema;
- /* istanbul ignore else*/
- if (schemaFromRequestBody.type) {
- schema = {
- type: schemaFromRequestBody.type,
- properties: schemaFromRequestBody.properties
- };
- } else {
- schema = response.components.schemas[workflowName + '_input'];
- }
- } catch (e) {
- console.log(e);
- schema = response.components.schemas[workflowName + '_input'];
- }
- if (schema) {
- resolve(schema);
- } else {
- resolve(null);
- }
+ .then(async (response: any) => {
+ resolve(await getCustomWorkflowSchemaFromApi(response, workflowName));
})
.catch((err) => reject(err));
});
diff --git
a/ui-packages/packages/runtime-tools-dev-ui-webapp/src/channel/apis/tests/apis.test.tsx
b/ui-packages/packages/runtime-tools-dev-ui-webapp/src/channel/apis/tests/apis.test.tsx
index 143939d6e..b5ae6846a 100755
---
a/ui-packages/packages/runtime-tools-dev-ui-webapp/src/channel/apis/tests/apis.test.tsx
+++
b/ui-packages/packages/runtime-tools-dev-ui-webapp/src/channel/apis/tests/apis.test.tsx
@@ -1108,6 +1108,9 @@ describe('swf custom form tests', () => {
it('get custom workflow schema - success - with workflowdata', async () => {
const schema = {
+ components: {
+ schemas: {}
+ },
type: 'object',
properties: {
name: {
diff --git a/ui-packages/pnpm-lock.yaml b/ui-packages/pnpm-lock.yaml
index b7da5f539..9460833c3 100644
--- a/ui-packages/pnpm-lock.yaml
+++ b/ui-packages/pnpm-lock.yaml
@@ -1859,7 +1859,7 @@ importers:
dependencies:
'@apidevtools/swagger-parser':
specifier: ^10.1.0
- version: 10.1.0([email protected])
+ version: 10.1.0([email protected])
'@babel/standalone':
specifier: ^7.22.8
version: 7.22.8
@@ -2138,8 +2138,8 @@ importers:
specifier: ^2.0.22
version: 2.0.22
openapi-types:
- specifier: ^9.3.1
- version: 9.3.1
+ specifier: ^7.0.1
+ version: 7.2.3
raw-loader:
specifier: ^4.0.2
version: 4.0.2([email protected])
@@ -3144,7 +3144,7 @@ packages:
resolution: {integrity:
sha512-QAkD5kK2b1WfjDS/UQn/qQkbwF31uqRjPTrsCs5ZG9BQGAkjwvqGFjjPqAuzac/IYzpPtRzjCP1WrTuAIjMrXg==}
dev: false
- /@apidevtools/[email protected]([email protected]):
+ /@apidevtools/[email protected]([email protected]):
resolution: {integrity:
sha512-9Kt7EuS/7WbMAUv2gSziqjvxwDbFSg3Xeyfuj5laUODX8o/k/CpsAKiQ8W7/R88eXFTMbJYg6+7uAmOWNKmwnw==}
peerDependencies:
openapi-types: '>=7'
@@ -3156,7 +3156,7 @@ packages:
ajv: 8.12.0
ajv-draft-04: 1.0.0([email protected])
call-me-maybe: 1.0.2
- openapi-types: 9.3.1
+ openapi-types: 7.2.3
dev: false
/@apollo/[email protected]:
@@ -14866,10 +14866,6 @@ packages:
/[email protected]:
resolution: {integrity:
sha512-olbaNxz12R27+mTyJ/ZAFEfUruauHH27AkeQHDHRq5AF0LdNkK1SSV7EourXQDK+4aX7dv2HtyirAGK06WMAsA==}
- dev: false
-
- /[email protected]:
- resolution: {integrity:
sha512-/Yvsd2D7miYB4HLJ3hOOS0+vnowQpaT75FsHzr/y5M9P4q9bwa7RcbW2YdH6KZBn8ceLbKGnHxMZ1CHliGHUFw==}
/[email protected]:
resolution: {integrity:
sha512-9A5pqGoQk49H6Vhjb9kPgAeeECfUDF6aIICbMDL23kDLStBn1MWk3YvcZ4xWF9CsSf6XEgvRLkXy4xof/56vVw==}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]