import React from 'react'; import { CodeEditor, Language } from '@patternfly/react-code-editor'; import { Text, Form, FormGroup, FormHelperText, Title, Alert, HelperText, HelperTextItem, } from '@patternfly/react-core'; import { useAppDispatch, useAppSelector } from '../../../../store/hooks'; import { selectFirstBootScript, setFirstBootScript, } from '../../../../store/wizardSlice'; import { useFirstBootValidation } from '../../utilities/useValidation'; const detectScriptType = (scriptString: string): Language => { const lines = scriptString.split('\n'); if (lines[0].startsWith('#!')) { // Extract the path from the shebang const path = lines[0].slice(2); if (path.includes('bin/bash') || path.includes('bin/sh')) { return Language.shell; } else if (path.includes('bin/python') || path.includes('bin/python3')) { return Language.python; } else if (path.includes('ansible-playbook')) { return Language.yaml; } } // default return Language.shell; }; const FirstBootStep = () => { const dispatch = useAppDispatch(); const selectedScript = useAppSelector(selectFirstBootScript); const language = detectScriptType(selectedScript); const { errors } = useFirstBootValidation(); return (
); }; export default FirstBootStep;