From a18605f27f75cc1b1ce61cdbf911547d2616444e Mon Sep 17 00:00:00 2001 From: Mario Volf Date: Sat, 2 Dec 2023 16:28:34 +0100 Subject: [PATCH] Fix for #995 (#1007) --- .../src/main/java/org/apache/camel/karavan/util/StringUtils.ts | 3 +++ .../src/main/webui/src/projects/CreateProjectModal.tsx | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/util/StringUtils.ts diff --git a/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/util/StringUtils.ts b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/util/StringUtils.ts new file mode 100644 index 00000000000..5bf90a49d52 --- /dev/null +++ b/karavan-web/karavan-app/src/main/java/org/apache/camel/karavan/util/StringUtils.ts @@ -0,0 +1,3 @@ +export function isEmpty(str: string) { + return str === null || str === undefined || str.trim() === ''; +} \ No newline at end of file diff --git a/karavan-web/karavan-app/src/main/webui/src/projects/CreateProjectModal.tsx b/karavan-web/karavan-app/src/main/webui/src/projects/CreateProjectModal.tsx index f4320e721d0..0281cb82a5b 100644 --- a/karavan-web/karavan-app/src/main/webui/src/projects/CreateProjectModal.tsx +++ b/karavan-web/karavan-app/src/main/webui/src/projects/CreateProjectModal.tsx @@ -27,6 +27,7 @@ import {ProjectService} from "../api/ProjectService"; import {Project} from "../api/ProjectModels"; import {CamelUi} from "../designer/utils/CamelUi"; import {shallow} from "zustand/shallow"; +import {isEmpty} from "../../../java/org/apache/camel/karavan/util/StringUtils"; export function CreateProjectModal () { @@ -55,7 +56,7 @@ export function CreateProjectModal () { } function onKeyDown(event: React.KeyboardEvent): void { - if (event.key === 'Enter' && name !== undefined && description !== undefined && projectId !== undefined) { + if (event.key === 'Enter' && !isEmpty(name) && !isEmpty(description) && !isEmpty(projectId)) { confirmAndCloseModal(); } }