diff --git a/frontend/src/components/AppModal.jsx b/frontend/src/components/AppModal.jsx new file mode 100644 index 00000000..d2de9d74 --- /dev/null +++ b/frontend/src/components/AppModal.jsx @@ -0,0 +1,311 @@ +import React from 'react'; +import { + Dialog, + DialogTitle, + DialogContent, + IconButton, + Typography, + Box, + Button, + Stack, + Avatar, +} from '@mui/material'; + +import CloseIcon from '@mui/icons-material/Close'; +import EditIcon from '@mui/icons-material/Edit'; +import ForkRightIcon from '@mui/icons-material/ForkRight'; +import OpenInNewIcon from '@mui/icons-material/OpenInNew'; +import LaunchIcon from '@mui/icons-material/Launch'; +import CheckCircleIcon from '@mui/icons-material/CheckCircle'; +import { CloudDownloadOutlined } from '@mui/icons-material'; + +const AppModal = ({ open, onClose, data, userdata }) => { + + console.log("App data: ", data) + console.log("userdata: ", userdata) + + const isCloud = + window.location.host === "localhost:3002" || + window.location.host === "shuffler.io" || window.location.host === "localhost:3000" + ? true + : false; + + var newAppname = data?.name; + if (newAppname === undefined) { + newAppname = "Undefined"; + } else { + newAppname = newAppname.charAt(0).toUpperCase() + newAppname.substring(1); + newAppname = newAppname.replaceAll("_", " "); + } + + var canEditApp = userdata.admin === "true" || userdata.id === data?.owner || data?.owner === "" || (userdata.admin === "true" && userdata.active_org.id === data?.reference_org) || !data?.generated + + + return ( + + + + About Gmail + + + + + + + + + + + + + + + {newAppname} + + { + isCloud && ( + + + + + + ) + } + + + {data?.categories ? data.categories.join(", ") : "Communication"} + + + + + + + + : + } + > + {canEditApp ? "Edit" : "Fork"} + + + + + + + + 20 + + + Public Workflow + + + + + {data?.actions?.length} + + + Actions + + + + + + + Google Collection + + + + Part of a collection + + + + + + + Connect Gmail to Jira + + + + + + + + + Email management + + + + + + + Create a Usecase + + + + + ); +}; + +export default AppModal; \ No newline at end of file diff --git a/frontend/src/views/Apps2.jsx b/frontend/src/views/Apps2.jsx index 079d4b2e..01d9ad26 100644 --- a/frontend/src/views/Apps2.jsx +++ b/frontend/src/views/Apps2.jsx @@ -25,6 +25,7 @@ import { toast } from "react-toastify"; import algoliasearch from "algoliasearch/lite"; import { debounce } from "lodash"; import AppSelection from "../components/AppSelection.jsx"; +import AppModal from "../components/AppModal.jsx"; const searchClient = algoliasearch( @@ -33,7 +34,7 @@ const searchClient = algoliasearch( ); // AppCard Component -const AppCard = ({ data, index, mouseHoverIndex, setMouseHoverIndex, globalUrl, deactivatedIndexes, currTab }) => { +const AppCard = ({ data, index, mouseHoverIndex, setMouseHoverIndex, globalUrl, deactivatedIndexes, currTab, handleAppClick }) => { const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io" || window.location.host === "localhost:3000"; const appUrl = isCloud ? `/apps/${data.id}` : `https://shuffler.io/apps/${data.id}`; @@ -51,12 +52,12 @@ const AppCard = ({ data, index, mouseHoverIndex, setMouseHoverIndex, globalUrl, return ( - setMouseHoverIndex(index)} + setMouseHoverIndex(index)} onMouseOut={() => setMouseHoverIndex(-1)} > - {/* Deactivate button */} {currTab === 0 && !deactivatedIndexes.includes(index) && mouseHoverIndex === index && data.generated === true && ( - { @@ -569,7 +570,7 @@ const SearchBox = ({ refine, searchQuery, setSearchQuery }) => { setSearchQuery(value); removeQuery("q"); refine(value); - }, 300) // Adjust the delay as needed + }, 300) ).current; useEffect(() => { @@ -702,8 +703,8 @@ const Apps2 = (props) => { const [mouseHoverIndex, setMouseHoverIndex] = useState(-1); var counted = 0; const [showNoAppFound, setShowNoAppFound] = useState(false); - - + const [openModal, setOpenModal] = useState(false); + const [selectedApp, setSelectedApp] = useState(null); const [appFramework, setAppFramework] = useState(undefined); const [defaultSearch, setDefaultSearch] = useState(""); // Set the current tab based on the query parameter @@ -799,6 +800,7 @@ const Apps2 = (props) => { } }; + // Only fetch if we have required data if (globalUrl && (currTab === 0 || (currTab === 1 && userdata?.id))) { fetchApps(); @@ -883,7 +885,7 @@ const Apps2 = (props) => { const handleCreateApp = (e) => { e.preventDefault(); - console.log("Create app clicked") + setOpenModal(true); }; @@ -968,9 +970,23 @@ const Apps2 = (props) => { setSelectedLabel(value); }; + const handleAppClick = (app) => { + setSelectedApp(app); + setOpenModal(true); + } + + const handleAppModalClose = () => { + setOpenModal(false) + } return ( + Apps @@ -1103,7 +1119,7 @@ const Apps2 = (props) => { {appsToShow?.length > 0 && appsToShow !== undefined && !isLoading ? ( {appsToShow.map((data, index) => ( - + ))} ) : ( @@ -1137,7 +1153,7 @@ const Apps2 = (props) => { {appsToShow?.length > 0 && appsToShow !== undefined ? ( {appsToShow.map((data, index) => ( - + ))} ) : (