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 501582d4 fix
501582d4 is described below
commit 501582d4e1c85d868aaaa26bfcae2f04f3ec9e96
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Wed May 8 12:15:59 2024 -0400
fix
---
karavan-app/src/main/webui/src/editor/CodeEditor.tsx | 10 +++-------
karavan-app/src/main/webui/src/util/StringUtils.ts | 9 +++++++++
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/karavan-app/src/main/webui/src/editor/CodeEditor.tsx
b/karavan-app/src/main/webui/src/editor/CodeEditor.tsx
index 3ff9d5ba..7e5e007a 100644
--- a/karavan-app/src/main/webui/src/editor/CodeEditor.tsx
+++ b/karavan-app/src/main/webui/src/editor/CodeEditor.tsx
@@ -21,19 +21,15 @@ import {useFileStore} from "../api/ProjectStore";
import {ProjectService} from "../api/ProjectService";
import {shallow} from "zustand/shallow";
-interface Props {
- projectId: string
-}
-
const languages = new Map<string, string>([
['sh', 'shell'],
['md', 'markdown'],
['properties', 'ini']
])
-export function CodeEditor(props: Props) {
+export function CodeEditor() {
- const [file, designerTab, setFile] = useFileStore((s) => [s.file,
s.designerTab, s.setFile], shallow)
+ const [file] = useFileStore((s) => [s.file], shallow)
const [code, setCode] = useState<string>();
useEffect(() => setCode(file?.code), []);
@@ -41,7 +37,7 @@ export function CodeEditor(props: Props) {
useEffect(() => {
const interval = setInterval(() => {
saveCode();
- }, 3000);
+ }, 700);
return () => {
clearInterval(interval);
saveCode();
diff --git a/karavan-app/src/main/webui/src/util/StringUtils.ts
b/karavan-app/src/main/webui/src/util/StringUtils.ts
index 0c32809b..3aef90ab 100644
--- a/karavan-app/src/main/webui/src/util/StringUtils.ts
+++ b/karavan-app/src/main/webui/src/util/StringUtils.ts
@@ -11,3 +11,12 @@ export function isValidProjectId(input: string): boolean {
const pattern = /^[a-z][a-z0-9-]*$/;
return pattern.test(input);
}
+
+export function splitByBraces(input: string): string[] {
+ const regex = /{[^{}]*}|[^{}]+/g;
+ return input.match(regex) ?? [];
+}
+
+export function getPathParams(input: string): string[] {
+ return splitByBraces(input).filter(p => p.startsWith('{')).map(p =>
p.replace('{', '').replace('}', ''));
+}
\ No newline at end of file