fantonangeli commented on code in PR #2302:
URL:
https://github.com/apache/incubator-kie-tools/pull/2302#discussion_r1593711444
##########
packages/runtime-tools-swf-gateway-api/src/gatewayApi/apis.tsx:
##########
@@ -518,42 +518,28 @@ export const triggerCloudEvent = (event:
CloudEventRequest, baseUrl: string, pro
return doTriggerCloudEvent(event, baseUrl, proxyEndpoint);
};
-export const createWorkflowDefinitionList = (
- workflowDefinitionObjs: WorkflowDefinition[],
- url: string
-): WorkflowDefinition[] => {
- const workflowDefinitionList: WorkflowDefinition[] = [];
- workflowDefinitionObjs.forEach((workflowDefObj) => {
- const workflowName = Object.keys(workflowDefObj)[0].split("/")[1];
- const endpoint = `${url}/${workflowName}`;
- workflowDefinitionList.push({
- workflowName,
- endpoint,
- });
- });
- return workflowDefinitionList;
-};
-
-export const getWorkflowDefinitionList = (baseUrl: string, openApiPath:
string): Promise<WorkflowDefinition[]> => {
- return new Promise((resolve, reject) => {
- SwaggerParser.parse(`${baseUrl}/${openApiPath}`)
- .then((response) => {
- const workflowDefinitionObjs: any[] = [];
- const paths = response.paths;
- const regexPattern = /^\/[^\n/]+\/schema/;
- Object.getOwnPropertyNames(paths)
- .filter((path) => regexPattern.test(path.toString()))
- .forEach((url) => {
- let workflowArray = url.split("/");
- workflowArray = workflowArray.filter((name) => name.length !== 0);
- /* istanbul ignore else*/
- if
(Object.prototype.hasOwnProperty.call(paths![`/${workflowArray[0]}`], "post")) {
- workflowDefinitionObjs.push({ [url]: paths![url] });
- }
- });
- resolve(createWorkflowDefinitionList(workflowDefinitionObjs, baseUrl));
+export const getWorkflowDefinitions = (client: ApolloClient<any>):
Promise<WorkflowDefinition[]> => {
+ return new Promise<WorkflowDefinition[]>((resolve, reject) => {
+ client
+ .query({
+ query: GraphQL.GetProcessDefinitionsDocument,
+ fetchPolicy: "network-only",
+ errorPolicy: "all",
})
- .catch((err: any) => reject(err));
+ .then((value) => {
+ const workflowDefinitions = value.data.ProcessDefinitions;
+ resolve(
+ value.data.ProcessDefinitions.map((item: { id: string; endpoint:
string }) => {
+ return {
+ workflowName: item.id,
+ endpoint: item.endpoint,
Review Comment:
I think we should continue composing the `endpoint` using the
`kogitoServiceUrl` to send the correct `Target-Url` to cors-proxy
##########
packages/serverless-logic-web-tools/src/runtimeTools/contexts/WebToolsWorkflowDefinitionListContextProvider.tsx:
##########
@@ -20,12 +20,17 @@
import * as React from "react";
import { WorkflowDefinitionListContextProvider } from
"@kie-tools/runtime-tools-swf-webapp-components/dist/WorkflowDefinitionList";
import { useSettings } from "../../settings/SettingsContext";
+import { useEnv } from "../../env/EnvContext";
export function WebToolsWorkflowDefinitionListContextProvider(props:
React.PropsWithChildren<{}>) {
const settings = useSettings();
+ const { env } = useEnv();
return (
- <WorkflowDefinitionListContextProvider
kogitoServiceUrl={settings.runtimeTools.config.kogitoServiceUrl}>
+ <WorkflowDefinitionListContextProvider
Review Comment:
Following my previous comment about `kogitoServiceUrl` I think we still need
to pass it to `WorkflowDefinitionListContextProvider`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]