diff --git a/code/frontend/src/App.js b/code/frontend/src/App.js index ea754d2..ae2855a 100644 --- a/code/frontend/src/App.js +++ b/code/frontend/src/App.js @@ -1,8 +1,8 @@ -import Layout from "./components/Layout" +import Layout from "./components/interactive/Layout" import { BrowserRouter } from "react-router-dom" -import GlobalTheme from "./components/GlobalTheme" -import GlobalServer from "./components/GlobalServer" -import GlobalUser from "./components/GlobalUser" +import GlobalTheme from "./components/providers/GlobalTheme" +import GlobalServer from "./components/providers/GlobalServer" +import GlobalUser from "./components/providers/GlobalUser" import PageSwitcher from "./PageSwitcher" diff --git a/code/frontend/src/components/BoxConditions.js b/code/frontend/src/components/BoxConditions.js deleted file mode 100644 index b09a5fd..0000000 --- a/code/frontend/src/components/BoxConditions.js +++ /dev/null @@ -1,17 +0,0 @@ -import React, { useContext } from "react" -import BoxFull from "./BoxFull" -import ContextRepositoryEditor from "../contexts/ContextRepositoryEditor" -import ConditionBadge from "./ConditionBadge" - - -export default function BoxConditions({ ...props }) { - const {conditions} = useContext(ContextRepositoryEditor) - - const badges = conditions.map((cond, pos) => ) - - return ( - - {badges} - - ) -} diff --git a/code/frontend/src/components/ButtonIconOnly.js b/code/frontend/src/components/ButtonIconOnly.js deleted file mode 100644 index 564d4d5..0000000 --- a/code/frontend/src/components/ButtonIconOnly.js +++ /dev/null @@ -1,11 +0,0 @@ -import React from "react" -import Style from "./ButtonIconOnly.module.css" -import classNames from "classnames" -import Button from "./Button" - - -export default function ButtonIconOnly({ children, className, ...props }) { - return ( - diff --git a/code/frontend/src/components/BoxLoggedIn.module.css b/code/frontend/src/components/interactive/BoxLoggedIn.module.css similarity index 100% rename from code/frontend/src/components/BoxLoggedIn.module.css rename to code/frontend/src/components/interactive/BoxLoggedIn.module.css diff --git a/code/frontend/src/components/BoxLogin.js b/code/frontend/src/components/interactive/BoxLogin.js similarity index 86% rename from code/frontend/src/components/BoxLogin.js rename to code/frontend/src/components/interactive/BoxLogin.js index 2e09320..18e6286 100644 --- a/code/frontend/src/components/BoxLogin.js +++ b/code/frontend/src/components/interactive/BoxLogin.js @@ -1,13 +1,13 @@ import React, { useContext, useState } from "react" -import FormLabelled from "./FormLabelled" -import FormLabel from "./FormLabel" -import InputWithIcon from "./InputWithIcon" +import FormLabelled from "../base/FormLabelled" +import FormLabel from "../base/formparts/FormLabel" +import InputWithIcon from "../base/InputWithIcon" import { faArrowRight, faEnvelope, faKey } from "@fortawesome/free-solid-svg-icons" -import BoxFull from "./BoxFull" -import FormButton from "./FormButton" -import ContextUser from "../contexts/ContextUser" +import BoxFull from "../base/BoxFull" +import FormButton from "../base/formparts/FormButton" +import ContextUser from "../../contexts/ContextUser" import { useHistory } from "react-router" -import FormAlert from "./FormAlert" +import FormAlert from "../base/formparts/FormAlert" /** @@ -25,7 +25,7 @@ export default function BoxLogin({ ...props }) { const {login} = useContext(ContextUser) const history = useHistory() - const doLogin = async (event) => { + const doLogin = async () => { if(working) { return; } diff --git a/code/frontend/src/components/BoxRepositoriesActive.js b/code/frontend/src/components/interactive/BoxRepositoriesActive.js similarity index 71% rename from code/frontend/src/components/BoxRepositoriesActive.js rename to code/frontend/src/components/interactive/BoxRepositoriesActive.js index 6db8da9..42ace13 100644 --- a/code/frontend/src/components/BoxRepositoriesActive.js +++ b/code/frontend/src/components/interactive/BoxRepositoriesActive.js @@ -1,12 +1,19 @@ import React, { useContext } from "react" -import BoxFull from "./BoxFull" -import ContextUser from "../contexts/ContextUser" -import useData from "../hooks/useData" +import BoxFull from "../base/BoxFull" +import ContextUser from "../../contexts/ContextUser" +import useData from "../../hooks/useData" import RepositorySummaryBase from "./RepositorySummaryBase" -import Loading from "./Loading" -import BoxAlert from "./BoxAlert" +import Loading from "../base/Loading" +import BoxAlert from "../base/BoxAlert" +/** + * A {@link BoxFull} listing all the user's active repositories. + * + * @param props - Additional props to pass to the box. + * @returns {JSX.Element} + * @constructor + */ export default function BoxRepositoriesActive({ ...props }) { const {fetchDataAuth} = useContext(ContextUser) const {data, started, loading, error} = useData(fetchDataAuth, "GET", "/api/repository/list", { diff --git a/code/frontend/src/components/BoxRepositoriesArchived.js b/code/frontend/src/components/interactive/BoxRepositoriesArchived.js similarity index 71% rename from code/frontend/src/components/BoxRepositoriesArchived.js rename to code/frontend/src/components/interactive/BoxRepositoriesArchived.js index f947061..2b2d4a5 100644 --- a/code/frontend/src/components/BoxRepositoriesArchived.js +++ b/code/frontend/src/components/interactive/BoxRepositoriesArchived.js @@ -1,12 +1,19 @@ import React, { useContext } from "react" -import BoxFull from "./BoxFull" -import ContextUser from "../contexts/ContextUser" -import useData from "../hooks/useData" +import BoxFull from "../base/BoxFull" +import ContextUser from "../../contexts/ContextUser" +import useData from "../../hooks/useData" import RepositorySummaryBase from "./RepositorySummaryBase" -import Loading from "./Loading" -import BoxAlert from "./BoxAlert" +import Loading from "../base/Loading" +import BoxAlert from "../base/BoxAlert" +/** + * A {@link BoxFull} listing all the user's archived repositories. + * + * @param props - Additional props to pass to the box. + * @returns {JSX.Element} + * @constructor + */ export default function BoxRepositoriesArchived({ ...props }) { const {fetchDataAuth} = useContext(ContextUser) const {data, started, loading, error} = useData(fetchDataAuth, "GET", "/api/repository/list", { diff --git a/code/frontend/src/components/BoxSetServer.js b/code/frontend/src/components/interactive/BoxSetServer.js similarity index 79% rename from code/frontend/src/components/BoxSetServer.js rename to code/frontend/src/components/interactive/BoxSetServer.js index 43a855c..ada5c92 100644 --- a/code/frontend/src/components/BoxSetServer.js +++ b/code/frontend/src/components/interactive/BoxSetServer.js @@ -1,10 +1,10 @@ import React, { useContext } from "react" -import BoxFull from "./BoxFull" -import FormLabelled from "./FormLabelled" -import FormLabel from "./FormLabel" -import InputWithIcon from "./InputWithIcon" +import BoxFull from "../base/BoxFull" +import FormLabelled from "../base/FormLabelled" +import FormLabel from "../base/formparts/FormLabel" +import InputWithIcon from "../base/InputWithIcon" import { faGlobe } from "@fortawesome/free-solid-svg-icons" -import ContextServer from "../contexts/ContextServer" +import ContextServer from "../../contexts/ContextServer" /** diff --git a/code/frontend/src/components/ConditionBadge.js b/code/frontend/src/components/interactive/ConditionBadge.js similarity index 92% rename from code/frontend/src/components/ConditionBadge.js rename to code/frontend/src/components/interactive/ConditionBadge.js index 668eeb2..0e8f410 100644 --- a/code/frontend/src/components/ConditionBadge.js +++ b/code/frontend/src/components/interactive/ConditionBadge.js @@ -2,9 +2,9 @@ import React, { useContext } from "react" import Style from "./ConditionBadge.module.css" import classNames from "classnames" import {FontAwesomeIcon} from "@fortawesome/react-fontawesome" -import ButtonSmallX from "./ButtonSmallX" +import ButtonSmallX from "../base/ButtonSmallX" import { faAt, faClock, faHashtag, faMapPin } from "@fortawesome/free-solid-svg-icons" -import ContextRepositoryEditor from "../contexts/ContextRepositoryEditor" +import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor" const CONDITION_COLORS = { diff --git a/code/frontend/src/components/ConditionBadge.module.css b/code/frontend/src/components/interactive/ConditionBadge.module.css similarity index 100% rename from code/frontend/src/components/ConditionBadge.module.css rename to code/frontend/src/components/interactive/ConditionBadge.module.css diff --git a/code/frontend/src/components/CurrentServer.js b/code/frontend/src/components/interactive/CurrentServer.js similarity index 90% rename from code/frontend/src/components/CurrentServer.js rename to code/frontend/src/components/interactive/CurrentServer.js index 6b012d7..7508657 100644 --- a/code/frontend/src/components/CurrentServer.js +++ b/code/frontend/src/components/interactive/CurrentServer.js @@ -1,7 +1,7 @@ import React, { useContext } from "react" import {FontAwesomeIcon} from "@fortawesome/react-fontawesome" import { faGlobe } from "@fortawesome/free-solid-svg-icons" -import ContextServer from "../contexts/ContextServer" +import ContextServer from "../../contexts/ContextServer" /** diff --git a/code/frontend/src/components/Layout.js b/code/frontend/src/components/interactive/Layout.js similarity index 89% rename from code/frontend/src/components/Layout.js rename to code/frontend/src/components/interactive/Layout.js index 28d123d..83094dd 100644 --- a/code/frontend/src/components/Layout.js +++ b/code/frontend/src/components/interactive/Layout.js @@ -1,8 +1,8 @@ import React, { useContext } from "react" import Style from "./Layout.module.css" import classNames from "classnames" -import Sidebar from "./Sidebar" -import ContextTheme from "../contexts/ContextTheme" +import Sidebar from "../interactive/Sidebar" +import ContextTheme from "../../contexts/ContextTheme" /** diff --git a/code/frontend/src/components/Layout.module.css b/code/frontend/src/components/interactive/Layout.module.css similarity index 100% rename from code/frontend/src/components/Layout.module.css rename to code/frontend/src/components/interactive/Layout.module.css diff --git a/code/frontend/src/components/LoggedInUser.js b/code/frontend/src/components/interactive/LoggedInUser.js similarity index 92% rename from code/frontend/src/components/LoggedInUser.js rename to code/frontend/src/components/interactive/LoggedInUser.js index fffb9c9..504dddb 100644 --- a/code/frontend/src/components/LoggedInUser.js +++ b/code/frontend/src/components/interactive/LoggedInUser.js @@ -1,7 +1,7 @@ import React, { useContext } from "react" import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" import { faUser } from "@fortawesome/free-solid-svg-icons" -import ContextUser from "../contexts/ContextUser" +import ContextUser from "../../contexts/ContextUser" /** diff --git a/code/frontend/src/components/Logo.js b/code/frontend/src/components/interactive/Logo.js similarity index 85% rename from code/frontend/src/components/Logo.js rename to code/frontend/src/components/interactive/Logo.js index 2ed7e77..be5e774 100644 --- a/code/frontend/src/components/Logo.js +++ b/code/frontend/src/components/interactive/Logo.js @@ -1,8 +1,8 @@ import React, {useContext} from "react" import Style from "./Logo.module.css" -import LogoDark from "../media/LogoDark.png" -import LogoLight from "../media/LogoLight.png" -import ContextTheme from "../contexts/ContextTheme" +import LogoDark from "../../media/LogoDark.png" +import LogoLight from "../../media/LogoLight.png" +import ContextTheme from "../../contexts/ContextTheme" import classNames from "classnames" diff --git a/code/frontend/src/components/Logo.module.css b/code/frontend/src/components/interactive/Logo.module.css similarity index 100% rename from code/frontend/src/components/Logo.module.css rename to code/frontend/src/components/interactive/Logo.module.css diff --git a/code/frontend/src/components/RepositorySummaryBase.js b/code/frontend/src/components/interactive/RepositorySummaryBase.js similarity index 98% rename from code/frontend/src/components/RepositorySummaryBase.js rename to code/frontend/src/components/interactive/RepositorySummaryBase.js index 96aeffe..e241b88 100644 --- a/code/frontend/src/components/RepositorySummaryBase.js +++ b/code/frontend/src/components/interactive/RepositorySummaryBase.js @@ -2,7 +2,7 @@ import React from "react" import Style from "./RepositorySummaryBase.module.css" import classNames from "classnames" import {FontAwesomeIcon} from "@fortawesome/react-fontawesome" -import Button from "./Button" +import Button from "../base/Button" import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-icons" diff --git a/code/frontend/src/components/RepositorySummaryBase.module.css b/code/frontend/src/components/interactive/RepositorySummaryBase.module.css similarity index 100% rename from code/frontend/src/components/RepositorySummaryBase.module.css rename to code/frontend/src/components/interactive/RepositorySummaryBase.module.css diff --git a/code/frontend/src/components/SelectTheme.js b/code/frontend/src/components/interactive/SelectTheme.js similarity index 87% rename from code/frontend/src/components/SelectTheme.js rename to code/frontend/src/components/interactive/SelectTheme.js index 8e28e75..60a7cc0 100644 --- a/code/frontend/src/components/SelectTheme.js +++ b/code/frontend/src/components/interactive/SelectTheme.js @@ -1,6 +1,6 @@ import React, {useContext} from "react" -import Select from "./Select" -import ContextTheme from "../contexts/ContextTheme" +import Select from "../base/Select" +import ContextTheme from "../../contexts/ContextTheme" /** diff --git a/code/frontend/src/components/Sidebar.js b/code/frontend/src/components/interactive/Sidebar.js similarity index 92% rename from code/frontend/src/components/Sidebar.js rename to code/frontend/src/components/interactive/Sidebar.js index ec6162c..5c0c625 100644 --- a/code/frontend/src/components/Sidebar.js +++ b/code/frontend/src/components/interactive/Sidebar.js @@ -1,10 +1,10 @@ import React, { Fragment, useContext } from "react" import Style from "./Sidebar.module.css" import classNames from "classnames" -import Logo from "./Logo" -import ButtonSidebar from "./ButtonSidebar" +import Logo from "../interactive/Logo" +import ButtonSidebar from "../base/ButtonSidebar" import { faCog, faExclamationTriangle, faFolder, faHome, faKey, faWrench } from "@fortawesome/free-solid-svg-icons" -import ContextUser from "../contexts/ContextUser" +import ContextUser from "../../contexts/ContextUser" /** diff --git a/code/frontend/src/components/Sidebar.module.css b/code/frontend/src/components/interactive/Sidebar.module.css similarity index 100% rename from code/frontend/src/components/Sidebar.module.css rename to code/frontend/src/components/interactive/Sidebar.module.css diff --git a/code/frontend/src/components/GlobalServer.js b/code/frontend/src/components/providers/GlobalServer.js similarity index 94% rename from code/frontend/src/components/GlobalServer.js rename to code/frontend/src/components/providers/GlobalServer.js index a29f217..4e3272d 100644 --- a/code/frontend/src/components/GlobalServer.js +++ b/code/frontend/src/components/providers/GlobalServer.js @@ -1,6 +1,6 @@ import React, { useCallback } from "react" -import useLocalStorageState from "../hooks/useLocalStorageState" -import ContextServer from "../contexts/ContextServer" +import useLocalStorageState from "../../hooks/useLocalStorageState" +import ContextServer from "../../contexts/ContextServer" import isString from "is-string" diff --git a/code/frontend/src/components/GlobalTheme.js b/code/frontend/src/components/providers/GlobalTheme.js similarity index 77% rename from code/frontend/src/components/GlobalTheme.js rename to code/frontend/src/components/providers/GlobalTheme.js index 2dd467a..f763eca 100644 --- a/code/frontend/src/components/GlobalTheme.js +++ b/code/frontend/src/components/providers/GlobalTheme.js @@ -1,6 +1,6 @@ import React from "react" -import useLocalStorageState from "../hooks/useLocalStorageState" -import ContextTheme from "../contexts/ContextTheme" +import useLocalStorageState from "../../hooks/useLocalStorageState" +import ContextTheme from "../../contexts/ContextTheme" /** diff --git a/code/frontend/src/components/GlobalUser.js b/code/frontend/src/components/providers/GlobalUser.js similarity index 93% rename from code/frontend/src/components/GlobalUser.js rename to code/frontend/src/components/providers/GlobalUser.js index 0514031..4797ae6 100644 --- a/code/frontend/src/components/GlobalUser.js +++ b/code/frontend/src/components/providers/GlobalUser.js @@ -1,7 +1,7 @@ import React, { useCallback, useContext } from "react" -import useLocalStorageState from "../hooks/useLocalStorageState" -import ContextServer from "../contexts/ContextServer" -import ContextUser from "../contexts/ContextUser" +import useLocalStorageState from "../../hooks/useLocalStorageState" +import ContextServer from "../../contexts/ContextServer" +import ContextUser from "../../contexts/ContextUser" /** diff --git a/code/frontend/src/components/RepositoryEditor.js b/code/frontend/src/components/providers/RepositoryEditor.js similarity index 87% rename from code/frontend/src/components/RepositoryEditor.js rename to code/frontend/src/components/providers/RepositoryEditor.js index 2c92a3a..b62b796 100644 --- a/code/frontend/src/components/RepositoryEditor.js +++ b/code/frontend/src/components/providers/RepositoryEditor.js @@ -1,6 +1,6 @@ import React, { useState } from "react" -import ContextRepositoryEditor from "../contexts/ContextRepositoryEditor" -import useArrayState from "../hooks/useArrayState" +import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor" +import useArrayState from "../../hooks/useArrayState" export default function RepositoryEditor({ children, id, name, start, end, conditions }) { diff --git a/code/frontend/src/contexts/ContextRepositoryEditor.js b/code/frontend/src/contexts/ContextRepositoryEditor.js index 5d9ff86..94b0ce5 100644 --- a/code/frontend/src/contexts/ContextRepositoryEditor.js +++ b/code/frontend/src/contexts/ContextRepositoryEditor.js @@ -1,5 +1,7 @@ import {createContext} from "react"; -const ContextRepositoryEditor = createContext(null) -export default ContextRepositoryEditor +/** + * @todo Document this. + */ +export default createContext(null) diff --git a/code/frontend/src/hooks/useArrayState.js b/code/frontend/src/hooks/useArrayState.js index ec529f4..08e169a 100644 --- a/code/frontend/src/hooks/useArrayState.js +++ b/code/frontend/src/hooks/useArrayState.js @@ -1,6 +1,12 @@ import { useCallback, useState } from "react" +/** + * An hook similar to {@link useState} which stores an array of values. + * + * @param def - The starting value of the hook. + * @returns {{spliceValue, removeValue, setValue, appendValue, value}} + */ export default function useArrayState(def) { const [value, setValue] = useState(def ?? []) diff --git a/code/frontend/src/hooks/useRepositoryEditor.js b/code/frontend/src/hooks/useRepositoryEditor.js new file mode 100644 index 0000000..387ad3b --- /dev/null +++ b/code/frontend/src/hooks/useRepositoryEditor.js @@ -0,0 +1,14 @@ +import { useContext } from "react" +import ContextRepositoryEditor from "../contexts/ContextRepositoryEditor" + + +/** + * @todo Document this. + */ +export default function useRepositoryEditor() { + const context = useContext(ContextRepositoryEditor) + if(!context) { + throw new Error("This component must be placed inside a RepositoryEditor.") + } + return context +} \ No newline at end of file diff --git a/code/frontend/src/routes/PageAlerts.js b/code/frontend/src/routes/PageAlerts.js index 5770e89..bbb5437 100644 --- a/code/frontend/src/routes/PageAlerts.js +++ b/code/frontend/src/routes/PageAlerts.js @@ -1,7 +1,7 @@ import React from "react" import Style from "./PageAlerts.module.css" import classNames from "classnames" -import BoxFull from "../components/BoxFull" +import BoxFull from "../components/base/BoxFull" export default function PageAlerts({ children, className, ...props }) { diff --git a/code/frontend/src/routes/PageDashboard.js b/code/frontend/src/routes/PageDashboard.js index ba10f90..cf4da58 100644 --- a/code/frontend/src/routes/PageDashboard.js +++ b/code/frontend/src/routes/PageDashboard.js @@ -1,15 +1,15 @@ import React from "react" import Style from "./PageDashboard.module.css" import classNames from "classnames" -import BoxHeader from "../components/BoxHeader" -import BoxFull from "../components/BoxFull" -import Checkbox from "../components/Checkbox" -import InputWithIcon from "../components/InputWithIcon" +import BoxHeader from "../components/base/BoxHeader" +import BoxFull from "../components/base/BoxFull" +import Checkbox from "../components/base/Checkbox" +import InputWithIcon from "../components/base/InputWithIcon" import { faFolder, faPlus } from "@fortawesome/free-solid-svg-icons" -import Radio from "../components/Radio" -import Button from "../components/Button" -import FormLabelled from "../components/FormLabelled" -import FormLabel from "../components/FormLabel" +import Radio from "../components/base/Radio" +import Button from "../components/base/Button" +import FormLabelled from "../components/base/FormLabelled" +import FormLabel from "../components/base/formparts/FormLabel" export default function PageDashboard({ children, className, ...props }) { diff --git a/code/frontend/src/routes/PageLogin.js b/code/frontend/src/routes/PageLogin.js index 9392428..4ef8c9a 100644 --- a/code/frontend/src/routes/PageLogin.js +++ b/code/frontend/src/routes/PageLogin.js @@ -1,8 +1,8 @@ import React from "react" import Style from "./PageLogin.module.css" import classNames from "classnames" -import BoxSetServer from "../components/BoxSetServer" -import BoxLogin from "../components/BoxLogin" +import BoxSetServer from "../components/interactive/BoxSetServer" +import BoxLogin from "../components/interactive/BoxLogin" export default function PageLogin({ className, ...props }) { diff --git a/code/frontend/src/routes/PageRepositories.js b/code/frontend/src/routes/PageRepositories.js index eb3c7db..c064790 100644 --- a/code/frontend/src/routes/PageRepositories.js +++ b/code/frontend/src/routes/PageRepositories.js @@ -1,8 +1,8 @@ import React from "react" import Style from "./PageRepositories.module.css" import classNames from "classnames" -import BoxRepositoriesActive from "../components/BoxRepositoriesActive" -import BoxRepositoriesArchived from "../components/BoxRepositoriesArchived" +import BoxRepositoriesActive from "../components/interactive/BoxRepositoriesActive" +import BoxRepositoriesArchived from "../components/interactive/BoxRepositoriesArchived" export default function PageRepositories({ children, className, ...props }) { diff --git a/code/frontend/src/routes/PageSettings.js b/code/frontend/src/routes/PageSettings.js index 92c633c..d05272a 100644 --- a/code/frontend/src/routes/PageSettings.js +++ b/code/frontend/src/routes/PageSettings.js @@ -1,10 +1,10 @@ import React from "react" import Style from "./PageSettings.module.css" import classNames from "classnames" -import BoxHeader from "../components/BoxHeader" -import BoxFull from "../components/BoxFull" -import SelectTheme from "../components/SelectTheme" -import BoxLoggedIn from "../components/BoxLoggedIn" +import BoxHeader from "../components/base/BoxHeader" +import BoxFull from "../components/base/BoxFull" +import SelectTheme from "../components/interactive/SelectTheme" +import BoxLoggedIn from "../components/interactive/BoxLoggedIn" export default function PageSettings({ children, className, ...props }) {