From be989ed8e90f4a100af5d51c91b0e0e0e206325c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 25 May 2021 04:39:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Refactor=20ContextRepositoryEdit?= =?UTF-8?q?or=20in=20ContextConditionEditor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/interactive/BadgeCondition.js | 2 +- .../interactive/BoxRepositoryCreate.js | 25 +++++++++++++------ .../components/providers/RepositoryEditor.js | 23 ++++++++++------- ...oryEditor.js => ContextConditionEditor.js} | 2 +- nest_frontend/hooks/useRepositoryEditor.js | 2 +- nest_frontend/routes/PageRepositoryCreate.js | 1 - 6 files changed, 34 insertions(+), 21 deletions(-) rename nest_frontend/contexts/{ContextRepositoryEditor.js => ContextConditionEditor.js} (57%) diff --git a/nest_frontend/components/interactive/BadgeCondition.js b/nest_frontend/components/interactive/BadgeCondition.js index dc30660..f450a00 100644 --- a/nest_frontend/components/interactive/BadgeCondition.js +++ b/nest_frontend/components/interactive/BadgeCondition.js @@ -1,5 +1,5 @@ import React, { useContext } from "react" -import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor" +import ContextRepositoryEditor from "../../contexts/ContextConditionEditor" import Badge from "../base/Badge" diff --git a/nest_frontend/components/interactive/BoxRepositoryCreate.js b/nest_frontend/components/interactive/BoxRepositoryCreate.js index 40182a3..80c0a85 100644 --- a/nest_frontend/components/interactive/BoxRepositoryCreate.js +++ b/nest_frontend/components/interactive/BoxRepositoryCreate.js @@ -15,24 +15,33 @@ import useStrings from "../../hooks/useStrings" /** * A {@link BoxFull} allowing the user to save the changes made in the current {@link RepositoryEditor}. * + * @param id - The id of the repository. + * @param name - The current name of the repository. + * @param setName - Function to change the name of the repository. + * @param evaluationMode - The current evaluation mode of the repository. + * @param setEvaluationMode - Function to change the current evaluation mode of the repository. * @param running - If a request is running, disabling the buttons. + * @param error - If a request error occoured, the error. + * @param revert - Function to cancel the changes made to the repository. + * @param save - Function to apply the changes made to the repository. * @param props - Additional props to pass to the box. * @returns {JSX.Element} * @constructor */ -export default function BoxRepositoryCreate({ running, ...props }) { - const { +export default function BoxRepositoryCreate( + { id, - evaluationMode, - setEvaluationMode, name, setName, - save, - revert, + evaluationMode, + setEvaluationMode, + running, error, - } = useRepositoryEditor() + revert, + save, + ...props + }) { - const history = useHistory() const strings = useStrings() return ( diff --git a/nest_frontend/components/providers/RepositoryEditor.js b/nest_frontend/components/providers/RepositoryEditor.js index 7c2fa94..17e3d09 100644 --- a/nest_frontend/components/providers/RepositoryEditor.js +++ b/nest_frontend/components/providers/RepositoryEditor.js @@ -1,5 +1,5 @@ import React, { useCallback, useContext, useState } from "react" -import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor" +import ContextConditionEditor from "../../contexts/ContextConditionEditor" import useArrayState from "../../hooks/useArrayState" import Style from "./RepositoryEditor.module.css" import BoxConditionLocation from "../interactive/BoxConditionLocation" @@ -142,14 +142,9 @@ export default function RepositoryEditor({ } return ( -
@@ -158,8 +153,18 @@ export default function RepositoryEditor({ - +
-
+ ) } diff --git a/nest_frontend/contexts/ContextRepositoryEditor.js b/nest_frontend/contexts/ContextConditionEditor.js similarity index 57% rename from nest_frontend/contexts/ContextRepositoryEditor.js rename to nest_frontend/contexts/ContextConditionEditor.js index 3364c6b..a68a4c0 100644 --- a/nest_frontend/contexts/ContextRepositoryEditor.js +++ b/nest_frontend/contexts/ContextConditionEditor.js @@ -2,7 +2,7 @@ import { createContext } from "react" /** - * React Context representing containing all variables of a {@link RepositoryEditor}. + * React Context representing a list of {@link Condition}s as provided by {@link useArrayState}. * * It is `null` outside a RepositoryEditor. */ diff --git a/nest_frontend/hooks/useRepositoryEditor.js b/nest_frontend/hooks/useRepositoryEditor.js index 143f665..dedfce2 100644 --- a/nest_frontend/hooks/useRepositoryEditor.js +++ b/nest_frontend/hooks/useRepositoryEditor.js @@ -1,5 +1,5 @@ import { useContext } from "react" -import ContextRepositoryEditor from "../contexts/ContextRepositoryEditor" +import ContextRepositoryEditor from "../contexts/ContextConditionEditor" /** diff --git a/nest_frontend/routes/PageRepositoryCreate.js b/nest_frontend/routes/PageRepositoryCreate.js index ea3bf41..f8892f1 100644 --- a/nest_frontend/routes/PageRepositoryCreate.js +++ b/nest_frontend/routes/PageRepositoryCreate.js @@ -17,7 +17,6 @@ export default function PageRepositoryCreate() { {makeIcon(faPlus)} {strings.dashboardTitle} } - {...props} >