From 5479a8dc35f56735746b637821702db8ab8bb826 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi <256895@studenti.unimore.it> Date: Thu, 29 Apr 2021 16:58:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Restructure=20project=20director?= =?UTF-8?q?ies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/frontend/src/App.js | 8 +++---- code/frontend/src/components/BoxConditions.js | 17 ------------- .../frontend/src/components/ButtonIconOnly.js | 11 --------- code/frontend/src/components/FormInline.js | 12 ---------- .../src/components/{ => base}/BoxAlert.js | 0 .../components/{ => base}/BoxAlert.module.css | 0 .../src/components/{ => base}/BoxFull.js | 0 .../components/{ => base}/BoxFull.module.css | 0 .../{ => base}/BoxFullScrollable.js | 0 .../{ => base}/BoxFullScrollable.module.css | 0 .../src/components/{ => base}/BoxHeader.js | 0 .../{ => base}/BoxHeader.module.css | 0 .../src/components/{ => base}/Button.js | 2 +- .../components/{ => base}/Button.module.css | 0 .../src/components/base/ButtonIconOnly.js | 19 +++++++++++++++ .../{ => base}/ButtonIconOnly.module.css | 0 .../components/{ => base}/ButtonSidebar.js | 2 +- .../{ => base}/ButtonSidebar.module.css | 0 .../src/components/{ => base}/ButtonSmallX.js | 10 +++++++- .../{ => base}/ButtonSmallX.module.css | 0 .../src/components/{ => base}/Checkbox.js | 0 .../components/{ => base}/Checkbox.module.css | 0 .../src/components/base/FormInline.js | 21 ++++++++++++++++ .../{ => base}/FormInline.module.css | 0 .../src/components/{ => base}/FormLabelled.js | 2 -- .../{ => base}/FormLabelled.module.css | 0 .../src/components/{ => base}/Input.js | 0 .../components/{ => base}/Input.module.css | 0 .../components/{ => base}/InputWithIcon.js | 2 +- .../{ => base}/InputWithIcon.module.css | 0 .../src/components/{ => base}/Loading.js | 10 ++++++-- .../src/components/{ => base}/Radio.js | 0 .../components/{ => base}/Radio.module.css | 0 .../src/components/{ => base}/Select.js | 0 .../components/{ => base}/Select.module.css | 0 .../src/components/{ => base}/Slider.js | 0 .../components/{ => base}/Slider.module.css | 0 .../src/components/{ => base}/TextArea.js | 0 .../components/{ => base}/TextArea.module.css | 0 .../{ => base/formparts}/FormAlert.js | 2 +- .../{ => base/formparts}/FormAlert.module.css | 0 .../{ => base/formparts}/FormButton.js | 2 +- .../formparts}/FormButton.module.css | 0 .../{ => base/formparts}/FormLabel.js | 0 .../{ => base/formparts}/FormLabel.module.css | 0 .../{ => interactive}/BoxConditionHashtag.js | 22 +++++++++++------ .../BoxConditionHashtag.module.css | 0 .../{ => interactive}/BoxConditionUser.js | 24 ++++++++++++------- .../components/interactive/BoxConditions.js | 24 +++++++++++++++++++ .../{ => interactive}/BoxLoggedIn.js | 8 +++---- .../{ => interactive}/BoxLoggedIn.module.css | 0 .../components/{ => interactive}/BoxLogin.js | 16 ++++++------- .../BoxRepositoriesActive.js | 17 +++++++++---- .../BoxRepositoriesArchived.js | 17 +++++++++---- .../{ => interactive}/BoxSetServer.js | 10 ++++---- .../{ => interactive}/ConditionBadge.js | 4 ++-- .../ConditionBadge.module.css | 0 .../{ => interactive}/CurrentServer.js | 2 +- .../components/{ => interactive}/Layout.js | 4 ++-- .../{ => interactive}/Layout.module.css | 0 .../{ => interactive}/LoggedInUser.js | 2 +- .../src/components/{ => interactive}/Logo.js | 6 ++--- .../{ => interactive}/Logo.module.css | 0 .../RepositorySummaryBase.js | 2 +- .../RepositorySummaryBase.module.css | 0 .../{ => interactive}/SelectTheme.js | 4 ++-- .../components/{ => interactive}/Sidebar.js | 6 ++--- .../{ => interactive}/Sidebar.module.css | 0 .../{ => providers}/GlobalServer.js | 4 ++-- .../components/{ => providers}/GlobalTheme.js | 4 ++-- .../components/{ => providers}/GlobalUser.js | 6 ++--- .../{ => providers}/RepositoryEditor.js | 4 ++-- .../src/contexts/ContextRepositoryEditor.js | 6 +++-- code/frontend/src/hooks/useArrayState.js | 6 +++++ .../frontend/src/hooks/useRepositoryEditor.js | 14 +++++++++++ code/frontend/src/routes/PageAlerts.js | 2 +- code/frontend/src/routes/PageDashboard.js | 16 ++++++------- code/frontend/src/routes/PageLogin.js | 4 ++-- code/frontend/src/routes/PageRepositories.js | 4 ++-- code/frontend/src/routes/PageSettings.js | 8 +++---- 80 files changed, 227 insertions(+), 139 deletions(-) delete mode 100644 code/frontend/src/components/BoxConditions.js delete mode 100644 code/frontend/src/components/ButtonIconOnly.js delete mode 100644 code/frontend/src/components/FormInline.js rename code/frontend/src/components/{ => base}/BoxAlert.js (100%) rename code/frontend/src/components/{ => base}/BoxAlert.module.css (100%) rename code/frontend/src/components/{ => base}/BoxFull.js (100%) rename code/frontend/src/components/{ => base}/BoxFull.module.css (100%) rename code/frontend/src/components/{ => base}/BoxFullScrollable.js (100%) rename code/frontend/src/components/{ => base}/BoxFullScrollable.module.css (100%) rename code/frontend/src/components/{ => base}/BoxHeader.js (100%) rename code/frontend/src/components/{ => base}/BoxHeader.module.css (100%) rename code/frontend/src/components/{ => base}/Button.js (94%) rename code/frontend/src/components/{ => base}/Button.module.css (100%) create mode 100644 code/frontend/src/components/base/ButtonIconOnly.js rename code/frontend/src/components/{ => base}/ButtonIconOnly.module.css (100%) rename code/frontend/src/components/{ => base}/ButtonSidebar.js (96%) rename code/frontend/src/components/{ => base}/ButtonSidebar.module.css (100%) rename code/frontend/src/components/{ => base}/ButtonSmallX.js (58%) rename code/frontend/src/components/{ => base}/ButtonSmallX.module.css (100%) rename code/frontend/src/components/{ => base}/Checkbox.js (100%) rename code/frontend/src/components/{ => base}/Checkbox.module.css (100%) create mode 100644 code/frontend/src/components/base/FormInline.js rename code/frontend/src/components/{ => base}/FormInline.module.css (100%) rename code/frontend/src/components/{ => base}/FormLabelled.js (83%) rename code/frontend/src/components/{ => base}/FormLabelled.module.css (100%) rename code/frontend/src/components/{ => base}/Input.js (100%) rename code/frontend/src/components/{ => base}/Input.module.css (100%) rename code/frontend/src/components/{ => base}/InputWithIcon.js (97%) rename code/frontend/src/components/{ => base}/InputWithIcon.module.css (100%) rename code/frontend/src/components/{ => base}/Loading.js (61%) rename code/frontend/src/components/{ => base}/Radio.js (100%) rename code/frontend/src/components/{ => base}/Radio.module.css (100%) rename code/frontend/src/components/{ => base}/Select.js (100%) rename code/frontend/src/components/{ => base}/Select.module.css (100%) rename code/frontend/src/components/{ => base}/Slider.js (100%) rename code/frontend/src/components/{ => base}/Slider.module.css (100%) rename code/frontend/src/components/{ => base}/TextArea.js (100%) rename code/frontend/src/components/{ => base}/TextArea.module.css (100%) rename code/frontend/src/components/{ => base/formparts}/FormAlert.js (94%) rename code/frontend/src/components/{ => base/formparts}/FormAlert.module.css (100%) rename code/frontend/src/components/{ => base/formparts}/FormButton.js (93%) rename code/frontend/src/components/{ => base/formparts}/FormButton.module.css (100%) rename code/frontend/src/components/{ => base/formparts}/FormLabel.js (100%) rename code/frontend/src/components/{ => base/formparts}/FormLabel.module.css (100%) rename code/frontend/src/components/{ => interactive}/BoxConditionHashtag.js (82%) rename code/frontend/src/components/{ => interactive}/BoxConditionHashtag.module.css (100%) rename code/frontend/src/components/{ => interactive}/BoxConditionUser.js (72%) create mode 100644 code/frontend/src/components/interactive/BoxConditions.js rename code/frontend/src/components/{ => interactive}/BoxLoggedIn.js (85%) rename code/frontend/src/components/{ => interactive}/BoxLoggedIn.module.css (100%) rename code/frontend/src/components/{ => interactive}/BoxLogin.js (86%) rename code/frontend/src/components/{ => interactive}/BoxRepositoriesActive.js (71%) rename code/frontend/src/components/{ => interactive}/BoxRepositoriesArchived.js (71%) rename code/frontend/src/components/{ => interactive}/BoxSetServer.js (79%) rename code/frontend/src/components/{ => interactive}/ConditionBadge.js (92%) rename code/frontend/src/components/{ => interactive}/ConditionBadge.module.css (100%) rename code/frontend/src/components/{ => interactive}/CurrentServer.js (90%) rename code/frontend/src/components/{ => interactive}/Layout.js (89%) rename code/frontend/src/components/{ => interactive}/Layout.module.css (100%) rename code/frontend/src/components/{ => interactive}/LoggedInUser.js (92%) rename code/frontend/src/components/{ => interactive}/Logo.js (85%) rename code/frontend/src/components/{ => interactive}/Logo.module.css (100%) rename code/frontend/src/components/{ => interactive}/RepositorySummaryBase.js (98%) rename code/frontend/src/components/{ => interactive}/RepositorySummaryBase.module.css (100%) rename code/frontend/src/components/{ => interactive}/SelectTheme.js (87%) rename code/frontend/src/components/{ => interactive}/Sidebar.js (92%) rename code/frontend/src/components/{ => interactive}/Sidebar.module.css (100%) rename code/frontend/src/components/{ => providers}/GlobalServer.js (94%) rename code/frontend/src/components/{ => providers}/GlobalTheme.js (77%) rename code/frontend/src/components/{ => providers}/GlobalUser.js (93%) rename code/frontend/src/components/{ => providers}/RepositoryEditor.js (87%) create mode 100644 code/frontend/src/hooks/useRepositoryEditor.js 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 }) {