import { Modal, Icon, Message} from 'semantic-ui-react'
import {ReactComponent as Gradio} from '../../../src/images/gradio.svg'
import {ReactComponent as Streamlit} from '../../../src/images/streamlit.svg'
import {ReactComponent as Exit} from '../../../src/images/exit.svg'
import { useState } from 'react'
import {BsSearch} from 'react-icons/bs';
export default function Import(props){
const [tab, setTab] = useState("gradio")
const [subTab, setSubTab] = useState(0)
return (
- {
setTab("gradio")
props.catch ? props.handelError(false) : props.handelError(props.catch) }}>
- {
setTab("streamlit")
props.catch ? props.handelError(false) : props.handelError(props.catch) }}>
{
props.quitHandeler(false)
props.catch ? props.handelError(false) : props.handelError(props.catch) }}>
{ tab === "gradio" &&
- {
setSubTab(0)
props.catch ? props.handelError(false) : props.handelError(props.catch) }}>
- {
setSubTab(1)
props.catch ? props.handelError(false) : props.handelError(props.catch) }}>
{subTab === 0 &&
}
{subTab === 1 &&
}
{props.catch &&
🚫 Something went wrong...
🤔 Possible Things That could of happen
- - The input was empty
- - The connection was forbidden
- - The name was already taken
- - The link you gave did not pass the regex
- - http://localhost:xxxx
- - http://xxxxx.gradio.app
- - https://hf.space/embed/$user/$space_name/+
- - link already exist within the menu
}
}
{ tab === "streamlit" &&
}
)
}
function Local(props){
return (
🏗️ Comming soon...
This tab will allow you grab your function from a given directory and build
your own tabular module gradio functions
)
}
function Shared(props){
const [preview, setPreview] = useState("")
const [fetchable, setFetch] = useState(false)
const isFetchable = async (url) => {
const pattern = {
share : new RegExp("^https?:\\/\\/([0-9a-zA-Z-]+)\\.gradio\\.live\\/?"),
hugginFace : new RegExp("^https?:\\/\\/([a-zA-Z0-9-]+)-gradio\\.hf\\.space\\/?$")
}
if (!pattern.share.test(url) &&
!pattern.hugginFace.test(url)){
setFetch(false)
return
}
fetch(url, {mode : "no-cors"}).then((re) => {
console.log(re)
if(re.url.includes("http://localhost:3000")){
setFetch(false)
} else {
setFetch(true)
props.catch ? props.handelError(false) : props.handelError(props.catch)
}
}).catch((err)=>{
setFetch(false)
})
setFetch(false)
}
return (
{
if (e.key.includes("Enter")) props.appendHandler(props.type)
}}>
)
}