Skip to content

Commit

Permalink
xchem#16 create init snapshot and restore from given snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
tibor-postek-m2ms committed Mar 26, 2020
1 parent 7de76b8 commit 1d4c854
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
15 changes: 7 additions & 8 deletions js/components/projects/addProjectDetail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const AddProjectDetail = memo(() => {

return (
<>
<Typography variant="h3">Add Project Detail</Typography>
<Typography variant="h3">Project Details</Typography>
<Formik
initialValues={{
title: '',
Expand All @@ -73,15 +73,14 @@ export const AddProjectDetail = memo(() => {
}}
onSubmit={values => {
const data = {
...values,
author: {
username: DJANGO_CONTEXT['username'],
email: DJANGO_CONTEXT['email']
},
tags
title: values.title,
description: values.description,
target: targetId,
author: DJANGO_CONTEXT['pk'] || null,
tags: JSON.stringify(tags)
};
dispatch(setProjectModalIsLoading(true));
api({ url: `${base_url}/api/project`, method: METHOD.POST, data })
api({ url: `${base_url}/api/session-projects/`, method: METHOD.POST, data })
.then(response => {
const projectID = response.data.id;
dispatch(setCurrentProjectProperty('projectID', projectID));
Expand Down
6 changes: 5 additions & 1 deletion js/components/snapshot/modals/newSnapshotForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React, { memo, useState } from 'react';
import { Typography } from '@material-ui/core';
import { useSelector } from 'react-redux';

export const NewSnapshotForm = memo(() => {
return;
const snapshotID = useSelector(state => state.projectReducers.currentSnapshot.id);
// TODO if exists children of existing snapshot, create branch
return <Typography variant="h3">Snapshot details</Typography>;
});
13 changes: 4 additions & 9 deletions js/components/snapshot/modals/newSnapshotModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ import React, { memo } from 'react';
import Modal from '../../common/Modal';
import { useDispatch, useSelector } from 'react-redux';
import { setOpenSnapshotSavingDialog } from '../redux/actions';
import { Typography } from '@material-ui/core';
import { NewSnapshotForm } from './newSnapshotForm';
import { AddProjectDetail } from '../../projects/addProjectDetail';
import { useRouteMatch } from 'react-router-dom';

export const NewSnapshotModal = memo(({}) => {
const dispatch = useDispatch();
const openSavingDialog = useSelector(state => state.snapshotReducers.openSavingDialog);
const dialogCurrentStep = useSelector(state => state.snapshotReducers.dialogCurrentStep);
const currectProject = useSelector(state => state.projectReducers.currentProject);
let match = useRouteMatch();

const projectId = (match && match.params && match.params.projectId) || (currectProject && currectProject.projectID);
const projectID = useSelector(state => state.projectReducers.currentProject.projectID);

const handleCloseModal = () => {
dispatch(setOpenSnapshotSavingDialog(false));
Expand All @@ -22,9 +18,8 @@ export const NewSnapshotModal = memo(({}) => {
return (
<>
<Modal open={openSavingDialog} onClose={handleCloseModal}>
{projectId && <Typography variant="h3">Save Session</Typography>}
{!projectId && dialogCurrentStep === 0 && <AddProjectDetail />}
{!projectId && dialogCurrentStep === 1 && <AddProjectDetail />}
{!projectID && dialogCurrentStep === 0 && <AddProjectDetail />}
{projectID && <NewSnapshotForm />}
</Modal>
</>
);
Expand Down

0 comments on commit 1d4c854

Please sign in to comment.