2021-05-07 15:42:20 +00:00
|
|
|
import React from "react"
|
2021-05-07 15:30:10 +00:00
|
|
|
import BoxFull from "../base/BoxFull"
|
|
|
|
import FormLabelled from "../base/FormLabelled"
|
|
|
|
import FormLabel from "../base/formparts/FormLabel"
|
|
|
|
import InputWithIcon from "../base/InputWithIcon"
|
2021-05-10 13:22:07 +00:00
|
|
|
import { faFolder, faPencilAlt, faPlus } from "@fortawesome/free-solid-svg-icons"
|
2021-05-07 15:30:10 +00:00
|
|
|
import Radio from "../base/Radio"
|
|
|
|
import Button from "../base/Button"
|
|
|
|
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
|
2021-05-07 23:40:49 +00:00
|
|
|
import FormAlert from "../base/formparts/FormAlert"
|
2021-05-07 15:30:10 +00:00
|
|
|
|
|
|
|
|
2021-05-10 13:22:07 +00:00
|
|
|
/**
|
|
|
|
* A {@link BoxFull} allowing the user to save the changes made in the current {@link RepositoryEditor}.
|
|
|
|
*
|
|
|
|
* @param props
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-05-07 15:30:10 +00:00
|
|
|
export default function BoxRepositoryCreate({ ...props }) {
|
|
|
|
const {
|
2021-05-10 13:22:07 +00:00
|
|
|
id,
|
2021-05-07 15:30:10 +00:00
|
|
|
evaluationMode,
|
|
|
|
setEvaluationMode,
|
|
|
|
name,
|
|
|
|
setName,
|
|
|
|
save,
|
2021-05-07 23:40:49 +00:00
|
|
|
error,
|
2021-05-07 15:30:10 +00:00
|
|
|
} = useRepositoryEditor()
|
|
|
|
|
|
|
|
return (
|
|
|
|
<BoxFull header={"Create repository"} {...props}>
|
2021-05-07 23:40:49 +00:00
|
|
|
<FormLabelled onSubmit={e => {e.preventDefault(); save()}}>
|
2021-05-07 15:30:10 +00:00
|
|
|
<FormLabel htmlFor={"repo-name"} text={"Repository name"}>
|
|
|
|
<InputWithIcon
|
|
|
|
id={"repo-name"}
|
|
|
|
icon={faFolder}
|
|
|
|
value={name}
|
|
|
|
onChange={e => setName(e.target.value)}
|
|
|
|
/>
|
|
|
|
</FormLabel>
|
|
|
|
<FormLabel htmlFor={"filter-mode"} text={"Add tweets if they satisfy"}>
|
|
|
|
<label>
|
|
|
|
<Radio
|
|
|
|
name={"filter-mode"}
|
2021-05-10 12:13:45 +00:00
|
|
|
onChange={() => setEvaluationMode(0)}
|
2021-05-07 15:30:10 +00:00
|
|
|
checked={evaluationMode === 0}
|
|
|
|
/>
|
|
|
|
At least one filter
|
|
|
|
</label>
|
|
|
|
|
|
|
|
<label>
|
|
|
|
<Radio
|
|
|
|
name={"filter-mode"}
|
2021-05-10 12:13:45 +00:00
|
|
|
onChange={() => setEvaluationMode(1)}
|
2021-05-07 15:30:10 +00:00
|
|
|
checked={evaluationMode === 1}
|
|
|
|
/>
|
|
|
|
Every filter
|
|
|
|
</label>
|
|
|
|
</FormLabel>
|
2021-05-07 23:40:49 +00:00
|
|
|
{error ?
|
|
|
|
<FormAlert color={"Red"}>
|
|
|
|
{error.toString()}
|
|
|
|
</FormAlert>
|
|
|
|
: null}
|
2021-05-10 13:22:07 +00:00
|
|
|
{id ?
|
|
|
|
<Button
|
|
|
|
style={{"gridColumn": "1 / 3"}}
|
|
|
|
icon={faPencilAlt}
|
|
|
|
color={"Green"}
|
|
|
|
goTo={"/repositories"}
|
|
|
|
onClick={e => save()}
|
|
|
|
>
|
|
|
|
Edit repository
|
|
|
|
</Button>
|
|
|
|
:
|
|
|
|
<Button
|
|
|
|
style={{"gridColumn": "1 / 3"}}
|
|
|
|
icon={faPlus}
|
|
|
|
color={"Green"}
|
|
|
|
goTo={"/repositories"}
|
|
|
|
onClick={e => save()}
|
|
|
|
>
|
|
|
|
Create repository
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
|
2021-05-07 15:30:10 +00:00
|
|
|
</FormLabelled>
|
|
|
|
</BoxFull>
|
|
|
|
)
|
|
|
|
}
|