import React, { useState, useEffect, useRef } from 'react'; import { IconLoader2, IconFileImport } from '@tabler/icons'; import { toastError } from 'utils/common/error'; import Modal from 'components/Modal'; import jsyaml from 'js-yaml'; import { postmanToBruno, isPostmanCollection } from 'utils/importers/postman-collection'; import { convertInsomniaToBruno, isInsomniaCollection } from 'utils/importers/insomnia-collection'; import { convertOpenapiToBruno, isOpenApiSpec } from 'utils/importers/openapi-collection'; import { processBrunoCollection } from 'utils/importers/bruno-collection'; const convertFileToObject = async (file) => { const text = await file.text(); try { if (file.type === 'application/json' || file.name.endsWith('.json')) { return JSON.parse(text); } const parsed = jsyaml.load(text); if (typeof parsed !== 'object' || parsed === null) { throw new Error(); } return parsed; } catch { throw new Error('Failed to parse the file – ensure it is valid JSON or YAML'); } }; const FullscreenLoader = ({ isLoading }) => { const [loadingMessage, setLoadingMessage] = useState(''); // Messages to cycle through while loading const loadingMessages = [ 'Processing collection...', 'Analyzing requests...', 'Translating scripts...', 'Preparing collection...', 'Almost done...' ]; useEffect(() => { if (!isLoading) return; let messageIndex = 0; const interval = setInterval(() => { messageIndex = (messageIndex + 1) % loadingMessages.length; setLoadingMessage(loadingMessages[messageIndex]); }, 2000); setLoadingMessage(loadingMessages[0]); return () => clearInterval(interval); }, [isLoading]); return (
This may take a moment depending on the collection size
Drop file to import or{' '}
Supports Bruno, Postman, Insomnia, and OpenAPI v3 formats