You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ma...@apache.org on 2021/10/14 22:49:41 UTC
[camel-karavan] branch main updated: VS Code extension preview with
components (#24)
This is an automated email from the ASF dual-hosted git repository.
marat pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push:
new af02775 VS Code extension preview with components (#24)
af02775 is described below
commit af027758581dba338d8d86b91c27c64d446525b9
Author: Marat Gubaidullin <ma...@gmail.com>
AuthorDate: Thu Oct 14 18:49:38 2021 -0400
VS Code extension preview with components (#24)
* VS Code extension preview with components
* VS Code extension upload name
---
.github/workflows/main.yml | 16 +++++++++++++++-
karavan-designer/src/designer/ui/DslElement.tsx | 9 +++++++--
karavan-vscode/package.json | 2 +-
karavan-vscode/src/extension.ts | 12 ++++++++++++
karavan-vscode/webpack.config.js | 1 +
karavan-vscode/webview/App.tsx | 4 ++++
6 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index fbe6fa1..93223c6 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -25,4 +25,18 @@ jobs:
- name: Karavan VS Code extension (build)
working-directory: ./karavan-vscode
- run: yarn run package
\ No newline at end of file
+ run: yarn run package
+
+ - name: Karavan VS Code extension (install vsce)
+ working-directory: ./karavan-vscode
+ run: npm install -g vsce
+
+ - name: Karavan VS Code extension (package)
+ working-directory: ./karavan-vscode
+ run: vsce package
+
+ - name: Karavan VS Code extension (upload)
+ uses: actions/upload-artifact@v2
+ with:
+ name: camel-karavan-vscode.vsix
+ path: ./karavan-vscode/*.vsix
\ No newline at end of file
diff --git a/karavan-designer/src/designer/ui/DslElement.tsx b/karavan-designer/src/designer/ui/DslElement.tsx
index 28aba5e..cb2acfd 100644
--- a/karavan-designer/src/designer/ui/DslElement.tsx
+++ b/karavan-designer/src/designer/ui/DslElement.tsx
@@ -140,7 +140,7 @@ export class DslElement extends React.Component<Props, State> {
getHeaderWithTooltip = (tooltip: string | undefined) => {
return (
- <Tooltip position={"auto"} disabled={CamelUi.isShowExpressionTooltip(this.state.element)}
+ <Tooltip position={"auto"}
content={<div>{tooltip}</div>}>
{this.getHeader()}
</Tooltip>
@@ -153,6 +153,11 @@ export class DslElement extends React.Component<Props, State> {
return undefined;
}
+ getElementHeader = () => {
+ const tooltip = this.getHeaderTooltip();
+ return tooltip === undefined ? this.getHeader() : this.getHeaderWithTooltip(tooltip);
+ }
+
render() {
return (
<div className={
@@ -168,7 +173,7 @@ export class DslElement extends React.Component<Props, State> {
onClick={event => this.selectElement(event)}
>
- {this.getHeaderWithTooltip(this.getHeaderTooltip())}
+ {this.getElementHeader()}
{this.state.element.hasSteps() && !this.horizontal() && this.getArrow()}
<div className={this.state.element.dslName}>
{this.state.element.hasSteps() &&
diff --git a/karavan-vscode/package.json b/karavan-vscode/package.json
index 20a075a..6dc4d1a 100644
--- a/karavan-vscode/package.json
+++ b/karavan-vscode/package.json
@@ -1,6 +1,6 @@
{
"name": "karavan-vscode",
- "publisher": "Apache Camel",
+ "publisher": "camel-karavan",
"displayName": "Camel Karavan Designer",
"icon": "icons/icon.png",
"description": "Integration Designer for Apache Camel",
diff --git a/karavan-vscode/src/extension.ts b/karavan-vscode/src/extension.ts
index 2fbf86e..e9d569c 100644
--- a/karavan-vscode/src/extension.ts
+++ b/karavan-vscode/src/extension.ts
@@ -103,6 +103,9 @@ function openKaravanWebView(context: vscode.ExtensionContext, webviewContent: st
// Read and send Kamelets
panel.webview.postMessage({command: 'kamelets', kamelets: readKamelets()});
+ // Read and send Components
+ panel.webview.postMessage({command: 'components', components: readComponents()});
+
// Send integration
panel.webview.postMessage({command: 'open', name: name, yaml: yaml});
@@ -135,6 +138,15 @@ function readKamelets(): string[] {
return yamls;
}
+function readComponents(): string[] {
+ const uri: vscode.Uri = vscode.Uri.file(path.resolve(
+ path.join(__dirname, './components')
+ ))
+ const jsons: string[] = fs.readdirSync(uri.fsPath).filter(file => file.endsWith("json")).map(file => fs.readFileSync(uri.fsPath + "/" + file, 'utf-8'));
+ console.log(jsons)
+ return jsons;
+}
+
function isIntegration(yaml: string): [boolean, string?] {
const i = CamelYaml.yamlToIntegration(yaml);
if (i.kind === 'Integration' && i.metadata.name){
diff --git a/karavan-vscode/webpack.config.js b/karavan-vscode/webpack.config.js
index 463de7f..6ca48d0 100644
--- a/karavan-vscode/webpack.config.js
+++ b/karavan-vscode/webpack.config.js
@@ -144,6 +144,7 @@ const prerenderConfig = (webpackEnv) => {
new CopyPlugin({
patterns: [
{from: "kamelets", to: "kamelets"},
+ {from: "components", to: "components"}
],
}),
],
diff --git a/karavan-vscode/webview/App.tsx b/karavan-vscode/webview/App.tsx
index fd93a27..da21b7c 100644
--- a/karavan-vscode/webview/App.tsx
+++ b/karavan-vscode/webview/App.tsx
@@ -21,6 +21,7 @@ import {
import {KaravanDesigner} from "../designer/ui/KaravanDesigner";
import vscode from "./vscode";
import {KameletApi} from "../designer/api/KameletApi";
+import { ComponentApi } from "../designer/api/ComponentApi";
interface Props {
}
@@ -47,6 +48,9 @@ class App extends React.Component<Props, State> {
case 'kamelets':
KameletApi.saveKamelets(message.kamelets);
break;
+ case 'components':
+ ComponentApi.saveComponents(message.components);
+ break;
case 'open':
if (this.state.name === '' && this.state.key === ''){
this.setState({name: message.name, yaml: message.yaml, key: Math.random().toString()});