@@ -3,6 +3,7 @@ import yaml from 'js-yaml';
33import { KnowledgeYamlData , SkillYamlData } from '@/types' ;
44import { DropEvent , MultipleFileUpload , MultipleFileUploadMain } from '@patternfly/react-core' ;
55import { UploadIcon } from '@patternfly/react-icons' ;
6+ import { ActionGroupAlertContent } from './Knowledge/Github' ;
67
78interface readFile {
89 fileName : string ;
@@ -16,13 +17,15 @@ interface YamlFileUploadProps {
1617 isKnowledgeForm : boolean ;
1718 onYamlUploadKnowledgeFillForm ?: ( data : KnowledgeYamlData ) => void ;
1819 onYamlUploadSkillsFillForm ?: ( data : SkillYamlData ) => void ;
20+ setActionGroupAlertContent : React . Dispatch < React . SetStateAction < ActionGroupAlertContent | undefined > > ;
1921}
2022
2123const YamlFileUpload : React . FC < YamlFileUploadProps > = ( {
2224 setIsModalOpen,
2325 isKnowledgeForm,
2426 onYamlUploadKnowledgeFillForm,
25- onYamlUploadSkillsFillForm
27+ onYamlUploadSkillsFillForm,
28+ setActionGroupAlertContent
2629} ) => {
2730 const [ currentFiles , setCurrentFiles ] = React . useState < File [ ] > ( [ ] ) ;
2831 const [ readFileData , setReadFileData ] = React . useState < readFile [ ] > ( [ ] ) ;
@@ -51,9 +54,23 @@ const YamlFileUpload: React.FC<YamlFileUploadProps> = ({
5154 onYamlUploadSkillsFillForm ?.( parsedData ) ;
5255 setIsModalOpen ( false ) ;
5356 } else {
57+ const yamlFileSchemaIssueAlertContent : ActionGroupAlertContent = {
58+ title : 'YAML file upload error!' ,
59+ message : `This yaml file does not match the Skills or Knowledge schema.` ,
60+ success : false ,
61+ timeout : false
62+ } ;
63+ setActionGroupAlertContent ( yamlFileSchemaIssueAlertContent ) ;
5464 console . error ( 'This yaml file does not match the Skills or Knowledge schema' ) ;
5565 }
5666 } catch ( error ) {
67+ const yamlFileParsingIssueAlertContent : ActionGroupAlertContent = {
68+ title : 'YAML file upload error!' ,
69+ message : `This yaml file is not correct and cannot be parsed.` ,
70+ success : false ,
71+ timeout : false
72+ } ;
73+ setActionGroupAlertContent ( yamlFileParsingIssueAlertContent ) ;
5774 console . error ( 'Error parsing YAML file:' , error ) ;
5875 }
5976 } ;
0 commit comments