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 2024/01/31 22:21:10 UTC
(camel-karavan) branch main updated: #1091 in VsCode
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 fa8fdf90 #1091 in VsCode
fa8fdf90 is described below
commit fa8fdf90aeca75918932840e80455a79fb8a8098
Author: Marat Gubaidullin <ma...@talismancloud.io>
AuthorDate: Wed Jan 31 17:21:02 2024 -0500
#1091 in VsCode
---
karavan-vscode/src/designerView.ts | 14 +++++++++-----
karavan-vscode/src/utils.ts | 16 ++++++++++++++++
karavan-vscode/webview/App.tsx | 8 ++++++--
3 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/karavan-vscode/src/designerView.ts b/karavan-vscode/src/designerView.ts
index 265bc924..1f6879de 100644
--- a/karavan-vscode/src/designerView.ts
+++ b/karavan-vscode/src/designerView.ts
@@ -177,7 +177,9 @@ export class DesignerView {
utils.readJavaCode(fullPath),
// Read supported components
utils.readSupportedComponents(),
- utils.readSupportedOnlySettings()
+ utils.readSupportedOnlySettings(),
+ // Read property placeholders
+ utils.readPropertyPlaceholder(this.context)
]).then(results => {
// Send Kamelets
panel.webview.postMessage({ command: 'kamelets', kamelets: results[0] });
@@ -191,22 +193,24 @@ export class DesignerView {
if (results[4]) panel.webview.postMessage({ command: 'supportedComponents', components: results[4]});
if (results[5] === true) panel.webview.postMessage({ command: 'supportedOnly'});
// Send integration
- this.sendIntegrationData(panel, filename, relativePath, fullPath, reread, yaml, tab);
+ this.sendIntegrationData(panel, filename, relativePath, fullPath, reread, yaml, tab, results[6]);
}).catch(err => console.log(err));
}
- sendIntegrationData(panel: WebviewPanel, filename: string, relativePath: string, fullPath: string, reread: boolean, yaml?: string, tab?: string) {
+ sendIntegrationData(panel: WebviewPanel, filename: string, relativePath: string, fullPath: string, reread: boolean, yaml?: string, tab?: string, propertyPlaceholders?: string[]) {
// Read file if required
if (reread) {
utils.readFile(path.resolve(fullPath)).then(readData => {
const yaml = Buffer.from(readData).toString('utf8');
// Send integration
- panel.webview.postMessage({ command: 'open', page: "designer", filename: filename, relativePath: relativePath, fullPath:fullPath, yaml: yaml, tab: tab });
+ panel.webview.postMessage(
+ { command: 'open', page: "designer", filename: filename, relativePath: relativePath, fullPath:fullPath, yaml: yaml, tab: tab, propertyPlaceholders: propertyPlaceholders });
});
} else {
// Send integration
- panel.webview.postMessage({ command: 'open', page: "designer", filename: filename, relativePath: relativePath, fullPath:fullPath, yaml: yaml, tab: tab });
+ panel.webview.postMessage(
+ { command: 'open', page: "designer", filename: filename, relativePath: relativePath, fullPath:fullPath, yaml: yaml, tab: tab, propertyPlaceholders: propertyPlaceholders });
}
}
diff --git a/karavan-vscode/src/utils.ts b/karavan-vscode/src/utils.ts
index c55901ee..6cb7083b 100644
--- a/karavan-vscode/src/utils.ts
+++ b/karavan-vscode/src/utils.ts
@@ -111,6 +111,22 @@ export async function readComponents(context: ExtensionContext) {
return jsons;
}
+export async function readPropertyPlaceholder(context: ExtensionContext) {
+ const result: string[] = [];
+ const properties = await getProperties();
+ const lines = properties.split('\n').map((line) => line.trim());
+ lines
+ .filter(line => !line.startsWith("camel.") && !line.startsWith("jkube.") && !line.startsWith("jib."))
+ .filter(line => line !== undefined && line !== null && line.length > 0)
+ .forEach(line => {
+ const parts = line.split("=");
+ if (parts.length > 0) {
+ result.push(parts[0]);
+ }
+ })
+ return result;
+}
+
export async function readTemplates(context: ExtensionContext) {
const result = new Map<string, string>();
const runtime = await getRuntime();
diff --git a/karavan-vscode/webview/App.tsx b/karavan-vscode/webview/App.tsx
index c8742e52..e539d7f1 100644
--- a/karavan-vscode/webview/App.tsx
+++ b/karavan-vscode/webview/App.tsx
@@ -46,7 +46,8 @@ interface State {
page: "designer" | "knowledgebase" | 'topology'
active: boolean
tab?: "routes" | "rest" | "beans"
- files: IntegrationFile[]
+ files: IntegrationFile[],
+ propertyPlaceholders: string[]
}
class App extends React.Component<Props, State> {
@@ -64,6 +65,7 @@ class App extends React.Component<Props, State> {
page: "designer",
active: false,
files: [],
+ propertyPlaceholders: []
};
saveScheduledChanges = () => {
@@ -153,7 +155,8 @@ class App extends React.Component<Props, State> {
key: Math.random().toString(),
loaded: true,
active: true,
- tab: message.tab
+ tab: message.tab,
+ propertyPlaceholders: message.propertyPlaceholders
});
}
break;
@@ -219,6 +222,7 @@ class App extends React.Component<Props, State> {
if (code === undefined || code.length === 0) code = TemplateApi.generateCode(javaType, name);
return new Promise<string | undefined>(resolve => resolve(code))
}}
+ propertyPlaceholders={this.state.propertyPlaceholders}
/>
}
{loaded && page === "knowledgebase" && <KnowledgebasePage dark={dark} />}