Skip to content

Commit

Permalink
KOGITO-8028: Dashbuilder Viewer VSCode Extension (apache#1260)
Browse files Browse the repository at this point in the history
* KOGITO-7937: Dashbuilder Editor Viewer

* Renaming to DashbuilderViewer

* building dashbuilder runtime in dev as well

* Removing duplicated script

* Exposing content loading in Javascript as well

* Now the envelope is also used as Dashbuilder container

* Dynamically loading resources

* Components in buil:dev

* Fixes and updating lock and graph files

* Version update

* Version fix

* License headers update

* KOGITO-8028: Dashbuilder Viewer VSCode Extension

* removing old

* Adding support for commands

* Configuration

* preventing path transversal

* Fix icon and versions update

* Fixing jenkins job

* Adding files for release

* Fixing readme

* Fixing Red Hat

* Fixing file associations

* Fixing package.json

* fixing the fix

* Adding dashbuilder edtiro to the kogito bundle

* fixes
  • Loading branch information
jesuino authored Oct 18, 2022
1 parent a7ab12f commit 4bce666
Show file tree
Hide file tree
Showing 40 changed files with 1,412 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .ci/jenkins/Jenkinsfile.vscode
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ node('rhel8') {
sh 'wget "https://github.com/kiegroup/kie-tools/releases/download/$VERSION/vscode_extension_dmn_editor_$VERSION.vsix"'
sh 'wget "https://github.com/kiegroup/kie-tools/releases/download/$VERSION/vscode_extension_pmml_editor_$VERSION.vsix"'
sh 'wget "https://github.com/kiegroup/kie-tools/releases/download/$VERSION/vscode_extension_serverless_workflow_editor_$VERSION.vsix"'
sh 'wget "https://github.com/kiegroup/kie-tools/releases/download/$VERSION/vscode_extension_dashbuilder_editor_$VERSION.vsix"'
sh 'wget "https://github.com/kiegroup/kie-tools/releases/download/$VERSION/vscode_extension_red_hat_business_automation_bundle_$VERSION.vsix"'
sh 'wget "https://github.com/kiegroup/kie-tools/releases/download/$VERSION/vscode_extension_kogito_bundle_$VERSION.vsix"'
sh 'wget "https://github.com/kiegroup/kie-tools/releases/download/$VERSION/vscode_extension_kie_ba_bundle_$VERSION.vsix"'
Expand Down Expand Up @@ -42,6 +43,7 @@ node('rhel8') {
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix_editors[1].path}"
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix_editors[2].path}"
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix_editors[3].path}"
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix_editors[4].path}"
sh 'vsce publish -p ${TOKEN} --packagePath' + " ${vsix_redhat_bundle[0].path}"
}
withCredentials([[$class: 'StringBinding', credentialsId: 'kie-vscode-token', variable: 'KIE_TOKEN']]) {
Expand All @@ -59,6 +61,7 @@ node('rhel8') {
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix_editors[1].path}"
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix_editors[2].path}"
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix_editors[3].path}"
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix_editors[4].path}"
sh 'ovsx publish -p ${OVSX_TOKEN}' + " ${vsix_redhat_bundle[0].path}"
}
withCredentials([[$class: 'StringBinding', credentialsId: 'kie-openvsx-token', variable: 'KIE_OVSX_TOKEN']]) {
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/daily_dev_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@ jobs:
name: vscode-extension-serverless-workflow-editor
path: kie-tools/packages/vscode-extension-serverless-workflow-editor/dist/vscode_extension_serverless_workflow_editor_${{ steps.version.outputs.version }}.vsix

- name: "Upload Dashbuilder VS Code Extension (Ubuntu only)"
if: runner.os == 'Linux'
uses: actions/upload-artifact@v1
with:
name: vscode-extension-dashbuilder-editor
path: kie-tools/packages/vscode-extension-dashbuilder-editor/dist/vscode_extension_dashbuilder_editor_${{ steps.version.outputs.version }}.vsix

- name: "Upload VS Code Extension (dev) (Ubuntu only)"
if: runner.os == 'Linux'
uses: actions/upload-artifact@v1
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,17 @@ jobs:
asset_name: vscode_extension_serverless_workflow_editor_${{ inputs.tag }}.vsix
asset_content_type: application/zip

- name: "Upload VS Code Extension - Dashbuilder Editor (prod)"
if: ${{ !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
with:
upload_url: ${{ inputs.upload_asset_url }}
asset_path: ./packages/vscode-extension-dashbuilder-editor/dist/vscode_extension_dashbuilder_editor_${{ inputs.tag }}.vsix
asset_name: vscode_extension_dashbuilder_editor_${{ inputs.tag }}.vsix
asset_content_type: application/zip

desktop:
if: ${{ needs.extract_runners.outputs.desktop == 'true' }}
runs-on: ${{ matrix.os }}
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/staging_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,17 @@ jobs:
asset_name: STAGING__vscode_extension_serverless_workflow_editor_${{ inputs.tag }}.vsix
asset_content_type: application/zip

- name: "STAGING: Upload VS Code Extension - Dashbuilder Editor (prod) (Ubuntu only)"
if: ${{ runner.os == 'Linux' && !inputs.dry_run }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
with:
upload_url: ${{ inputs.upload_asset_url }}
asset_path: ${{ github.workspace }}/kie-tools/packages/vscode-extension-dashbuilder-editor/dist/vscode_extension_dashbuilder_editor_${{ inputs.tag }}.vsix
asset_name: STAGING__vscode_extension_dashbuilder_editor_${{ inputs.tag }}.vsix
asset_content_type: application/zip

- name: "STAGING: Upload VS Code Extension - Kogito Bundle (prod) (Ubuntu only)"
if: ${{ matrix.os == 'ubuntu-latest' && !inputs.dry_run }}
uses: actions/[email protected]
Expand Down
Binary file added gifs/dashbuilder.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@kie-tools-core/workspace": "workspace:*",
"axios": "^0.27.2",
"fast-xml-parser": "^3.17.4",
"portfinder": "^1.0.27",
"portfinder": "^1.0.32",
"semver": "^7.3.5",
"sinon": "^11.1.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

interface CustomWindow extends Window {
componentServerUrl: string;

setDashbuilderContent: (content: string) => void;
dashbuilderReady: () => void;
}
Expand All @@ -40,4 +42,8 @@ export class DashbuilderWrapper {
public getContent(): string {
return this.content;
}

public setComponentServerUrl(componentServerUrl: string) {
window.componentServerUrl = componentServerUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@

import { KogitoEditorChannelApi } from "@kie-tools-core/editor/dist/api";

export interface DashbuilderViewerChannelApi extends KogitoEditorChannelApi {}
export interface DashbuilderViewerChannelApi extends KogitoEditorChannelApi {
getComponentsServerUrl(): Promise<string | undefined>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class DashbuilderViewerFactory implements EditorFactory<Editor, Dashbuild
appendLoaderContainer();
const langData = getDashbuilderLanguageData(initArgs.resourcesPathPrefix);
langData.resources.forEach((resource) => loadResource(resource));

return new DashbuilderViewerView(ctx, initArgs);
}
}
Expand Down
18 changes: 8 additions & 10 deletions packages/dashbuilder-viewer/src/envelope/DashbuilderViewerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ import { Notification } from "@kie-tools-core/notifications/dist/api";
import * as React from "react";
import { DashbuilderViewerChannelApi } from "./DashbuilderViewerChannelApi";

export interface CustomWindow extends Window {
setDashbuilderContent: (content: string) => void;
dashbuilderReady: () => void;
}

declare let window: CustomWindow;

export class DashbuilderViewerView implements Editor {
private readonly editorRef: React.RefObject<EditorApi>;
public dashbuilderWrapper: DashbuilderWrapper;
Expand All @@ -45,9 +38,14 @@ export class DashbuilderViewerView implements Editor {
private readonly initArgs: EditorInitArgs
) {
this.editorRef = React.createRef<EditorApi>();
this.dashbuilderWrapper = new DashbuilderWrapper(() =>
envelopeContext.channelApi.notifications.kogitoEditor_ready.send()
);
this.dashbuilderWrapper = new DashbuilderWrapper(() => {
envelopeContext.channelApi.requests.getComponentsServerUrl().then((componentServerUrl) => {
if (componentServerUrl) {
this.dashbuilderWrapper.setComponentServerUrl(componentServerUrl);
}
});
envelopeContext.channelApi.notifications.kogitoEditor_ready.send();
});
}

public async getElementPosition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ public void withComponentIdAndPartition(String componentId, String partition) {
public void withComponentBaseUrlIdAndPartition(String baseUrl, String componentId, String partition) {
var url = "";
if (baseUrl == null) {
url = buildUrl(hostPageUrl, COMPONENT_SERVER_PATH, componentId, partition);
var customComponentServerUrl = getComponentServerUrl();
if (customComponentServerUrl == null || customComponentServerUrl.trim().isEmpty()) {
url = buildUrl(hostPageUrl, COMPONENT_SERVER_PATH, componentId, partition);
} else {
url = buildUrl(customComponentServerUrl, "", componentId, partition);
}
} else {
url = buildUrl(baseUrl, null, componentId, partition);
}
Expand Down Expand Up @@ -167,4 +172,8 @@ String buildUrl(String baseUrl, String componentsPath, String componentId, Strin
return url.toLowerCase();
}

private static native String getComponentServerUrl() /*-{
return $wnd.componentServerUrl;
}-*/;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import javax.enterprise.context.Dependent;
import javax.inject.Inject;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import elemental2.dom.Event;
import elemental2.dom.HTMLDivElement;
Expand Down Expand Up @@ -86,7 +85,7 @@ public void postMessage(ExternalComponentMessage message) {

private void postMessageToComponent(Object message) {
if (externalComponentIFrame != null && externalComponentIFrame.contentWindow != null) {
externalComponentIFrame.contentWindow.postMessage(message, Window.Location.getHref());
externalComponentIFrame.contentWindow.postMessage(message, "*");
}
}

Expand All @@ -105,7 +104,7 @@ public void configurationIssue(String message) {
public void configurationOk() {
showComponent();
}

private void showConfigurationIssue() {
configurationIssueRoot.style.display = "block";
externalComponentIFrame.style.display = "none";
Expand All @@ -130,4 +129,4 @@ private Object onInvoke(Event e) {
return null;
}

}
}
24 changes: 24 additions & 0 deletions packages/vscode-extension-dashbuilder-editor/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"preLaunchTask": "npm: watch"
},
{
"name": "Run Extension (web)",
"type": "pwa-extensionHost",
"debugWebWorkerHost": true,
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionDevelopmentKind=web"],
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
"preLaunchTask": "npm: watch"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files.exclude": {
"out": false
},
"search.exclude": {
"out": true
},
"typescript.tsc.autoDetect": "off"
}
18 changes: 18 additions & 0 deletions packages/vscode-extension-dashbuilder-editor/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
1 change: 1 addition & 0 deletions packages/vscode-extension-dashbuilder-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 0.?.0 (alpha)
Loading

0 comments on commit 4bce666

Please sign in to comment.