1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-10-16 20:17:25 +00:00

🔧 Use useStrings instead of useContext(ContextLanguage)

This commit is contained in:
Steffo 2021-05-24 14:13:24 +02:00
parent 1e14b1910a
commit 957a6c892f
Signed by: steffo
GPG key ID: 6965406171929D01
24 changed files with 60 additions and 60 deletions

View file

@ -1,11 +1,11 @@
import React, { useCallback, useContext } from "react"
import React, { useCallback } from "react"
import BoxFull from "../base/BoxFull"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faClock } from "@fortawesome/free-solid-svg-icons"
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import ContextLanguage from "../../contexts/ContextLanguage"
import FormInlineTimeRay from "./FormInlineTimeRay"
import { ConditionTime } from "../../objects/Condition"
import useStrings from "../../hooks/useStrings"
/**
@ -18,7 +18,7 @@ import { ConditionTime } from "../../objects/Condition"
*/
export default function BoxConditionDatetime({ ...props }) {
const { addCondition } = useRepositoryEditor()
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const submit = useCallback(
timeRay => addCondition(new ConditionTime(timeRay)),

View file

@ -1,11 +1,11 @@
import React, { useCallback, useContext } from "react"
import React, { useCallback } from "react"
import BoxFull from "../base/BoxFull"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faHashtag } from "@fortawesome/free-solid-svg-icons"
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import ContextLanguage from "../../contexts/ContextLanguage"
import FormInlineHashtag from "./FormInlineHashtag"
import { ConditionHashtag } from "../../objects/Condition"
import useStrings from "../../hooks/useStrings"
/**
@ -18,7 +18,7 @@ import { ConditionHashtag } from "../../objects/Condition"
*/
export default function BoxConditionHashtag({ ...props }) {
const { addCondition } = useRepositoryEditor()
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const submit = useCallback(
value => addCondition(new ConditionHashtag(value)),

View file

@ -1,12 +1,12 @@
import React, { useCallback, useContext } from "react"
import React, { useCallback } from "react"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faLocationArrow, faPlus } from "@fortawesome/free-solid-svg-icons"
import ButtonIconOnly from "../base/ButtonIconOnly"
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import ContextLanguage from "../../contexts/ContextLanguage"
import BoxMap from "../base/BoxMap"
import useMapAreaState from "../../hooks/useMapAreaState"
import { ConditionLocation } from "../../objects/Condition"
import useStrings from "../../hooks/useStrings"
/**
@ -20,7 +20,7 @@ import { ConditionLocation } from "../../objects/Condition"
export default function BoxConditionLocation({ ...props }) {
const mapViewHook = useMapAreaState()
const { addCondition } = useRepositoryEditor()
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const onButtonClick = useCallback(
() => addCondition(new ConditionLocation(mapViewHook.mapArea)),

View file

@ -1,11 +1,11 @@
import React, { useCallback, useContext } from "react"
import React, { useCallback } from "react"
import BoxFull from "../base/BoxFull"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faAt } from "@fortawesome/free-solid-svg-icons"
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import ContextLanguage from "../../contexts/ContextLanguage"
import FormInlineUser from "./FormInlineUser"
import { ConditionUser } from "../../objects/Condition"
import useStrings from "../../hooks/useStrings"
/**
@ -18,7 +18,7 @@ import { ConditionUser } from "../../objects/Condition"
*/
export default function BoxConditionUser({ ...props }) {
const { addCondition } = useRepositoryEditor()
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const submit = useCallback(
value => addCondition(new ConditionUser(value)),

View file

@ -1,8 +1,8 @@
import React, { useContext } from "react"
import React from "react"
import BoxFull from "../base/BoxFull"
import BadgeCondition from "./BadgeCondition"
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -14,7 +14,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
*/
export default function BoxConditions({ ...props }) {
const { conditions } = useRepositoryEditor()
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const badges = conditions.map((cond, pos) => <BadgeCondition key={pos} condition={cond}/>)

View file

@ -1,8 +1,8 @@
import React, { useContext } from "react"
import BoxFull from "../base/BoxFull"
import ContextLanguage from "../../contexts/ContextLanguage"
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
import BadgeFilter from "./BadgeFilter"
import useStrings from "../../hooks/useStrings"
/**
@ -13,7 +13,7 @@ import BadgeFilter from "./BadgeFilter"
* @constructor
*/
export default function BoxFilters({ ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const { filters } = useContext(ContextRepositoryViewer)
const badges = filters.map((filter, pos) => <BadgeFilter key={pos} filter={filter}/>)

View file

@ -7,7 +7,7 @@ import ContextUser from "../../contexts/ContextUser"
import { useHistory } from "react-router"
import Style from "./BoxLoggedIn.module.css"
import CurrentServer from "./CurrentServer"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -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 = useStrings()
return (
<BoxFull header={strings.loggedInTitle} {...props}>

View file

@ -8,7 +8,7 @@ import FormButton from "../base/formparts/FormButton"
import ContextUser from "../../contexts/ContextUser"
import { useHistory } from "react-router"
import FormAlert from "../base/formparts/FormAlert"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -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 = useStrings()
const doLogin = async () => {
if(working) {

View file

@ -1,4 +1,4 @@
import React, { useContext } from "react"
import React from "react"
import BoxFull from "../base/BoxFull"
import FormLabelled from "../base/FormLabelled"
import FormLabel from "../base/formparts/FormLabel"
@ -8,9 +8,8 @@ import Radio from "../base/Radio"
import Button from "../base/Button"
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
import FormAlert from "../base/formparts/FormAlert"
import goToOnSuccess from "../../utils/goToOnSuccess"
import { useHistory } from "react-router"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -34,7 +33,7 @@ export default function BoxRepositoryCreate({ running, ...props }) {
} = useRepositoryEditor()
const history = useHistory()
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
return (
<BoxFull header={strings.createRepo} {...props}>

View file

@ -5,7 +5,7 @@ import FormLabel from "../base/formparts/FormLabel"
import InputWithIcon from "../base/InputWithIcon"
import { faGlobe } from "@fortawesome/free-solid-svg-icons"
import ContextServer from "../../contexts/ContextServer"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -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 = useStrings()
return (
<BoxFull header={strings.server} {...props}>

View file

@ -1,4 +1,4 @@
import React, { useCallback, useContext, useState } from "react"
import React, { useCallback, useState } from "react"
import FormLabelled from "../base/FormLabelled"
import FormLabel from "../base/formparts/FormLabel"
import InputWithIcon from "../base/InputWithIcon"
@ -6,7 +6,7 @@ import { faEnvelope, faKey, faPlus, faUser } from "@fortawesome/free-solid-svg-i
import FormButton from "../base/formparts/FormButton"
import BoxFull from "../base/BoxFull"
import FormAlert from "../base/formparts/FormAlert"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -23,7 +23,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 = useStrings()
const onButtonClick = useCallback(
async () => {

View file

@ -2,12 +2,12 @@ import React, { useContext, useMemo } from "react"
import BoxFull from "../base/BoxFull"
import BoxChart from "../base/BoxChart"
import Empty from "./Empty"
import ContextLanguage from "../../contexts/ContextLanguage"
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
import useStrings from "../../hooks/useStrings"
export default function BoxVisualizationChart({ ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const { tweets } = useContext(ContextRepositoryViewer)
const chartProps = useMemo(

View file

@ -1,9 +1,9 @@
import React, { useContext, useMemo } from "react"
import BoxMap from "../base/BoxMap"
import ContextLanguage from "../../contexts/ContextLanguage"
import { Marker, Popup } from "react-leaflet"
import Coordinates from "../../objects/Coordinates"
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
import useStrings from "../../hooks/useStrings"
/**
@ -14,7 +14,7 @@ import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
* @constructor
*/
export default function BoxVisualizationMap({ ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const { tweets, mapViewHook } = useContext(ContextRepositoryViewer)
const markers = useMemo(

View file

@ -1,13 +1,13 @@
import React, { useContext, useMemo } from "react"
import FormLabelled from "../base/FormLabelled"
import FormLabel from "../base/formparts/FormLabel"
import ContextLanguage from "../../contexts/ContextLanguage"
import BoxFullScrollable from "../base/BoxFullScrollable"
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
import useStrings from "../../hooks/useStrings"
export default function BoxVisualizationStats({ ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const { tweets, words, rawTweets } = useContext(ContextRepositoryViewer)
const tweetCount = useMemo(

View file

@ -1,14 +1,14 @@
import React, { useCallback, useContext } from "react"
import BoxWordcloud from "../base/BoxWordcloud"
import ContextLanguage from "../../contexts/ContextLanguage"
import BoxFull from "../base/BoxFull"
import Empty from "./Empty"
import ContextRepositoryViewer from "../../contexts/ContextRepositoryViewer"
import { FilterContains } from "../../objects/Filter"
import useStrings from "../../hooks/useStrings"
export default function BoxVisualizationWordcloud({ ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const { words, appendFilter } = useContext(ContextRepositoryViewer)
if(words.length === 0) {

View file

@ -1,8 +1,8 @@
import React, { useContext } from "react"
import React from "react"
import Style from "./ButtonToggleBeforeAfter.module.css"
import classNames from "classnames"
import Button from "../base/Button"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -16,7 +16,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
* @constructor
*/
export default function ButtonToggleBeforeAfter({ isBefore, setBefore, className, ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const onButtonClick = () => {
setBefore(a => !a)

View file

@ -1,7 +1,7 @@
import React, { useContext } from "react"
import React from "react"
import Style from "./Empty.module.css"
import classNames from "classnames"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -13,7 +13,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
* @constructor
*/
export default function Empty({ className, ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
return (
<i className={classNames(Style.Empty, className)} {...props}>

View file

@ -2,7 +2,7 @@ import React, { useContext } from "react"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faUser } from "@fortawesome/free-solid-svg-icons"
import ContextUser from "../../contexts/ContextUser"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -14,7 +14,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
*/
export default function LoggedInUser({ ...props }) {
const { user } = useContext(ContextUser)
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
if(!user) {
return (

View file

@ -4,7 +4,7 @@ import LogoDark from "../../media/LogoDark.png"
import LogoLight from "../../media/LogoLight.png"
import ContextTheme from "../../contexts/ContextTheme"
import classNames from "classnames"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -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 = useStrings()
let logo
if(theme === "ThemeDark") {

View file

@ -1,7 +1,7 @@
import React, { useContext } from "react"
import Select from "../base/Select"
import ContextTheme from "../../contexts/ContextTheme"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -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 = useStrings()
return (
<Select value={theme} onChange={e => setTheme(e.target.value)} {...props}>

View file

@ -3,9 +3,9 @@ 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, faHome, faKey, faUserCog } from "@fortawesome/free-solid-svg-icons"
import ContextUser from "../../contexts/ContextUser"
import ContextLanguage from "../../contexts/ContextLanguage"
import useStrings from "../../hooks/useStrings"
/**
@ -18,7 +18,7 @@ import ContextLanguage from "../../contexts/ContextLanguage"
*/
export default function Sidebar({ className, ...props }) {
const { user } = useContext(ContextUser)
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
return (
<aside className={classNames(Style.Sidebar, className)} {...props}>

View file

@ -1,4 +1,4 @@
import React, { useContext } from "react"
import React from "react"
import {
faArchive,
faBell,
@ -8,12 +8,12 @@ import {
faShare,
faTrash,
} from "@fortawesome/free-solid-svg-icons"
import ContextLanguage from "../../contexts/ContextLanguage"
import SummaryBase from "../base/summary/SummaryBase"
import SummaryLeft from "../base/summary/SummaryLeft"
import SummaryLabels from "../base/summary/SummaryLabels"
import SummaryButton from "../base/summary/SummaryButton"
import SummaryRight from "../base/summary/SummaryRight"
import useStrings from "../../hooks/useStrings"
/**
@ -35,7 +35,7 @@ import SummaryRight from "../base/summary/SummaryRight"
export default function SummaryRepository(
{ repo, view, alerts, share, archive, edit, destroy, running, className, ...props },
) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
return (
<SummaryBase {...props}>

View file

@ -1,13 +1,13 @@
import React, { useContext } from "react"
import { faShare, faStar, faTrash, faUser } from "@fortawesome/free-solid-svg-icons"
import ContextLanguage from "../../contexts/ContextLanguage"
import SummaryBase from "../base/summary/SummaryBase"
import SummaryLeft from "../base/summary/SummaryLeft"
import SummaryLabels from "../base/summary/SummaryLabels"
import SummaryButton from "../base/summary/SummaryButton"
import SummaryRight from "../base/summary/SummaryRight"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import ContextUser from "../../contexts/ContextUser"
import useStrings from "../../hooks/useStrings"
/**
@ -23,7 +23,7 @@ import ContextUser from "../../contexts/ContextUser"
* @constructor
*/
export default function SummaryUser({ user, shareWithUser, unshareWithUser, destroyUser, running, ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const {user: loggedUser} = useContext(ContextUser)
return (

View file

@ -8,10 +8,11 @@ import useBackendViewset from "../hooks/useBackendViewset"
import { useParams } from "react-router"
import ContextUser from "../contexts/ContextUser"
import BoxAlert from "../components/base/BoxAlert"
import useStrings from "../hooks/useStrings"
export default function PageShare({ className, ...props }) {
const { strings } = useContext(ContextLanguage)
const strings = useStrings()
const { user: loggedUser } = useContext(ContextUser)
const { id } = useParams()