mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-22 04:54:18 +00:00
🧹 Cleanup code
This commit is contained in:
parent
8f324a0f23
commit
ce0a8d321e
27 changed files with 36 additions and 44 deletions
|
@ -1,10 +1,11 @@
|
||||||
// Link.react.test.js
|
// Link.react.test.js
|
||||||
import React from 'react'
|
import React from "react"
|
||||||
import '@testing-library/jest-dom/extend-expect'
|
import "@testing-library/jest-dom/extend-expect"
|
||||||
import { render, screen } from '@testing-library/react'
|
import { render, screen } from "@testing-library/react"
|
||||||
import App from "./App"
|
import App from "./App"
|
||||||
|
|
||||||
test('App renders without exploding', () => {
|
|
||||||
|
test("App renders without exploding", () => {
|
||||||
render(<App/>)
|
render(<App/>)
|
||||||
expect(screen.getByRole("main")).toBeVisible()
|
expect(screen.getByRole("main")).toBeVisible()
|
||||||
});
|
})
|
||||||
|
|
|
@ -210,5 +210,5 @@ export default {
|
||||||
type: "Tyyppi",
|
type: "Tyyppi",
|
||||||
admin: "Ylläpitäjä",
|
admin: "Ylläpitäjä",
|
||||||
user: "Käyttäjä",
|
user: "Käyttäjä",
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default function BoxConditionDatetime({ ...props }) {
|
||||||
const [datetime, setDatetime] = useState("")
|
const [datetime, setDatetime] = useState("")
|
||||||
const [ba, setBa] = useState(false)
|
const [ba, setBa] = useState(false)
|
||||||
const { addCondition } = useRepositoryEditor()
|
const { addCondition } = useRepositoryEditor()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const onInputChange = event => {
|
const onInputChange = event => {
|
||||||
let text = event.target.value
|
let text = event.target.value
|
||||||
|
|
|
@ -26,7 +26,7 @@ const INVALID_HASHTAG_CHARACTERS = /([^a-z0-9_\u00c0-\u00d6\u00d8-\u00f6\u00f8-\
|
||||||
export default function BoxConditionHashtag({ ...props }) {
|
export default function BoxConditionHashtag({ ...props }) {
|
||||||
const [hashtag, setHashtag] = useState("")
|
const [hashtag, setHashtag] = useState("")
|
||||||
const { addCondition } = useRepositoryEditor()
|
const { addCondition } = useRepositoryEditor()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const onInputChange = event => {
|
const onInputChange = event => {
|
||||||
let text = event.target.value
|
let text = event.target.value
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useCallback, useContext, useEffect, useState } from "react"
|
import React, { useCallback, useContext, useEffect, useState } from "react"
|
||||||
import BoxFull from "../base/BoxFull"
|
import BoxFull from "../base/BoxFull"
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
import { faAt, faMapPin, faPlus } from "@fortawesome/free-solid-svg-icons"
|
import { faMapPin, faPlus } from "@fortawesome/free-solid-svg-icons"
|
||||||
import Style from "./BoxConditionMap.module.css"
|
import Style from "./BoxConditionMap.module.css"
|
||||||
import ButtonIconOnly from "../base/ButtonIconOnly"
|
import ButtonIconOnly from "../base/ButtonIconOnly"
|
||||||
import { MapContainer, TileLayer } from "react-leaflet"
|
import { MapContainer, TileLayer } from "react-leaflet"
|
||||||
|
@ -54,7 +54,7 @@ export default function BoxConditionMap({ ...props }) {
|
||||||
const [zoom, setZoom] = useState(STARTING_ZOOM)
|
const [zoom, setZoom] = useState(STARTING_ZOOM)
|
||||||
const [map, setMap] = useState(null)
|
const [map, setMap] = useState(null)
|
||||||
const { addCondition } = useRepositoryEditor()
|
const { addCondition } = useRepositoryEditor()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const onMove = useCallback(
|
const onMove = useCallback(
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -25,7 +25,7 @@ const INVALID_USER_CHARACTERS = /[^a-zA-Z0-9]/g
|
||||||
export default function BoxConditionUser({ ...props }) {
|
export default function BoxConditionUser({ ...props }) {
|
||||||
const [user, setUser] = useState("")
|
const [user, setUser] = useState("")
|
||||||
const { addCondition } = useRepositoryEditor()
|
const { addCondition } = useRepositoryEditor()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const onInputChange = event => {
|
const onInputChange = event => {
|
||||||
let text = event.target.value
|
let text = event.target.value
|
||||||
|
|
|
@ -14,7 +14,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
*/
|
*/
|
||||||
export default function BoxConditions({ ...props }) {
|
export default function BoxConditions({ ...props }) {
|
||||||
const { conditions } = useRepositoryEditor()
|
const { conditions } = useRepositoryEditor()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const badges = conditions.map((cond, pos) => <ConditionBadge key={pos} {...cond}/>)
|
const badges = conditions.map((cond, pos) => <ConditionBadge key={pos} {...cond}/>)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
export default function BoxLoggedIn({ ...props }) {
|
export default function BoxLoggedIn({ ...props }) {
|
||||||
const { logout } = useContext(ContextUser)
|
const { logout } = useContext(ContextUser)
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={strings.loggedInTitle} {...props}>
|
<BoxFull header={strings.loggedInTitle} {...props}>
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default function BoxLogin({ ...props }) {
|
||||||
const [error, setError] = useState(null)
|
const [error, setError] = useState(null)
|
||||||
const { login } = useContext(ContextUser)
|
const { login } = useContext(ContextUser)
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const doLogin = async () => {
|
const doLogin = async () => {
|
||||||
if(working) {
|
if(working) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import Loading from "../base/Loading"
|
||||||
import BoxFullScrollable from "../base/BoxFullScrollable"
|
import BoxFullScrollable from "../base/BoxFullScrollable"
|
||||||
import ContextLanguage from "../../contexts/ContextLanguage"
|
import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link BoxFull} listing all the user's active repositories.
|
* A {@link BoxFull} listing all the user's active repositories.
|
||||||
*
|
*
|
||||||
|
@ -25,7 +26,7 @@ export default function BoxRepositoriesActive({
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
const { user } = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
let contents
|
let contents
|
||||||
if(repositories === null) {
|
if(repositories === null) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ export default function BoxRepositoriesArchived({
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
const { user } = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
let contents
|
let contents
|
||||||
if(repositories === null) {
|
if(repositories === null) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ export default function BoxRepositoryCreate({ running, ...props }) {
|
||||||
} = useRepositoryEditor()
|
} = useRepositoryEditor()
|
||||||
|
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={strings.createRepo} {...props}>
|
<BoxFull header={strings.createRepo} {...props}>
|
||||||
|
|
|
@ -17,7 +17,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
*/
|
*/
|
||||||
export default function BoxSetServer({ ...props }) {
|
export default function BoxSetServer({ ...props }) {
|
||||||
const { server, setServer } = useContext(ContextServer)
|
const { server, setServer } = useContext(ContextServer)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={strings.server} {...props}>
|
<BoxFull header={strings.server} {...props}>
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default function BoxUserCreate({ createUser, running, ...props }) {
|
||||||
const [email, setEmail] = useState("")
|
const [email, setEmail] = useState("")
|
||||||
const [password, setPassword] = useState("")
|
const [password, setPassword] = useState("")
|
||||||
const [error, setError] = useState(undefined)
|
const [error, setError] = useState(undefined)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const onButtonClick = useCallback(
|
const onButtonClick = useCallback(
|
||||||
async () => {
|
async () => {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
|
|
||||||
|
|
||||||
export default function BoxUserList({ users, destroyUser, running, ...props }) {
|
export default function BoxUserList({ users, destroyUser, running, ...props }) {
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
let contents
|
let contents
|
||||||
if(users === null) {
|
if(users === null) {
|
||||||
|
|
|
@ -13,11 +13,11 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxWordcloud({ words, props }) {
|
export default function BoxWordcloud({ words, props }) {
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={strings.wordcloud} {...props}>
|
<BoxFull header={strings.wordcloud} {...props}>
|
||||||
<div style={{"width": "100%", "height": "100%"}}>
|
<div style={{ "width": "100%", "height": "100%" }}>
|
||||||
<ReactWordcloud
|
<ReactWordcloud
|
||||||
options={{
|
options={{
|
||||||
colors: [
|
colors: [
|
||||||
|
|
|
@ -7,7 +7,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
|
|
||||||
export default function ButtonToggleBeforeAfter({ onUpdate, className, ...props }) {
|
export default function ButtonToggleBeforeAfter({ onUpdate, className, ...props }) {
|
||||||
const [value, setValue] = useState(false)
|
const [value, setValue] = useState(false)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const onButtonClick = () => {
|
const onButtonClick = () => {
|
||||||
onUpdate(!value)
|
onUpdate(!value)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
*/
|
*/
|
||||||
export default function LoggedInUser({ ...props }) {
|
export default function LoggedInUser({ ...props }) {
|
||||||
const { user } = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
if(!user) {
|
if(!user) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -19,7 +19,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
*/
|
*/
|
||||||
export default function Logo({ className, ...props }) {
|
export default function Logo({ className, ...props }) {
|
||||||
const { theme } = useContext(ContextTheme)
|
const { theme } = useContext(ContextTheme)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
let logo
|
let logo
|
||||||
if(theme === "ThemeDark") {
|
if(theme === "ThemeDark") {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function SelectLanguage({ ...props }) {
|
export default function SelectLanguage({ ...props }) {
|
||||||
const {strings, lang, setLang} = useContext(ContextLanguage)
|
const { strings, lang, setLang } = useContext(ContextLanguage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select value={lang} onChange={event => setLang(event.target.value)} {...props}>
|
<Select value={lang} onChange={event => setLang(event.target.value)} {...props}>
|
||||||
|
|
|
@ -14,7 +14,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
*/
|
*/
|
||||||
export default function SelectTheme({ ...props }) {
|
export default function SelectTheme({ ...props }) {
|
||||||
const { theme, setTheme } = useContext(ContextTheme)
|
const { theme, setTheme } = useContext(ContextTheme)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select value={theme} onChange={e => setTheme(e.target.value)} {...props}>
|
<Select value={theme} onChange={e => setTheme(e.target.value)} {...props}>
|
||||||
|
|
|
@ -3,14 +3,7 @@ import Style from "./Sidebar.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
import Logo from "../interactive/Logo"
|
import Logo from "../interactive/Logo"
|
||||||
import ButtonSidebar from "../base/ButtonSidebar"
|
import ButtonSidebar from "../base/ButtonSidebar"
|
||||||
import {
|
import { faCog, faExclamationTriangle, faFolder, faHome, faKey, faUserCog } from "@fortawesome/free-solid-svg-icons"
|
||||||
faCog,
|
|
||||||
faExclamationTriangle,
|
|
||||||
faFolder,
|
|
||||||
faHome,
|
|
||||||
faKey,
|
|
||||||
faUserCog,
|
|
||||||
} from "@fortawesome/free-solid-svg-icons"
|
|
||||||
import ContextUser from "../../contexts/ContextUser"
|
import ContextUser from "../../contexts/ContextUser"
|
||||||
import ContextLanguage from "../../contexts/ContextLanguage"
|
import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
|
|
||||||
|
@ -26,7 +19,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
*/
|
*/
|
||||||
export default function Sidebar({ className, ...props }) {
|
export default function Sidebar({ className, ...props }) {
|
||||||
const { user } = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<aside className={classNames(Style.Sidebar, className)} {...props}>
|
<aside className={classNames(Style.Sidebar, className)} {...props}>
|
||||||
|
|
|
@ -26,7 +26,7 @@ export default function SummaryRepository(
|
||||||
{ repo, refresh, canDelete, deleteSelf, canEdit, canArchive, archiveSelf, running, className, ...props },
|
{ repo, refresh, canDelete, deleteSelf, canEdit, canArchive, archiveSelf, running, className, ...props },
|
||||||
) {
|
) {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const onRepoClick = () => {
|
const onRepoClick = () => {
|
||||||
history.push(`/repositories/${repo.id}`)
|
history.push(`/repositories/${repo.id}`)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
||||||
|
|
||||||
export default function SummaryUser({ user, destroyUser, running, ...props }) {
|
export default function SummaryUser({ user, destroyUser, running, ...props }) {
|
||||||
const { user: loggedUser } = useContext(ContextUser)
|
const { user: loggedUser } = useContext(ContextUser)
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
const buttons = <>
|
const buttons = <>
|
||||||
{loggedUser.email !== user.email ?
|
{loggedUser.email !== user.email ?
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ContextLanguage from "../contexts/ContextLanguage"
|
||||||
|
|
||||||
|
|
||||||
export default function PageAlerts({ children, className, ...props }) {
|
export default function PageAlerts({ children, className, ...props }) {
|
||||||
const {strings} = useContext(ContextLanguage)
|
const { strings } = useContext(ContextLanguage)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(Style.PageAlerts, className)} {...props}>
|
<div className={classNames(Style.PageAlerts, className)} {...props}>
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
import React, { useContext } from "react"
|
import React from "react"
|
||||||
import Style from "./PageDashboard.module.css"
|
import Style from "./PageDashboard.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
import BoxHeader from "../components/base/BoxHeader"
|
import BoxHeader from "../components/base/BoxHeader"
|
||||||
import RepositoryEditor from "../components/providers/RepositoryEditor"
|
import RepositoryEditor from "../components/providers/RepositoryEditor"
|
||||||
import ContextLanguage from "../contexts/ContextLanguage"
|
|
||||||
|
|
||||||
|
|
||||||
export default function PageDashboard({ children, className, ...props }) {
|
export default function PageDashboard({ children, className, ...props }) {
|
||||||
const {strings} = useContext(ContextLanguage)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(Style.PageHome, className)} {...props}>
|
<div className={classNames(Style.PageHome, className)} {...props}>
|
||||||
<BoxHeader className={Style.Header}>
|
<BoxHeader className={Style.Header}>
|
||||||
|
|
Loading…
Reference in a new issue