-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KOGITO-9935: Extract common consumer runtime tools code to a reusable…
… package (#2066) Co-authored-by: Paulo Martins <[email protected]>
- Loading branch information
Showing
78 changed files
with
1,870 additions
and
2,208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env"); | ||
|
||
module.exports = composeEnv([require("@kie-tools/root-env/env")], { | ||
vars: varsWithName({}), | ||
get env() { | ||
return {}; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
globals: { | ||
"ts-jest": { | ||
tsconfig: "<rootDir>/tsconfig.json", | ||
}, | ||
}, | ||
reporters: ["default", ["jest-junit", { outputFile: "./dist-tests/junit-report.xml" }]], | ||
moduleDirectories: ["node_modules"], | ||
moduleFileExtensions: ["js", "jsx", "ts", "tsx"], | ||
testRegex: "/tests/.*\\.test\\.(jsx?|tsx?)$", | ||
transform: { | ||
"^.+\\.jsx?$": ["babel-jest", { presets: [["@babel/env", { targets: { node: "current" } }], "@babel/react"] }], | ||
"^.+\\.tsx?$": "ts-jest", | ||
}, | ||
moduleNameMapper: { | ||
"\\.(css|less|sass|scss)$": "<rootDir>/tests/__mocks__/styleMock.js", | ||
}, | ||
setupFilesAfterEnv: ["./tests/jest.setup.ts"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "@kie-tools/runtime-tools-webapp-components", | ||
"version": "0.0.0", | ||
"description": "", | ||
"license": "Apache-2.0", | ||
"keywords": [], | ||
"homepage": "https://github.com/kiegroup/kie-tools", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kiegroup/kie-tools.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/kiegroup/kie-tools/issues" | ||
}, | ||
"types": "./dist/index.d.ts", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build:dev": "rimraf dist && tsc -p tsconfig.json", | ||
"build:prod": "pnpm lint && rimraf dist && tsc -p tsconfig.json && pnpm test", | ||
"lint": "run-script-if --bool \"$(build-env linters.run)\" --then \"kie-tools--eslint ./src\"", | ||
"test": "run-script-if --ignore-errors \"$(build-env tests.ignoreFailures)\" --bool \"$(build-env tests.run)\" --then \"jest --silent --verbose --passWithNoTests\"" | ||
}, | ||
"dependencies": { | ||
"@kie-tools/runtime-tools-components": "workspace:*", | ||
"@kie-tools/runtime-tools-enveloped-components": "workspace:*", | ||
"@kie-tools/runtime-tools-gateway-api": "workspace:*", | ||
"@patternfly/react-core": "^4.276.6", | ||
"apollo-cache-inmemory": "1.6.6", | ||
"apollo-client": "2.6.10", | ||
"apollo-link-http": "1.5.17", | ||
"react": "^17.0.2" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.16.0", | ||
"@babel/preset-env": "^7.16.0", | ||
"@babel/preset-react": "^7.16.0", | ||
"@kie-tools/eslint": "workspace:*", | ||
"@kie-tools/root-env": "workspace:*", | ||
"@kie-tools/tsconfig": "workspace:*", | ||
"@testing-library/jest-dom": "^5.16.1", | ||
"@testing-library/react": "^11.2.6", | ||
"@types/jest": "^26.0.23", | ||
"@types/react": "^17.0.6", | ||
"@types/testing-library__jest-dom": "^5.9.1", | ||
"@types/testing-library__react": "^9.1.2", | ||
"jest": "^26.6.3", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.6.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...s/runtime-tools-webapp-components/src/CloudEventFormContainer/CloudEventFormContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import React, { useCallback } from "react"; | ||
import { componentOuiaProps, OUIAProps } from "@kie-tools/runtime-tools-components/dist/ouiaTools"; | ||
import { useCloudEventFormGatewayApi } from "../CloudEventForm"; | ||
import { EmbeddedCloudEventForm } from "@kie-tools/runtime-tools-enveloped-components/dist/cloudEventForm"; | ||
import { CloudEventRequest } from "@kie-tools/runtime-tools-gateway-api/dist/types"; | ||
|
||
interface CloudEventFormContainerProps { | ||
instanceId?: string; | ||
cloudEventSource: string; | ||
isTriggerNewInstance: boolean; | ||
onStartWorkflowError: (error: any) => void; | ||
onTriggerCloudEventSuccess: () => void; | ||
onTriggerStartCloudEventSuccess: (businessKey: string) => void; | ||
} | ||
|
||
export const CloudEventFormContainer: React.FC<CloudEventFormContainerProps & OUIAProps> = ({ | ||
instanceId, | ||
cloudEventSource, | ||
isTriggerNewInstance, | ||
onStartWorkflowError, | ||
onTriggerCloudEventSuccess, | ||
onTriggerStartCloudEventSuccess, | ||
ouiaId, | ||
ouiaSafe, | ||
}) => { | ||
const gatewayApi = useCloudEventFormGatewayApi(); | ||
|
||
const triggerStartCloudEvent = useCallback( | ||
(event: CloudEventRequest) => { | ||
return gatewayApi | ||
.triggerStartCloudEvent(event) | ||
.then((businessKey) => { | ||
onTriggerStartCloudEventSuccess(businessKey); | ||
}) | ||
.catch((error) => onStartWorkflowError(error)); | ||
}, | ||
[gatewayApi, onStartWorkflowError, onTriggerStartCloudEventSuccess] | ||
); | ||
|
||
const triggerCloudEvent = useCallback( | ||
(event: CloudEventRequest) => { | ||
return gatewayApi | ||
.triggerCloudEvent(event) | ||
.then((_response) => { | ||
onTriggerCloudEventSuccess(); | ||
}) | ||
.catch((error) => onStartWorkflowError(error)); | ||
}, | ||
[gatewayApi, onStartWorkflowError, onTriggerCloudEventSuccess] | ||
); | ||
|
||
return ( | ||
<EmbeddedCloudEventForm | ||
{...componentOuiaProps(ouiaId, "cloud-event-form-container", ouiaSafe)} | ||
targetOrigin={window.location.origin} | ||
isNewInstanceEvent={isTriggerNewInstance} | ||
defaultValues={{ cloudEventSource, instanceId }} | ||
driver={{ | ||
triggerCloudEvent(event: CloudEventRequest): Promise<void> { | ||
const doTrigger = isTriggerNewInstance ? triggerStartCloudEvent : triggerCloudEvent; | ||
return doTrigger(event); | ||
}, | ||
}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.