Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save project as gist #114

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions gui/src/app/pages/HomePage/ExportWindow.tsx

This file was deleted.

44 changes: 22 additions & 22 deletions gui/src/app/pages/HomePage/LeftPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import ModalWindow, { useModalWindow } from "@fi-sci/modal-window";
import { FunctionComponent, useCallback, useContext } from "react";
import examplesStanies, { Stanie } from "../../exampleStanies/exampleStanies";
import { ProjectContext } from "../../Project/ProjectContextProvider";
import ExportWindow from "./ExportWindow";
import ImportWindow from "./ImportWindow";
import SaveProjectWindow from "./SaveProjectWindow";
import LoadProjectWindow from "./LoadProjectWindow";
import { ChevronLeft, ChevronRight } from "@mui/icons-material";

type LeftPanelProps = {
Expand Down Expand Up @@ -33,14 +33,14 @@ const LeftPanel: FunctionComponent<LeftPanelProps> = ({
);

const {
visible: exportVisible,
handleOpen: exportOpen,
handleClose: exportClose,
visible: saveProjectVisible,
handleOpen: saveProjectOpen,
handleClose: saveProjectClose,
} = useModalWindow();
const {
visible: importVisible,
handleOpen: importOpen,
handleClose: importClose,
visible: loadProjectVisible,
handleOpen: loadProjectOpen,
handleClose: loadProjectClose,
} = useModalWindow();

if (collapsed) {
Expand Down Expand Up @@ -82,6 +82,16 @@ const LeftPanel: FunctionComponent<LeftPanelProps> = ({
</div>
))}
<hr />
<div>
<button onClick={loadProjectOpen} disabled={hasUnsavedChanges}>
Load project
</button>
&nbsp;
<button onClick={saveProjectOpen} disabled={hasUnsavedChanges}>
Save project
</button>
</div>
<div>&nbsp;</div>
<div>
{/* This will probably be removed or replaced in the future. It's just for convenience during development. */}
<button
Expand All @@ -96,22 +106,12 @@ const LeftPanel: FunctionComponent<LeftPanelProps> = ({
Clear all
</button>
</div>
<div>&nbsp;</div>
<div>
<button onClick={importOpen} disabled={hasUnsavedChanges}>
Import
</button>
&nbsp;
<button onClick={exportOpen} disabled={hasUnsavedChanges}>
Export
</button>
</div>
</div>
<ModalWindow visible={importVisible} onClose={importClose}>
<ImportWindow onClose={importClose} />
<ModalWindow visible={loadProjectVisible} onClose={loadProjectClose}>
<LoadProjectWindow onClose={loadProjectClose} />
</ModalWindow>
<ModalWindow visible={exportVisible} onClose={exportClose}>
<ExportWindow onClose={exportClose} />
<ModalWindow visible={saveProjectVisible} onClose={saveProjectClose}>
<SaveProjectWindow onClose={saveProjectClose} />
</ModalWindow>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import {
} from "../../Project/ProjectSerialization";
import UploadFilesArea from "./UploadFilesArea";

type ImportWindowProps = {
type LoadProjectWindowProps = {
onClose: () => void;
};

const ImportWindow: FunctionComponent<ImportWindowProps> = ({ onClose }) => {
const LoadProjectWindow: FunctionComponent<LoadProjectWindowProps> = ({
onClose,
}) => {
const { update } = useContext(ProjectContext);
const [errorText, setErrorText] = useState<string | null>(null);
const [filesUploaded, setFilesUploaded] = useState<
Expand Down Expand Up @@ -105,7 +107,7 @@ const ImportWindow: FunctionComponent<ImportWindowProps> = ({ onClose }) => {

return (
<div>
<h3>Import project</h3>
<h3>Load project</h3>
<div>
You can upload:
<ul>
Expand All @@ -132,18 +134,18 @@ const ImportWindow: FunctionComponent<ImportWindowProps> = ({ onClose }) => {
{showReplaceProjectOptions && (
<div>
<button onClick={() => importUploadedFiles({ replaceProject: true })}>
Import into a NEW project
Load into a NEW project
</button>
&nbsp;
<button
onClick={() => importUploadedFiles({ replaceProject: false })}
>
Import into EXISTING project
Load into EXISTING project
</button>
</div>
)}
</div>
);
};

export default ImportWindow;
export default LoadProjectWindow;
Loading