mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 14:34:19 +00:00
🔧 Refactor ContextRepositoryEditor in ContextConditionEditor
This commit is contained in:
parent
7a7dbc79b3
commit
be989ed8e9
6 changed files with 34 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
||||||
import React, { useContext } from "react"
|
import React, { useContext } from "react"
|
||||||
import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor"
|
import ContextRepositoryEditor from "../../contexts/ContextConditionEditor"
|
||||||
import Badge from "../base/Badge"
|
import Badge from "../base/Badge"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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}.
|
* 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 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.
|
* @param props - Additional props to pass to the box.
|
||||||
* @returns {JSX.Element}
|
* @returns {JSX.Element}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxRepositoryCreate({ running, ...props }) {
|
export default function BoxRepositoryCreate(
|
||||||
const {
|
{
|
||||||
id,
|
id,
|
||||||
evaluationMode,
|
|
||||||
setEvaluationMode,
|
|
||||||
name,
|
name,
|
||||||
setName,
|
setName,
|
||||||
save,
|
evaluationMode,
|
||||||
revert,
|
setEvaluationMode,
|
||||||
|
running,
|
||||||
error,
|
error,
|
||||||
} = useRepositoryEditor()
|
revert,
|
||||||
|
save,
|
||||||
|
...props
|
||||||
|
}) {
|
||||||
|
|
||||||
const history = useHistory()
|
|
||||||
const strings = useStrings()
|
const strings = useStrings()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useCallback, useContext, useState } from "react"
|
import React, { useCallback, useContext, useState } from "react"
|
||||||
import ContextRepositoryEditor from "../../contexts/ContextRepositoryEditor"
|
import ContextConditionEditor from "../../contexts/ContextConditionEditor"
|
||||||
import useArrayState from "../../hooks/useArrayState"
|
import useArrayState from "../../hooks/useArrayState"
|
||||||
import Style from "./RepositoryEditor.module.css"
|
import Style from "./RepositoryEditor.module.css"
|
||||||
import BoxConditionLocation from "../interactive/BoxConditionLocation"
|
import BoxConditionLocation from "../interactive/BoxConditionLocation"
|
||||||
|
@ -142,14 +142,9 @@ export default function RepositoryEditor({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextRepositoryEditor.Provider
|
<ContextConditionEditor.Provider
|
||||||
value={{
|
value={{
|
||||||
id,
|
|
||||||
name: _name, setName,
|
|
||||||
conditions: _conditions, addCondition, appendRawCondition, removeRawCondition, spliceRawCondition,
|
conditions: _conditions, addCondition, appendRawCondition, removeRawCondition, spliceRawCondition,
|
||||||
evaluationMode: _evaluationMode, setEvaluationMode,
|
|
||||||
error, running,
|
|
||||||
revert, save,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className={classNames(Style.RepositoryEditor, className)}>
|
<div className={classNames(Style.RepositoryEditor, className)}>
|
||||||
|
@ -158,8 +153,18 @@ export default function RepositoryEditor({
|
||||||
<BoxConditionUser className={Style.SearchByUser}/>
|
<BoxConditionUser className={Style.SearchByUser}/>
|
||||||
<BoxConditionDatetime className={Style.SearchByTimePeriod}/>
|
<BoxConditionDatetime className={Style.SearchByTimePeriod}/>
|
||||||
<BoxConditions className={Style.Conditions}/>
|
<BoxConditions className={Style.Conditions}/>
|
||||||
<BoxRepositoryCreate running={running} className={Style.CreateDialog}/>
|
<BoxRepositoryCreate
|
||||||
|
className={Style.CreateDialog}
|
||||||
|
name={name}
|
||||||
|
setName={setName}
|
||||||
|
evaluationMode={_evaluationMode}
|
||||||
|
setEvaluationMode={setEvaluationMode}
|
||||||
|
running={running}
|
||||||
|
error={error}
|
||||||
|
revert={revert}
|
||||||
|
save={save}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ContextRepositoryEditor.Provider>
|
</ContextConditionEditor.Provider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* It is `null` outside a RepositoryEditor.
|
||||||
*/
|
*/
|
|
@ -1,5 +1,5 @@
|
||||||
import { useContext } from "react"
|
import { useContext } from "react"
|
||||||
import ContextRepositoryEditor from "../contexts/ContextRepositoryEditor"
|
import ContextRepositoryEditor from "../contexts/ContextConditionEditor"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,6 @@ export default function PageRepositoryCreate() {
|
||||||
{makeIcon(faPlus)} {strings.dashboardTitle}
|
{makeIcon(faPlus)} {strings.dashboardTitle}
|
||||||
</BoxHeader>
|
</BoxHeader>
|
||||||
}
|
}
|
||||||
{...props}
|
|
||||||
>
|
>
|
||||||
<RepositoryEditor/>
|
<RepositoryEditor/>
|
||||||
</PageWithHeader>
|
</PageWithHeader>
|
||||||
|
|
Loading…
Reference in a new issue