import React from "react"
import {
Avatar,
Box,
Button,
Typography,
Tooltip,
} from "@mui/material"
import { useNavigate } from "react-router";
import theme from "../theme.jsx";
import {
Lock as LockIcon,
} from '@mui/icons-material';
// onclickHandler = function override from parent onclick
const RecentWorkflow = ({ workflow, onclickHandler, leftNavOpen, currentWorkflowId, }) => {
const navigate = useNavigate();
const [hovered, setHovered] = React.useState(false)
if (workflow === undefined || workflow === null) {
console.log("No workflow")
return null
}
/*
* Note for @Lalit:
*
* When you want to make a list of something that is complex,
* make a component. This way, you can easily manage
* the logic, and we can actually reuse it. This component is used
* multiple places, so do make sure to not break it randomly.
*/
const expandLeftNav = leftNavOpen === true || leftNavOpen === undefined ? true : false
// Check if workflow.input_markdown has an image in it
// If it does, show it as the main thing
//
var relevantImageUrl = ""
if (workflow.input_markdown !== undefined && workflow.input_markdown !== null && workflow.input_markdown !== "") {
// Look for tag or  markdown
// html > markdown
const imgTag = workflow.input_markdown.match(/
]+>/g)
if (imgTag !== null) {
const src = imgTag[0].match(/src="([^"]+)"/)
if (src !== null) {
relevantImageUrl = src[1]
}
} else {
const markdownTag = workflow.input_markdown.match(/!\[.*\]\(.*\)/g)
if (markdownTag !== null) {
const src = markdownTag[0].match(/\(([^)]+)\)/)
if (src !== null) {
relevantImageUrl = src[1]
}
}
}
}
return (