Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mgubaidullin committed May 8, 2024
1 parent 6de2bd3 commit 501582d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 3 additions & 7 deletions karavan-app/src/main/webui/src/editor/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,23 @@ 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), []);

useEffect(() => {
const interval = setInterval(() => {
saveCode();
}, 3000);
}, 700);
return () => {
clearInterval(interval);
saveCode();
Expand Down
9 changes: 9 additions & 0 deletions karavan-app/src/main/webui/src/util/StringUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('}', ''));
}

0 comments on commit 501582d

Please sign in to comment.