Skip to content

Commit

Permalink
Merge branch 'main' into kie-issues#1547
Browse files Browse the repository at this point in the history
  • Loading branch information
jomarko committed Oct 30, 2024
2 parents 527aad4 + 448d767 commit 925f925
Show file tree
Hide file tree
Showing 37 changed files with 740 additions and 162 deletions.
11 changes: 8 additions & 3 deletions packages/bpmn-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@kie-tools-core/i18n": "workspace:*",
"@kie-tools-core/patternfly-base": "workspace:*",
"@kie-tools-core/vscode-extension": "workspace:*",
"@kie-tools/form-code-generator-vscode-command": "workspace:*",
"@kie-tools/kie-bc-editors": "workspace:*"
},
"devDependencies": {
Expand Down Expand Up @@ -65,11 +66,15 @@
"dark": "./static/svg-icon-dark.png",
"light": "./static/svg-icon-light.png"
},
"title": "Get BPMN Editor Preview SVG"
"title": "BPMN Editor: Get preview SVG"
},
{
"command": "extension.kogito.silentlyGenerateSvgBpmn",
"title": "Generate SVG without any notification"
"title": "BPMN Editor: Generate SVG without any notification"
},
{
"command": "extension.apache.kie.bpmnEditor.generateFormCode",
"title": "BPMN Editor: Generate form code for human interactions from jBPM project"
}
],
"configuration": {
Expand All @@ -93,7 +98,7 @@
},
"customEditors": [
{
"displayName": "BPMN Editor",
"displayName": "Apache KIE BPMN Editor",
"selector": [
{
"filenamePattern": "*.{bpmn,bpmn2}"
Expand Down
7 changes: 7 additions & 0 deletions packages/bpmn-vscode-extension/src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { I18n } from "@kie-tools-core/i18n/dist/core";
import { VsCodeBackendProxy } from "@kie-tools-core/backend/dist/vscode";
import * as KogitoVsCode from "@kie-tools-core/vscode-extension";
import * as vscode from "vscode";
import { generateFormsCommand } from "@kie-tools/form-code-generator-vscode-command/dist/generateFormCodeCommand";

let backendProxy: VsCodeBackendProxy;

Expand All @@ -49,6 +50,12 @@ export function activate(context: vscode.ExtensionContext) {
backendProxy: backendProxy,
});

context.subscriptions.push(
vscode.commands.registerCommand("extension.apache.kie.bpmnEditor.generateFormCode", async (args: any) =>
generateFormsCommand()
)
);

KogitoVsCode.VsCodeRecommendation.showExtendedServicesRecommendation(context);

console.info("Extension is successfully setup.");
Expand Down
10 changes: 5 additions & 5 deletions packages/form-code-generator-bootstrap4-theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ You can consume this package in two ways:

```ts
{
id: string; // The form id
sanitizedId: string; // The form id, any # is replaced by _
disabled?: boolean; // Enable/disable form (read only)
placeholder?: boolean; // Enable/disable placeholders
schema: Bridge; // A Uniforms Bridge instance
id: string; // The form id
idWithoutInvalidTsVarChars: string; // The form id, any # is replaced by _
disabled?: boolean; // Enable/disable form (read only)
placeholder?: boolean; // Enable/disable placeholders
schema: Bridge; // A Uniforms Bridge instance
}
```

Expand Down
7 changes: 3 additions & 4 deletions packages/form-code-generator-bootstrap4-theme/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ export const bootstrap4FormCodeGeneratorTheme: FormCodeGeneratorTheme<Bootstrap4
generate: (formSchema) => {
const form = renderForm({
id: formSchema.name,
sanitizedId: formSchema.name,
schema: new JSONSchemaBridge(formSchema.schema, () => true),
disabled: false,
placeholder: true,
});
return {
id: formSchema.name,
assetName: `${formSchema.name}.${BOOTSTRAP4_FILE_EXT}`,
type: BOOTSTRAP4_FILE_EXT,
name: formSchema.name,
fileName: `${formSchema.name}.${BOOTSTRAP4_FILE_EXT}`,
fileExt: BOOTSTRAP4_FILE_EXT,
content: unescape(form),
config: {
schema: JSON.stringify(formSchema.schema),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import unescape from "lodash/unescape";

interface Args {
id: string;
sanitizedId: string;
idWithoutInvalidTsVarChars?: string;
disabled?: boolean;
placeholder?: boolean;
schema: Bridge;
Expand Down
10 changes: 5 additions & 5 deletions packages/form-code-generator-patternfly-theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ You can consume this package in two ways:

```ts
{
id: string; // The form id
sanitizedId: string; // The form id, any # is replaced by _
disabled?: boolean; // Enable/disable form (read only)
placeholder?: boolean; // Enable/disable placeholders
schema: Bridge; // A Uniforms Bridge instance
id: string; // The form id
idWithoutInvalidTsVarChars: string; // The form id, any # is replaced by _
disabled?: boolean; // Enable/disable form (read only)
placeholder?: boolean; // Enable/disable placeholders
schema: Bridge; // A Uniforms Bridge instance
}
```

Expand Down
7 changes: 3 additions & 4 deletions packages/form-code-generator-patternfly-theme/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ export const patternflyFormCodeGeneratorTheme: FormCodeGeneratorTheme<Patternfly
generate: (formSchema) => {
const form = renderForm({
id: formSchema.name,
sanitizedId: formSchema.name,
schema: new JSONSchemaBridge(formSchema.schema, () => true),
disabled: false,
placeholder: true,
});
return {
id: formSchema.name,
assetName: `${formSchema.name}.${PATTERNFLY_FILE_EXT}`,
type: PATTERNFLY_FILE_EXT,
name: formSchema.name,
fileName: `${formSchema.name}.${PATTERNFLY_FILE_EXT}`,
fileExt: PATTERNFLY_FILE_EXT,
content: unescape(form),
config: {
schema: JSON.stringify(formSchema.schema),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { getStaticCodeBlock } from "./staticCode/staticCodeBlocks";

export type AutoFormProps = {
id: string;
sanitizedId: string;
idWithoutInvalidTsVarChars?: string;
disabled?: boolean;
placeholder?: boolean;
schema: Bridge;
Expand All @@ -54,7 +54,8 @@ const AutoForm: React.FC<AutoFormProps> = (props) => {
staticCodeArray = union(staticCodeArray, input.requiredCode);
});

const formName = `Form${props.sanitizedId ? `${NS_SEPARATOR}${props.sanitizedId}` : ""}`;
const formId = props.idWithoutInvalidTsVarChars ?? props.id;
const formName = `Form${formId ? `${NS_SEPARATOR}${formId}` : ""}`;
const hooks = inputs.map((input) => input.stateCode).join("\n");
const elements = inputs.map((input) => input.jsxCode).join("\n");
const staticCodeStr: string = staticCodeArray.map((id) => JSON.stringify(getStaticCodeBlock(id))).join("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import unescape from "lodash/unescape";

interface Args {
id: string;
sanitizedId: string;
idWithoutInvalidTsVarChars?: string;
disabled?: boolean;
placeholder?: boolean;
schema: Bridge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const schema = {

const props: AutoFormProps = {
id: "HRInterview",
sanitizedId: "HRInterview",
idWithoutInvalidTsVarChars: "HRInterview",
schema: createSchema(schema),
disabled: false,
placeholder: true,
Expand Down
64 changes: 64 additions & 0 deletions packages/form-code-generator-vscode-command/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--
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.
-->

## Form Code Generator VS Code command

This package is a VS Code command for generating form code from jBPM projects.

## How it works?

The command provides a user-friendly interface for generating form code from jBPM projects. It interacts with the file system getting the jBPM JSON Schemas that are generated during compile time, and feeding them to the "form-code-generator" that will generate the form code using one of two themes: Bootstrap4 or Patternfly.

## Usage

The command name will change depending on the host extension, but it should be available in the command palette. After starting the command, the user will be prompted with a few questions, which can be represented using the following diagram:

![VS Code command diagram](./docs/vscode-command-diagram.png?raw=true "VS Code command diagram")

## Build

In order to build the library you must run the following command in the root folder of the repository:

```shell script
pnpm -F @kie-tools/form-code-generator-vscode-command... build:prod
```

---

Apache KIE (incubating) is an effort undergoing incubation at The Apache Software
Foundation (ASF), sponsored by the name of Apache Incubator. Incubation is
required of all newly accepted projects until a further review indicates that
the infrastructure, communications, and decision making process have stabilized
in a manner consistent with other successful ASF projects. While incubation
status is not necessarily a reflection of the completeness or stability of the
code, it does indicate that the project has yet to be fully endorsed by the ASF.

Some of the incubating project’s releases may not be fully compliant with ASF
policy. For example, releases may have incomplete or un-reviewed licensing
conditions. What follows is a list of known issues the project is currently
aware of (note that this list, by definition, is likely to be incomplete):

- Hibernate, an LGPL project, is being used. Hibernate is in the process of
relicensing to ASL v2
- Some files, particularly test files, and those not supporting comments, may
be missing the ASF Licensing Header

If you are planning to incorporate this work into your product/project, please
be aware that you will need to conduct a thorough licensing review to determine
the overall implications of including this work. For the current status of this
project through the Apache Incubator visit:
https://incubator.apache.org/projects/kie.html
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions packages/form-code-generator-vscode-command/env/index.js
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 {};
},
});
37 changes: 37 additions & 0 deletions packages/form-code-generator-vscode-command/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@kie-tools/form-code-generator-vscode-command",
"version": "0.0.0",
"description": "",
"license": "Apache-2.0",
"keywords": [],
"homepage": "https://github.com/apache/incubator-kie-tools",
"repository": {
"type": "git",
"url": "https://github.com/apache/incubator-kie-tools.git"
},
"bugs": {
"url": "https://github.com/apache/incubator-kie-tools/issues"
},
"files": [
"dist"
],
"scripts": {
"build:dev": "rimraf dist && tsc",
"build:prod": "pnpm lint && rimraf dist && tsc",
"lint": "run-script-if --bool \"$(build-env linters.run)\" --then \"kie-tools--eslint ./src\""
},
"dependencies": {
"@kie-tools/form-code-generator": "workspace:*",
"@kie-tools/form-code-generator-bootstrap4-theme": "workspace:*",
"@kie-tools/form-code-generator-patternfly-theme": "workspace:*",
"@kie-tools/jbpm-form-code-generator-themes": "workspace:*"
},
"devDependencies": {
"@kie-tools/eslint": "workspace:*",
"@kie-tools/root-env": "workspace:*",
"@kie-tools/tsconfig": "workspace:*",
"@types/vscode": "1.67.0",
"rimraf": "^3.0.2",
"typescript": "^5.5.3"
}
}
Loading

0 comments on commit 925f925

Please sign in to comment.