diff --git a/src/features/machines/components/MachineAccordion.js b/src/features/machines/components/MachineAccordion.js
new file mode 100644
index 0000000..e001ff2
--- /dev/null
+++ b/src/features/machines/components/MachineAccordion.js
@@ -0,0 +1,50 @@
+import React from "react";
+import PropTypes from "prop-types";
+import Accordion from "@material-ui/core/Accordion";
+import AccordionSummary from "@material-ui/core/AccordionSummary";
+import AccordionDetails from "@material-ui/core/AccordionDetails";
+import Checkbox from "@material-ui/core/Checkbox";
+import FormControlLabel from "@material-ui/core/FormControlLabel";
+import Typography from "@material-ui/core/Typography";
+import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
+import withStyles from "@material-ui/core/styles/withStyles";
+
+const IconLeftAccordionSummary = withStyles({
+ expandIcon: {
+ order: -1
+ }
+})(AccordionSummary);
+
+const MachineAccordion = ({ machine }) => {
+ return (
+
+ }
+ aria-label="Expand"
+ aria-controls="additional-actions1-content"
+ id="additional-actions1-header"
+ IconButtonProps={{ edge: "start" }}
+ >
+ event.stopPropagation()}
+ onFocus={event => event.stopPropagation()}
+ control={}
+ label="I acknowledge that I should stop the click event propagation"
+ />
+
+
+
+ The click event of the nested action will propagate up and expand the
+ accordion unless you explicitly stop it.
+
+
+
+ );
+};
+
+MachineAccordion.propTypes = {
+ machine: PropTypes.array.isRequired
+};
+
+export default MachineAccordion;
diff --git a/src/features/machines/components/MachineContainer.js b/src/features/machines/components/MachineContainer.js
index 9c74b27..e472b9c 100644
--- a/src/features/machines/components/MachineContainer.js
+++ b/src/features/machines/components/MachineContainer.js
@@ -1,6 +1,8 @@
import React, { useState, useCallback } from "react";
import PropTypes from "prop-types";
-import Machine from "./Machine";
+import MachineTableRow from "./MachineTableRow";
+import MachineAccordion from "./MachineAccordion";
+import { ViewModes } from "./ViewModeSelection";
import { useToast } from "../../../hooks";
import {
LastPage,
@@ -12,7 +14,7 @@ import {
import { useTranslation } from "react-i18next";
import useApi from "../../../api";
-const MachineContainer = ({ machine }) => {
+const MachineContainer = ({ machine, viewMode }) => {
const [logs, setLogs] = useState([]);
const [secondaryActionsAnchor, setSecondaryActionsAnchor] =
React.useState(null);
@@ -123,18 +125,32 @@ const MachineContainer = ({ machine }) => {
];
return (
-
+ <>
+ {viewMode === ViewModes.TABLE && (
+
+ )}
+ {viewMode === ViewModes.ACCORDION && (
+
+ )}
+ >
);
};
MachineContainer.propTypes = {
- machine: PropTypes.object.isRequired
+ machine: PropTypes.object.isRequired,
+ viewMode: PropTypes.bool.isRequired
};
export default MachineContainer;
diff --git a/src/features/machines/components/Machine.js b/src/features/machines/components/MachineTableRow.js
similarity index 100%
rename from src/features/machines/components/Machine.js
rename to src/features/machines/components/MachineTableRow.js
diff --git a/src/features/machines/components/MachinesAccordionList.js b/src/features/machines/components/MachinesAccordionList.js
deleted file mode 100644
index eb394f2..0000000
--- a/src/features/machines/components/MachinesAccordionList.js
+++ /dev/null
@@ -1,63 +0,0 @@
-import React from "react";
-import PropTypes from "prop-types";
-import { makeStyles } from "@material-ui/core/styles";
-import Accordion from "@material-ui/core/Accordion";
-import AccordionSummary from "@material-ui/core/AccordionSummary";
-import AccordionDetails from "@material-ui/core/AccordionDetails";
-import Checkbox from "@material-ui/core/Checkbox";
-import FormControlLabel from "@material-ui/core/FormControlLabel";
-import Typography from "@material-ui/core/Typography";
-import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
-import withStyles from "@material-ui/core/styles/withStyles";
-
-const IconLeftAccordionSummary = withStyles({
- expandIcon: {
- order: -1
- }
-})(AccordionSummary);
-
-const useStyles = makeStyles({
- root: {
- width: "100%"
- }
-});
-
-const MachinesAccordionList = ({ machines }) => {
- const classes = useStyles();
-
- return (
-
- {machines.map(machine => (
-
- }
- aria-label="Expand"
- aria-controls="additional-actions1-content"
- id="additional-actions1-header"
- IconButtonProps={{ edge: "start" }}
- >
- event.stopPropagation()}
- onFocus={event => event.stopPropagation()}
- control={}
- label="I acknowledge that I should stop the click event propagation"
- />
-
-
-
- The click event of the nested action will propagate up and expand
- the accordion unless you explicitly stop it.
-
-
-
- ))}
-
- );
-};
-
-MachinesAccordionList.propTypes = {
- machines: PropTypes.array.isRequired
-};
-
-export default MachinesAccordionList;
diff --git a/src/features/machines/components/MachinesContainer.js b/src/features/machines/components/MachinesContainer.js
index 12bbb84..203c7ec 100644
--- a/src/features/machines/components/MachinesContainer.js
+++ b/src/features/machines/components/MachinesContainer.js
@@ -4,8 +4,7 @@ import {
NetworkDispatchContext
} from "../../network/state/contexts";
import useApi from "../../../api";
-import MachinesTableList from "./MachinesTableList";
-import MachinesAccordionList from "./MachinesAccordionList";
+import MachinesListComponent from "./MachinesListComponent";
import PageTitle from "../../../components/common/PageTitle";
import { useTranslation } from "react-i18next";
import ViewModeSelection, { ViewModes } from "./ViewModeSelection";
@@ -40,12 +39,10 @@ const MachinesContainer = () => {
text={t("Menu.Machines")}
toolBar={}
/>
- {viewMode === ViewModes.TABLE && (
-
- )}
- {viewMode === ViewModes.ACCORDION && (
-
- )}
+
>
);
};
diff --git a/src/features/machines/components/MachinesListComponent.js b/src/features/machines/components/MachinesListComponent.js
new file mode 100644
index 0000000..53d2522
--- /dev/null
+++ b/src/features/machines/components/MachinesListComponent.js
@@ -0,0 +1,80 @@
+import React from "react";
+import PropTypes from "prop-types";
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableContainer,
+ TableHead,
+ TableRow
+} from "@material-ui/core";
+import Paper from "@material-ui/core/Paper";
+import MachineContainer from "./MachineContainer";
+import { useTranslation } from "react-i18next";
+import { ViewModes } from "./ViewModeSelection";
+
+const MachinesList = ({ machines, viewMode }) => {
+ return (
+ <>
+ {machines.map(machine => (
+
+ ))}
+ >
+ );
+};
+
+MachinesList.propTypes = {
+ machines: PropTypes.array.isRequired,
+ viewMode: PropTypes.string.isRequired
+};
+
+const MachinesTableList = ({ machines, viewMode }) => {
+ const { t } = useTranslation();
+ return (
+
+
+
+
+
+ {t("Machine.FullName")}
+ {t("Machine.Name")}
+ {t("Machine.IP")}
+ {t("Machine.MAC")}
+
+
+
+
+
+
+
+
+ );
+};
+
+MachinesTableList.propTypes = {
+ machines: PropTypes.array.isRequired,
+ viewMode: PropTypes.string.isRequired
+};
+
+const MachinesListComponent = ({ machines, viewMode }) => {
+ return (
+ <>
+ {viewMode === ViewModes.TABLE ? (
+
+ ) : (
+
+ )}
+ >
+ );
+};
+
+MachinesListComponent.propTypes = {
+ machines: PropTypes.array.isRequired,
+ viewMode: PropTypes.string.isRequired
+};
+
+export default MachinesListComponent;
diff --git a/src/features/machines/components/MachinesTableList.js b/src/features/machines/components/MachinesTableList.js
deleted file mode 100644
index 2fb8311..0000000
--- a/src/features/machines/components/MachinesTableList.js
+++ /dev/null
@@ -1,48 +0,0 @@
-import React from "react";
-import PropTypes from "prop-types";
-import {
- Table,
- TableBody,
- TableCell,
- TableContainer,
- TableHead,
- TableRow
-} from "@material-ui/core";
-import Paper from "@material-ui/core/Paper";
-import MachineContainer from "./MachineContainer";
-import { useTranslation } from "react-i18next";
-
-const MachinesTableList = ({ dense, machines }) => {
- const { t } = useTranslation();
- return (
-
-
-
-
-
- {t("Machine.FullName")}
- {t("Machine.Name")}
- {t("Machine.IP")}
- {t("Machine.MAC")}
-
-
-
-
- {machines.map(machine => (
-
- ))}
-
-
-
- );
-};
-
-MachinesTableList.propTypes = {
- dense: PropTypes.bool.isRequired,
- machines: PropTypes.array.isRequired
-};
-
-export default MachinesTableList;