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 8a7b9159 Fix for #914
8a7b9159 is described below
commit 8a7b9159450e754e2166bdd8dd273d880c90bd79
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Wed Sep 27 18:39:42 2023 -0400
Fix for #914
---
.../src/main/webui/src/project/files/CreateFileModal.tsx | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git
a/karavan-web/karavan-app/src/main/webui/src/project/files/CreateFileModal.tsx
b/karavan-web/karavan-app/src/main/webui/src/project/files/CreateFileModal.tsx
index e24c7279..36dc24ea 100644
---
a/karavan-web/karavan-app/src/main/webui/src/project/files/CreateFileModal.tsx
+++
b/karavan-web/karavan-app/src/main/webui/src/project/files/CreateFileModal.tsx
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import React, {useState} from 'react';
+import React, {useEffect, useState} from 'react';
import {
Button,
Modal,
@@ -42,7 +42,13 @@ export function CreateFileModal (props: Props) {
const [project] = useProjectStore((s) => [s.project], shallow);
const [operation, setFile] = useFileStore((s) => [s.operation, s.setFile],
shallow);
const [name, setName] = useState<string>( '');
- const [fileType, setFileType] = useState<string>(props.types.at(0) ||
'INTEGRATION');
+ const [fileType, setFileType] = useState<string>();
+
+ useEffect(() => {
+ if (props.types.length > 0) {
+ setFileType(props.types[0]);
+ }
+ }, [props]);
function cleanValues() {
setName("");
@@ -76,7 +82,7 @@ export function CreateFileModal (props: Props) {
return title.replace(/[^0-9a-zA-Z.]+/gi, "-").toLowerCase();
}
- const extension = ProjectFileTypes.filter(value => value.name ===
fileType)[0].extension;
+ const extension = ProjectFileTypes.filter(value => value.name ===
fileType)[0]?.extension;
const filename = (extension !== 'java')
? fileNameCheck(name)
: CamelUi.javaNameFromTitle(name)