summaryrefslogtreecommitdiff
path: root/frontend/src/containers/modals/NewExperimentModal.js
blob: c703c39a0cddcf356e484f4393cdcd11fbeda3bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { connect } from "react-redux";
import { addExperiment } from "../../actions/experiments";
import { closeNewExperimentModal } from "../../actions/modals/experiments";
import NewExperimentModalComponent from "../../components/modals/custom-components/NewExperimentModalComponent";

const mapStateToProps = state => {
  return {
    show: state.modals.newExperimentModalVisible,
    paths: Object.values(state.objects.path).filter(
      path => path.simulationId === state.currentSimulationId
    ),
    traces: Object.values(state.objects.trace),
    schedulers: Object.values(state.objects.scheduler)
  };
};

const mapDispatchToProps = dispatch => {
  return {
    callback: (name, pathId, traceId, schedulerName) => {
      if (name) {
        dispatch(
          addExperiment({
            name,
            pathId,
            traceId,
            schedulerName
          })
        );
      }
      dispatch(closeNewExperimentModal());
    }
  };
};

const NewExperimentModal = connect(mapStateToProps, mapDispatchToProps)(
  NewExperimentModalComponent
);

export default NewExperimentModal;