diff --git a/src/App.css b/src/App.css index f03baa79..9507d94d 100644 --- a/src/App.css +++ b/src/App.css @@ -26,6 +26,10 @@ padding: 0 40px; } +.load-button { + margin-right: 20px; +} + .footer { display: flex; flex-direction: row; diff --git a/src/App.tsx b/src/App.tsx index c330ada3..f9535e72 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; import { v4 as uuidv4 } from "uuid"; -import { Layout, Typography } from "antd"; +import { Button, Layout, Typography } from "antd"; import { getJobStatus, addRecipe } from "./utils/firebase"; import { getFirebaseRecipe, jsonToString } from "./utils/recipeLoader"; import { getSubmitPackingUrl, JOB_STATUS } from "./constants/aws"; @@ -15,6 +15,7 @@ import { useSetPackingResults, } from "./state/store"; import PackingInput from "./components/PackingInput"; +import UploadModal from "./components/UploadModal"; import Viewer from "./components/Viewer"; import StatusBar from "./components/StatusBar"; @@ -25,6 +26,7 @@ const { Link } = Typography; function App() { const [jobStatus, setJobStatus] = useState(""); + const [isModalOpen, setIsModalOpen] = useState(false); const setJobLogs = useSetJobLogs(); const jobLogs = useJobLogs(); @@ -40,10 +42,13 @@ function App() { return new Promise((resolve) => setTimeout(resolve, ms)); } - const recipeHasChanged = async ( + const isUploadNeeded = async ( recipeId: string, recipeString: string ): Promise => { + if (!recipeId) { + return true; + } const originalRecipe = await getFirebaseRecipe(recipeId); return !(jsonToString(originalRecipe) == recipeString); }; @@ -73,11 +78,11 @@ function App() { const firebaseConfig = configId ? "firebase:configs/" + configId : undefined; - const recipeChanged: boolean = await recipeHasChanged( + const uploadNeeded: boolean = await isUploadNeeded( recipeId, recipeString ); - if (recipeChanged) { + if (uploadNeeded) { const recipeId = uuidv4(); firebaseRecipe = "firebase:recipes_edited/" + recipeId; const recipeJson = recipeToFirebase( @@ -156,6 +161,14 @@ function App() { } }; + const showUploadDialog = () => { + setIsModalOpen(true); + }; + + const handleModalClose = () => { + setIsModalOpen(false); + }; + return (

cellPACK Studio

- - GitHub - +
+ + + GitHub + +
+ diff --git a/src/components/LocalRecipe/index.tsx b/src/components/LocalRecipe/index.tsx new file mode 100644 index 00000000..0cad6f13 --- /dev/null +++ b/src/components/LocalRecipe/index.tsx @@ -0,0 +1,45 @@ +import { Button, Input } from 'antd'; +import { CloseOutlined } from '@ant-design/icons' +import { useLocalRecipeString, useSetLocalRecipe } from '../../state/store'; + +import "./style.css"; + +const { TextArea } = Input; + +interface LocalRecipeProps { + startPacking: (recipeId: string, configId: string, recipeString: string) => Promise; + maxHeight?: number; +} + +const LocalRecipe: React.FC = ({ startPacking, maxHeight }) => { + const localRecipeString = useLocalRecipeString(); + const setLocalRecipe = useSetLocalRecipe(); + + const closeLocalRecipe = () => { + setLocalRecipe(undefined); + }; + + if (!localRecipeString) { + return
No local recipe loaded.
; + } + return ( +
+
+

Uploaded Recipe

+
+