From 90fae26aa4bd0e0eb3272ff6e6524060e9004fbb Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Mon, 29 Jun 2020 15:47:09 +0200 Subject: Prepare frontend repository for monorepo This change prepares the frontend Git repository for the monorepo residing at https://github.com/atlarge-research.com/opendc. To accomodate for this, we move all files into a frontend subdirectory. --- src/components/modals/ConfirmationModal.js | 37 ------ src/components/modals/Modal.js | 132 --------------------- src/components/modals/TextInputModal.js | 58 --------- .../NewExperimentModalComponent.js | 104 ---------------- 4 files changed, 331 deletions(-) delete mode 100644 src/components/modals/ConfirmationModal.js delete mode 100644 src/components/modals/Modal.js delete mode 100644 src/components/modals/TextInputModal.js delete mode 100644 src/components/modals/custom-components/NewExperimentModalComponent.js (limited to 'src/components/modals') diff --git a/src/components/modals/ConfirmationModal.js b/src/components/modals/ConfirmationModal.js deleted file mode 100644 index abdce5ac..00000000 --- a/src/components/modals/ConfirmationModal.js +++ /dev/null @@ -1,37 +0,0 @@ -import PropTypes from "prop-types"; -import React from "react"; -import Modal from "./Modal"; - -class ConfirmationModal extends React.Component { - static propTypes = { - title: PropTypes.string.isRequired, - message: PropTypes.string.isRequired, - show: PropTypes.bool.isRequired, - callback: PropTypes.func.isRequired - }; - - onConfirm() { - this.props.callback(true); - } - - onCancel() { - this.props.callback(false); - } - - render() { - return ( - - {this.props.message} - - ); - } -} - -export default ConfirmationModal; diff --git a/src/components/modals/Modal.js b/src/components/modals/Modal.js deleted file mode 100644 index 19337db8..00000000 --- a/src/components/modals/Modal.js +++ /dev/null @@ -1,132 +0,0 @@ -import classNames from "classnames"; -import PropTypes from "prop-types"; -import React from "react"; -import jQuery from "../../util/jquery"; - -class Modal extends React.Component { - static propTypes = { - title: PropTypes.string.isRequired, - show: PropTypes.bool.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired, - submitButtonType: PropTypes.string, - submitButtonText: PropTypes.string - }; - static defaultProps = { - submitButtonType: "primary", - submitButtonText: "Save" - }; - static idCounter = 0; - - // Local, up-to-date copy of modal visibility for time between close event and a props update (to prevent duplicate - // 'close' triggers) - visible = false; - - constructor(props) { - super(props); - this.id = "modal-" + Modal.idCounter++; - } - - componentDidMount() { - this.visible = this.props.show; - this.openOrCloseModal(); - - // Trigger auto-focus - jQuery("#" + this.id) - .on("shown.bs.modal", function() { - jQuery(this) - .find("input") - .first() - .focus(); - }) - .on("hide.bs.modal", () => { - if (this.visible) { - this.props.onCancel(); - } - }) - .on("keydown", e => { - e.stopPropagation(); - }); - } - - componentDidUpdate() { - this.visible = this.props.show; - this.openOrCloseModal(); - } - - onSubmit() { - if (this.visible) { - this.props.onSubmit(); - this.visible = false; - this.closeModal(); - } - } - - onCancel() { - if (this.visible) { - this.props.onCancel(); - this.visible = false; - this.closeModal(); - } - } - - openModal() { - jQuery("#" + this.id).modal("show"); - } - - closeModal() { - jQuery("#" + this.id).modal("hide"); - } - - openOrCloseModal() { - if (this.visible) { - this.openModal(); - } else { - this.closeModal(); - } - } - - render() { - return ( - - ); - } -} - -export default Modal; diff --git a/src/components/modals/TextInputModal.js b/src/components/modals/TextInputModal.js deleted file mode 100644 index cc16f8e1..00000000 --- a/src/components/modals/TextInputModal.js +++ /dev/null @@ -1,58 +0,0 @@ -import PropTypes from "prop-types"; -import React from "react"; -import Modal from "./Modal"; - -class TextInputModal extends React.Component { - static propTypes = { - title: PropTypes.string.isRequired, - label: PropTypes.string.isRequired, - show: PropTypes.bool.isRequired, - callback: PropTypes.func.isRequired, - initialValue: PropTypes.string - }; - - componentDidUpdate() { - if (this.props.initialValue) { - this.textInput.value = this.props.initialValue; - } - } - - onSubmit() { - this.props.callback(this.textInput.value); - this.textInput.value = ""; - } - - onCancel() { - this.props.callback(undefined); - this.textInput.value = ""; - } - - render() { - return ( - -
{ - e.preventDefault(); - this.onSubmit(); - }} - > -
- - (this.textInput = textInput)} - /> -
-
-
- ); - } -} - -export default TextInputModal; diff --git a/src/components/modals/custom-components/NewExperimentModalComponent.js b/src/components/modals/custom-components/NewExperimentModalComponent.js deleted file mode 100644 index e356fe96..00000000 --- a/src/components/modals/custom-components/NewExperimentModalComponent.js +++ /dev/null @@ -1,104 +0,0 @@ -import PropTypes from "prop-types"; -import React from "react"; -import Shapes from "../../../shapes"; -import Modal from "../Modal"; - -class NewExperimentModalComponent extends React.Component { - static propTypes = { - show: PropTypes.bool.isRequired, - paths: PropTypes.arrayOf(Shapes.Path), - schedulers: PropTypes.arrayOf(Shapes.Scheduler), - traces: PropTypes.arrayOf(Shapes.Trace), - callback: PropTypes.func.isRequired - }; - - reset() { - this.textInput.value = ""; - this.pathSelect.selectedIndex = 0; - this.traceSelect.selectedIndex = 0; - this.schedulerSelect.selectedIndex = 0; - } - - onSubmit() { - this.props.callback( - this.textInput.value, - parseInt(this.pathSelect.value, 10), - parseInt(this.traceSelect.value, 10), - this.schedulerSelect.value - ); - this.reset(); - } - - onCancel() { - this.props.callback(undefined); - this.reset(); - } - - render() { - return ( - -
{ - e.preventDefault(); - this.onSubmit(); - }} - > -
- - (this.textInput = textInput)} - /> -
-
- - -
-
- - -
-
- - -
-
-
- ); - } -} - -export default NewExperimentModalComponent; -- cgit v1.2.3