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
|
||||
import React from 'react'
|
||||
import '@testing-library/jest-dom/extend-expect'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import React from "react"
|
||||
import "@testing-library/jest-dom/extend-expect"
|
||||
import { render, screen } from "@testing-library/react"
|
||||
import App from "./App"
|
||||
|
||||
test('App renders without exploding', () => {
|
||||
|
||||
test("App renders without exploding", () => {
|
||||
render(<App/>)
|
||||
expect(screen.getByRole("main")).toBeVisible()
|
||||
});
|
||||
})
|
||||
|
|
|
@ -210,5 +210,5 @@ export default {
|
|||
type: "Tyyppi",
|
||||
admin: "Ylläpitäjä",
|
||||
user: "Käyttäjä",
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ export default function BoxConditionDatetime({ ...props }) {
|
|||
const [datetime, setDatetime] = useState("")
|
||||
const [ba, setBa] = useState(false)
|
||||
const { addCondition } = useRepositoryEditor()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const onInputChange = event => {
|
||||
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 }) {
|
||||
const [hashtag, setHashtag] = useState("")
|
||||
const { addCondition } = useRepositoryEditor()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const onInputChange = event => {
|
||||
let text = event.target.value
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React, { useCallback, useContext, useEffect, useState } from "react"
|
||||
import BoxFull from "../base/BoxFull"
|
||||
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 ButtonIconOnly from "../base/ButtonIconOnly"
|
||||
import { MapContainer, TileLayer } from "react-leaflet"
|
||||
|
@ -54,7 +54,7 @@ export default function BoxConditionMap({ ...props }) {
|
|||
const [zoom, setZoom] = useState(STARTING_ZOOM)
|
||||
const [map, setMap] = useState(null)
|
||||
const { addCondition } = useRepositoryEditor()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const onMove = useCallback(
|
||||
() => {
|
||||
|
|
|
@ -25,7 +25,7 @@ const INVALID_USER_CHARACTERS = /[^a-zA-Z0-9]/g
|
|||
export default function BoxConditionUser({ ...props }) {
|
||||
const [user, setUser] = useState("")
|
||||
const { addCondition } = useRepositoryEditor()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const onInputChange = event => {
|
||||
let text = event.target.value
|
||||
|
|
|
@ -14,7 +14,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
*/
|
||||
export default function BoxConditions({ ...props }) {
|
||||
const { conditions } = useRepositoryEditor()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const badges = conditions.map((cond, pos) => <ConditionBadge key={pos} {...cond}/>)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
export default function BoxLoggedIn({ ...props }) {
|
||||
const { logout } = useContext(ContextUser)
|
||||
const history = useHistory()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<BoxFull header={strings.loggedInTitle} {...props}>
|
||||
|
|
|
@ -25,7 +25,7 @@ export default function BoxLogin({ ...props }) {
|
|||
const [error, setError] = useState(null)
|
||||
const { login } = useContext(ContextUser)
|
||||
const history = useHistory()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const doLogin = async () => {
|
||||
if(working) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import Loading from "../base/Loading"
|
|||
import BoxFullScrollable from "../base/BoxFullScrollable"
|
||||
import ContextLanguage from "../../contexts/ContextLanguage"
|
||||
|
||||
|
||||
/**
|
||||
* A {@link BoxFull} listing all the user's active repositories.
|
||||
*
|
||||
|
@ -25,7 +26,7 @@ export default function BoxRepositoriesActive({
|
|||
...props
|
||||
}) {
|
||||
const { user } = useContext(ContextUser)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
let contents
|
||||
if(repositories === null) {
|
||||
|
|
|
@ -26,7 +26,7 @@ export default function BoxRepositoriesArchived({
|
|||
...props
|
||||
}) {
|
||||
const { user } = useContext(ContextUser)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
let contents
|
||||
if(repositories === null) {
|
||||
|
|
|
@ -34,7 +34,7 @@ export default function BoxRepositoryCreate({ running, ...props }) {
|
|||
} = useRepositoryEditor()
|
||||
|
||||
const history = useHistory()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<BoxFull header={strings.createRepo} {...props}>
|
||||
|
|
|
@ -17,7 +17,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
*/
|
||||
export default function BoxSetServer({ ...props }) {
|
||||
const { server, setServer } = useContext(ContextServer)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<BoxFull header={strings.server} {...props}>
|
||||
|
|
|
@ -14,7 +14,7 @@ export default function BoxUserCreate({ createUser, running, ...props }) {
|
|||
const [email, setEmail] = useState("")
|
||||
const [password, setPassword] = useState("")
|
||||
const [error, setError] = useState(undefined)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const onButtonClick = useCallback(
|
||||
async () => {
|
||||
|
|
|
@ -6,7 +6,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
|
||||
|
||||
export default function BoxUserList({ users, destroyUser, running, ...props }) {
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
let contents
|
||||
if(users === null) {
|
||||
|
|
|
@ -13,11 +13,11 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
* @constructor
|
||||
*/
|
||||
export default function BoxWordcloud({ words, props }) {
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<BoxFull header={strings.wordcloud} {...props}>
|
||||
<div style={{"width": "100%", "height": "100%"}}>
|
||||
<div style={{ "width": "100%", "height": "100%" }}>
|
||||
<ReactWordcloud
|
||||
options={{
|
||||
colors: [
|
||||
|
|
|
@ -7,7 +7,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
|
||||
export default function ButtonToggleBeforeAfter({ onUpdate, className, ...props }) {
|
||||
const [value, setValue] = useState(false)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const onButtonClick = () => {
|
||||
onUpdate(!value)
|
||||
|
|
|
@ -14,7 +14,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
*/
|
||||
export default function LoggedInUser({ ...props }) {
|
||||
const { user } = useContext(ContextUser)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
if(!user) {
|
||||
return (
|
||||
|
|
|
@ -19,7 +19,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
*/
|
||||
export default function Logo({ className, ...props }) {
|
||||
const { theme } = useContext(ContextTheme)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
let logo
|
||||
if(theme === "ThemeDark") {
|
||||
|
|
|
@ -12,7 +12,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
* @constructor
|
||||
*/
|
||||
export default function SelectLanguage({ ...props }) {
|
||||
const {strings, lang, setLang} = useContext(ContextLanguage)
|
||||
const { strings, lang, setLang } = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<Select value={lang} onChange={event => setLang(event.target.value)} {...props}>
|
||||
|
|
|
@ -14,7 +14,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
*/
|
||||
export default function SelectTheme({ ...props }) {
|
||||
const { theme, setTheme } = useContext(ContextTheme)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<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 Logo from "../interactive/Logo"
|
||||
import ButtonSidebar from "../base/ButtonSidebar"
|
||||
import {
|
||||
faCog,
|
||||
faExclamationTriangle,
|
||||
faFolder,
|
||||
faHome,
|
||||
faKey,
|
||||
faUserCog,
|
||||
} from "@fortawesome/free-solid-svg-icons"
|
||||
import { faCog, faExclamationTriangle, faFolder, faHome, faKey, faUserCog } from "@fortawesome/free-solid-svg-icons"
|
||||
import ContextUser from "../../contexts/ContextUser"
|
||||
import ContextLanguage from "../../contexts/ContextLanguage"
|
||||
|
||||
|
@ -26,7 +19,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
*/
|
||||
export default function Sidebar({ className, ...props }) {
|
||||
const { user } = useContext(ContextUser)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<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 },
|
||||
) {
|
||||
const history = useHistory()
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const onRepoClick = () => {
|
||||
history.push(`/repositories/${repo.id}`)
|
||||
|
|
|
@ -8,7 +8,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
|
|||
|
||||
export default function SummaryUser({ user, destroyUser, running, ...props }) {
|
||||
const { user: loggedUser } = useContext(ContextUser)
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
const buttons = <>
|
||||
{loggedUser.email !== user.email ?
|
||||
|
|
|
@ -6,7 +6,7 @@ import ContextLanguage from "../contexts/ContextLanguage"
|
|||
|
||||
|
||||
export default function PageAlerts({ children, className, ...props }) {
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
const { strings } = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<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 classNames from "classnames"
|
||||
import BoxHeader from "../components/base/BoxHeader"
|
||||
import RepositoryEditor from "../components/providers/RepositoryEditor"
|
||||
import ContextLanguage from "../contexts/ContextLanguage"
|
||||
|
||||
|
||||
export default function PageDashboard({ children, className, ...props }) {
|
||||
const {strings} = useContext(ContextLanguage)
|
||||
|
||||
return (
|
||||
<div className={classNames(Style.PageHome, className)} {...props}>
|
||||
<BoxHeader className={Style.Header}>
|
||||
|
|
Loading…
Reference in a new issue