mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-24 22:14:18 +00:00
🧹 Reformat code
This commit is contained in:
parent
70fe072b5e
commit
809d86758c
50 changed files with 207 additions and 194 deletions
|
@ -22,7 +22,7 @@ export default function ButtonSidebar({ icon, children, to, className, ...props
|
||||||
path: to,
|
path: to,
|
||||||
strict: true,
|
strict: true,
|
||||||
exact: true,
|
exact: true,
|
||||||
});
|
})
|
||||||
|
|
||||||
if(match) {
|
if(match) {
|
||||||
className = classNames(Style.Active, className)
|
className = classNames(Style.Active, className)
|
||||||
|
|
|
@ -17,7 +17,7 @@ import make_icon from "../../utils/make_icon"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function InputWithIcon({ icon, className, ...props }) {
|
export default function InputWithIcon({ icon, className, ...props }) {
|
||||||
const [isFocused, setFocused] = useState(false);
|
const [isFocused, setFocused] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(Style.InputWithIcon, isFocused ? Style.Focused : null, className)}>
|
<div className={classNames(Style.InputWithIcon, isFocused ? Style.Focused : null, className)}>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from "react"
|
||||||
import Style from "./Radio.module.css"
|
import Style from "./Radio.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A radio button.
|
* A radio button.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,10 @@ import classNames from "classnames"
|
||||||
*/
|
*/
|
||||||
export default function TextArea({ resize, children, className, ...props }) {
|
export default function TextArea({ resize, children, className, ...props }) {
|
||||||
return (
|
return (
|
||||||
<textarea className={classNames(Style.TextArea, resize ? Style.TextAreaResizable : Style.TextAreaNoResize, className)} {...props}>
|
<textarea
|
||||||
|
className={classNames(Style.TextArea, resize
|
||||||
|
? Style.TextAreaResizable
|
||||||
|
: Style.TextAreaNoResize, className)} {...props}>
|
||||||
{children}
|
{children}
|
||||||
</textarea>
|
</textarea>
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useState } from "react"
|
import React, { 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, faClock, faPlus } from "@fortawesome/free-solid-svg-icons"
|
import { faClock, faPlus } from "@fortawesome/free-solid-svg-icons"
|
||||||
import InputWithIcon from "../base/InputWithIcon"
|
import InputWithIcon from "../base/InputWithIcon"
|
||||||
import FormInline from "../base/FormInline"
|
import FormInline from "../base/FormInline"
|
||||||
import Style from "./BoxConditionDatetime.module.css"
|
import Style from "./BoxConditionDatetime.module.css"
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import React, { useCallback, useState, useRef, useMemo, useEffect } from "react"
|
import React, { useCallback, 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 { faMapPin, faPlus } from "@fortawesome/free-solid-svg-icons"
|
import { faMapPin, faPlus } from "@fortawesome/free-solid-svg-icons"
|
||||||
import FormInline from "../base/FormInline"
|
|
||||||
import Style from "./BoxConditionMap.module.css"
|
import Style from "./BoxConditionMap.module.css"
|
||||||
import ButtonIconOnly from "../base/ButtonIconOnly"
|
import ButtonIconOnly from "../base/ButtonIconOnly"
|
||||||
import { MapContainer, Marker, TileLayer } from "react-leaflet"
|
import { MapContainer, TileLayer } from "react-leaflet"
|
||||||
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
|
import useRepositoryEditor from "../../hooks/useRepositoryEditor"
|
||||||
import Condition from "../../utils/Condition"
|
import Condition from "../../utils/Condition"
|
||||||
|
|
||||||
|
@ -59,19 +58,21 @@ export default function BoxConditionMap({ ...props }) {
|
||||||
() => {
|
() => {
|
||||||
setPosition(map.getCenter())
|
setPosition(map.getCenter())
|
||||||
},
|
},
|
||||||
[map]
|
[map],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onZoom = useCallback(
|
const onZoom = useCallback(
|
||||||
() => {
|
() => {
|
||||||
setZoom(map.getZoom())
|
setZoom(map.getZoom())
|
||||||
},
|
},
|
||||||
[map]
|
[map],
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if(map === null) return
|
if(map === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
map.on("move", onMove)
|
map.on("move", onMove)
|
||||||
map.on("zoom", onZoom)
|
map.on("zoom", onZoom)
|
||||||
|
@ -80,7 +81,7 @@ export default function BoxConditionMap({ ...props }) {
|
||||||
map.off("zoom", onZoom)
|
map.off("zoom", onZoom)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[map]
|
[map],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onButtonClick = () => {
|
const onButtonClick = () => {
|
||||||
|
@ -90,7 +91,7 @@ export default function BoxConditionMap({ ...props }) {
|
||||||
|
|
||||||
addCondition(new Condition(
|
addCondition(new Condition(
|
||||||
"COORDINATES",
|
"COORDINATES",
|
||||||
`< ${radius} ${position.lat} ${position.lng}`
|
`< ${radius} ${position.lat} ${position.lng}`,
|
||||||
))
|
))
|
||||||
setPosition(STARTING_POSITION)
|
setPosition(STARTING_POSITION)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,12 @@ export default function BoxLoggedIn({ ...props }) {
|
||||||
You are currently logged in at <CurrentServer/> as <LoggedInUser/>.
|
You are currently logged in at <CurrentServer/> as <LoggedInUser/>.
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button color={"Red"} onClick={() => {
|
<Button
|
||||||
|
color={"Red"} onClick={() => {
|
||||||
logout()
|
logout()
|
||||||
history.push("/login")
|
history.push("/login")
|
||||||
}} icon={faSignOutAlt}>Logout</Button>
|
}} icon={faSignOutAlt}
|
||||||
|
>Logout</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</BoxFull>
|
</BoxFull>
|
||||||
|
|
|
@ -27,7 +27,7 @@ export default function BoxLogin({ ...props }) {
|
||||||
|
|
||||||
const doLogin = async () => {
|
const doLogin = async () => {
|
||||||
if(working) {
|
if(working) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setWorking(true)
|
setWorking(true)
|
||||||
|
|
|
@ -17,7 +17,7 @@ import ContextUser from "../../contexts/ContextUser"
|
||||||
export default function BoxRepositoriesActive({ repositories, refresh, ...props }) {
|
export default function BoxRepositoriesActive({ repositories, refresh, ...props }) {
|
||||||
const { user } = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
|
|
||||||
let contents;
|
let contents
|
||||||
if(repositories.length > 0) {
|
if(repositories.length > 0) {
|
||||||
contents = repositories.map(repo => (
|
contents = repositories.map(repo => (
|
||||||
<RepositorySummaryBase
|
<RepositorySummaryBase
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
||||||
export default function BoxRepositoriesArchived({ repositories, refresh, ...props }) {
|
export default function BoxRepositoriesArchived({ repositories, refresh, ...props }) {
|
||||||
const { user } = useContext(ContextUser)
|
const { user } = useContext(ContextUser)
|
||||||
|
|
||||||
let contents;
|
let contents
|
||||||
if(repositories.length > 0) {
|
if(repositories.length > 0) {
|
||||||
contents = repositories.map(repo => (
|
contents = repositories.map(repo => (
|
||||||
<RepositorySummaryBase
|
<RepositorySummaryBase
|
||||||
|
|
|
@ -34,7 +34,12 @@ export default function BoxRepositoryCreate({ ...props }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={"Create repository"} {...props}>
|
<BoxFull header={"Create repository"} {...props}>
|
||||||
<FormLabelled onSubmit={e => {e.preventDefault(); save()}}>
|
<FormLabelled
|
||||||
|
onSubmit={e => {
|
||||||
|
e.preventDefault()
|
||||||
|
save()
|
||||||
|
}}
|
||||||
|
>
|
||||||
<FormLabel htmlFor={"repo-name"} text={"Repository name"}>
|
<FormLabel htmlFor={"repo-name"} text={"Repository name"}>
|
||||||
<InputWithIcon
|
<InputWithIcon
|
||||||
id={"repo-name"}
|
id={"repo-name"}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import ContextServer from "../../contexts/ContextServer"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxSetServer({ ...props }) {
|
export default function BoxSetServer({ ...props }) {
|
||||||
const {server, setServer} = useContext(ContextServer);
|
const { server, setServer } = useContext(ContextServer)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoxFull header={"Choose server"} {...props}>
|
<BoxFull header={"Choose server"} {...props}>
|
||||||
|
|
|
@ -65,10 +65,12 @@ export default function ConditionBadge({ ...condition }) {
|
||||||
{displayedContent}
|
{displayedContent}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ButtonSmallX onClick={() => {
|
<ButtonSmallX
|
||||||
|
onClick={() => {
|
||||||
console.debug(`Removing Condition: `, condition)
|
console.debug(`Removing Condition: `, condition)
|
||||||
removeRawCondition(condition)
|
removeRawCondition(condition)
|
||||||
}}/>
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import ContextServer from "../../contexts/ContextServer"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function CurrentServer({ ...props }) {
|
export default function CurrentServer({ ...props }) {
|
||||||
const {server} = useContext(ContextServer);
|
const { server } = useContext(ContextServer)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<b {...props}>
|
<b {...props}>
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"a b"
|
"a b";
|
||||||
;
|
|
||||||
grid-template-columns: 250px 1fr;
|
grid-template-columns: 250px 1fr;
|
||||||
|
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import ContextUser from "../../contexts/ContextUser"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function LoggedInUser({ ...props }) {
|
export default function LoggedInUser({ ...props }) {
|
||||||
const {user} = useContext(ContextUser);
|
const { user } = useContext(ContextUser)
|
||||||
|
|
||||||
if(!user) {
|
if(!user) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default function Logo({ className, ...props }) {
|
||||||
// It's perfectly fine!
|
// It's perfectly fine!
|
||||||
const { theme } = useContext(ContextTheme)
|
const { theme } = useContext(ContextTheme)
|
||||||
|
|
||||||
let logo;
|
let logo
|
||||||
if(theme === "ThemeDark") {
|
if(theme === "ThemeDark") {
|
||||||
logo = LogoDark
|
logo = LogoDark
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import ContextUser from "../../contexts/ContextUser"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function RepositorySummaryBase(
|
export default function RepositorySummaryBase(
|
||||||
{ id, refresh, owner, icon, name, start, end, is_active, canDelete, canEdit, canArchive, className, ...props }
|
{ id, refresh, owner, icon, name, start, end, is_active, canDelete, canEdit, canArchive, className, ...props },
|
||||||
) {
|
) {
|
||||||
const { fetchDataAuth } = useContext(ContextUser)
|
const { fetchDataAuth } = useContext(ContextUser)
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
"a b"
|
"a b"
|
||||||
"a c"
|
"a c"
|
||||||
"a d"
|
"a d"
|
||||||
"a e"
|
"a e";
|
||||||
;
|
|
||||||
grid-template-columns: auto 1fr;
|
grid-template-columns: auto 1fr;
|
||||||
grid-template-rows: 5px 1fr 1fr 5px;
|
grid-template-rows: 5px 1fr 1fr 5px;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import ContextTheme from "../../contexts/ContextTheme"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function SelectTheme({ ...props }) {
|
export default function SelectTheme({ ...props }) {
|
||||||
const {theme, setTheme} = useContext(ContextTheme);
|
const { theme, setTheme } = useContext(ContextTheme)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select value={theme} onChange={e => setTheme(e.target.value)} {...props}>
|
<Select value={theme} onChange={e => setTheme(e.target.value)} {...props}>
|
||||||
|
|
|
@ -73,7 +73,7 @@ export default function RepositoryEditor({
|
||||||
}
|
}
|
||||||
fetchNow()
|
fetchNow()
|
||||||
},
|
},
|
||||||
[id, body, fetchNow]
|
[id, body, fetchNow],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ export default function RepositoryEditor({
|
||||||
setRawConditions(conditions)
|
setRawConditions(conditions)
|
||||||
setEvaluationMode(evaluationMode)
|
setEvaluationMode(evaluationMode)
|
||||||
},
|
},
|
||||||
[name, isActive, start, end, conditions, evaluationMode]
|
[name, isActive, start, end, conditions, evaluationMode],
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ export default function RepositoryEditor({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for duplicates
|
// Check for duplicates
|
||||||
let duplicate = null;
|
let duplicate = null
|
||||||
for(const oldCond of _conditions) {
|
for(const oldCond of _conditions) {
|
||||||
if(newCond.type === oldCond.type && newCond.content === oldCond.content) {
|
if(newCond.type === oldCond.type && newCond.content === oldCond.content) {
|
||||||
duplicate = oldCond
|
duplicate = oldCond
|
||||||
|
@ -119,11 +119,12 @@ export default function RepositoryEditor({
|
||||||
console.debug("Adding ", newCond, " to the Repository Conditions")
|
console.debug("Adding ", newCond, " to the Repository Conditions")
|
||||||
appendRawCondition(newCond)
|
appendRawCondition(newCond)
|
||||||
},
|
},
|
||||||
[_conditions]
|
[_conditions],
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextRepositoryEditor.Provider value={{
|
<ContextRepositoryEditor.Provider
|
||||||
|
value={{
|
||||||
id,
|
id,
|
||||||
name: _name, setName,
|
name: _name, setName,
|
||||||
isActive: _isActive, setActive,
|
isActive: _isActive, setActive,
|
||||||
|
@ -133,7 +134,8 @@ export default function RepositoryEditor({
|
||||||
evaluationMode: _evaluationMode, setEvaluationMode,
|
evaluationMode: _evaluationMode, setEvaluationMode,
|
||||||
error, loading,
|
error, loading,
|
||||||
revert, save,
|
revert, save,
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<div className={classNames(Style.RepositoryEditor, className)}>
|
<div className={classNames(Style.RepositoryEditor, className)}>
|
||||||
<BoxConditionMap className={Style.SearchByZone}/>
|
<BoxConditionMap className={Style.SearchByZone}/>
|
||||||
<BoxConditionHashtag className={Style.SearchByHashtags}/>
|
<BoxConditionHashtag className={Style.SearchByHashtags}/>
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
"b d"
|
"b d"
|
||||||
"b e"
|
"b e"
|
||||||
"b f"
|
"b f"
|
||||||
"b g"
|
"b g";
|
||||||
;
|
|
||||||
grid-template-columns: 400px 1fr;
|
grid-template-columns: 400px 1fr;
|
||||||
grid-template-rows: auto auto auto 1fr auto;
|
grid-template-rows: auto auto auto 1fr auto;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {createContext} from "react";
|
import { createContext } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {createContext} from "react";
|
import { createContext } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {createContext} from "react";
|
import { createContext } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,6 @@ import {createContext} from "react";
|
||||||
const ContextTheme = createContext({
|
const ContextTheme = createContext({
|
||||||
isSet: false,
|
isSet: false,
|
||||||
theme: "ThemeDark",
|
theme: "ThemeDark",
|
||||||
setTheme: () => console.error("Trying to setTheme while outside a ContextTheme.Provider!")
|
setTheme: () => console.error("Trying to setTheme while outside a ContextTheme.Provider!"),
|
||||||
})
|
})
|
||||||
export default ContextTheme
|
export default ContextTheme
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {createContext} from "react";
|
import { createContext } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,10 +14,10 @@ export default function useArrayState(def) {
|
||||||
newSingle => {
|
newSingle => {
|
||||||
console.debug("Appending ", newSingle, " to ArrayState")
|
console.debug("Appending ", newSingle, " to ArrayState")
|
||||||
setValue(
|
setValue(
|
||||||
oldArray => [...oldArray, newSingle]
|
oldArray => [...oldArray, newSingle],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
[]
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
const spliceValue = useCallback(
|
const spliceValue = useCallback(
|
||||||
|
@ -28,20 +28,20 @@ export default function useArrayState(def) {
|
||||||
// TODO: Hope this doesn't break anything...
|
// TODO: Hope this doesn't break anything...
|
||||||
oldArray.splice(position, 1)
|
oldArray.splice(position, 1)
|
||||||
return oldArray
|
return oldArray
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
[]
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
const removeValue = useCallback(
|
const removeValue = useCallback(
|
||||||
remValue => {
|
remValue => {
|
||||||
console.debug("Removing ", remValue, " from ArrayState")
|
console.debug("Removing ", remValue, " from ArrayState")
|
||||||
setValue(
|
setValue(
|
||||||
oldArray => oldArray.filter(item => JSON.stringify(item) !== JSON.stringify(remValue))
|
oldArray => oldArray.filter(item => JSON.stringify(item) !== JSON.stringify(remValue)),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
[]
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
return { value, setValue, appendValue, spliceValue, removeValue }
|
return { value, setValue, appendValue, spliceValue, removeValue }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useEffect, useState } from "react"
|
import { useCallback, useState } from "react"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,15 +28,17 @@ export default function useData(fetchData, method, path, body, init) {
|
||||||
const _data = await fetchData(method, path, body, init)
|
const _data = await fetchData(method, path, body, init)
|
||||||
console.debug(`Displaying data of ${method} ${path}: `, _data)
|
console.debug(`Displaying data of ${method} ${path}: `, _data)
|
||||||
setData(_data)
|
setData(_data)
|
||||||
} catch(e) {
|
}
|
||||||
|
catch(e) {
|
||||||
console.debug(`Displaying error of ${method} ${path}: `, e)
|
console.debug(`Displaying error of ${method} ${path}: `, e)
|
||||||
setError(e)
|
setError(e)
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
console.debug(`Stopping loading of ${method} ${path}...`)
|
console.debug(`Stopping loading of ${method} ${path}...`)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[fetchData, method, path, body, init]
|
[fetchData, method, path, body, init],
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +54,7 @@ export default function useData(fetchData, method, path, body, init) {
|
||||||
|
|
||||||
await load()
|
await load()
|
||||||
},
|
},
|
||||||
[load]
|
[load],
|
||||||
)
|
)
|
||||||
|
|
||||||
return { data, error, loading, fetchNow }
|
return { data, error, loading, fetchNow }
|
||||||
|
|
|
@ -16,11 +16,13 @@ export default function useDataImmediately(fetchData, method, path, body, init)
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if(!(loading || data || error)) {
|
if(!(
|
||||||
|
loading || data || error
|
||||||
|
)) {
|
||||||
fetchNow()
|
fetchNow()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[data, error, loading, fetchNow]
|
[data, error, loading, fetchNow],
|
||||||
)
|
)
|
||||||
|
|
||||||
return { data, error, loading, fetchNow }
|
return { data, error, loading, fetchNow }
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default function useLocalStorageState(key, def) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [value, setValue] = useState(load());
|
const [value, setValue] = useState(load())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a value to the {@link localStorage}.
|
* Save a value to the {@link localStorage}.
|
||||||
|
@ -43,7 +43,7 @@ export default function useLocalStorageState(key, def) {
|
||||||
console.warn(`Can't save ${key}; localStorage doesn't seem to be available...`)
|
console.warn(`Can't save ${key}; localStorage doesn't seem to be available...`)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[key]
|
[key],
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ export default function useLocalStorageState(key, def) {
|
||||||
setValue(value)
|
setValue(value)
|
||||||
save(value)
|
save(value)
|
||||||
},
|
},
|
||||||
[save]
|
[save],
|
||||||
)
|
)
|
||||||
|
|
||||||
return [value, setAndSave]
|
return [value, setAndSave]
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"a"
|
"a"
|
||||||
"b"
|
"b";
|
||||||
;
|
|
||||||
|
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"a"
|
"a"
|
||||||
"b"
|
"b";
|
||||||
;
|
|
||||||
grid-template-rows: auto 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
|
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|
|
@ -6,17 +6,14 @@ import RepositoryEditor from "../components/providers/RepositoryEditor"
|
||||||
import useDataImmediately from "../hooks/useDataImmediately"
|
import useDataImmediately from "../hooks/useDataImmediately"
|
||||||
import ContextUser from "../contexts/ContextUser"
|
import ContextUser from "../contexts/ContextUser"
|
||||||
import BoxAlert from "../components/base/BoxAlert"
|
import BoxAlert from "../components/base/BoxAlert"
|
||||||
import RepositorySummaryBase from "../components/interactive/RepositorySummaryBase"
|
|
||||||
import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
|
||||||
import Loading from "../components/base/Loading"
|
import Loading from "../components/base/Loading"
|
||||||
import BoxFull from "../components/base/BoxFull"
|
|
||||||
|
|
||||||
|
|
||||||
export default function PageEdit({ id, className, ...props }) {
|
export default function PageEdit({ id, className, ...props }) {
|
||||||
const { fetchDataAuth } = useContext(ContextUser)
|
const { fetchDataAuth } = useContext(ContextUser)
|
||||||
const { data, error } = useDataImmediately(fetchDataAuth, "GET", `/api/v1/repositories/${id}`)
|
const { data, error } = useDataImmediately(fetchDataAuth, "GET", `/api/v1/repositories/${id}`)
|
||||||
|
|
||||||
let contents;
|
let contents
|
||||||
if(error) {
|
if(error) {
|
||||||
contents = <BoxAlert color={"Red"}>{error.toString()}</BoxAlert>
|
contents = <BoxAlert color={"Red"}>{error.toString()}</BoxAlert>
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default function PageRepositories({ children, className, ...props }) {
|
||||||
const { fetchDataAuth } = useContext(ContextUser)
|
const { fetchDataAuth } = useContext(ContextUser)
|
||||||
const { data, error, fetchNow: refresh } = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/")
|
const { data, error, fetchNow: refresh } = useDataImmediately(fetchDataAuth, "GET", "/api/v1/repositories/")
|
||||||
|
|
||||||
let contents;
|
let contents
|
||||||
if(error) {
|
if(error) {
|
||||||
contents = <BoxAlert color={"Red"}>{error}</BoxAlert>
|
contents = <BoxAlert color={"Red"}>{error}</BoxAlert>
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"a"
|
"a"
|
||||||
"b"
|
"b";
|
||||||
;
|
|
||||||
|
|
||||||
grid-gap: 10px;
|
grid-gap: 10px;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,9 @@ export default function convertToLocalISODate(date) {
|
||||||
const tzHours = Math.abs(Math.floor(tz / 60)).toString().padStart(2, "0")
|
const tzHours = Math.abs(Math.floor(tz / 60)).toString().padStart(2, "0")
|
||||||
|
|
||||||
// Find the minutes
|
// Find the minutes
|
||||||
const tzMinutes = (tz % 60).toString().padStart(2, "0")
|
const tzMinutes = (
|
||||||
|
tz % 60
|
||||||
|
).toString().padStart(2, "0")
|
||||||
|
|
||||||
// Replace the naive part with the aware part
|
// Replace the naive part with the aware part
|
||||||
return naive.replace("Z", `${tz < 0 ? "-" : "+"}${tzHours}${tzMinutes}`)
|
return naive.replace("Z", `${tz < 0 ? "-" : "+"}${tzHours}${tzMinutes}`)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
|
|
||||||
export default function make_icon(icon, className) {
|
export default function make_icon(icon, className) {
|
||||||
if(isValidElement(icon)) {
|
if(isValidElement(icon)) {
|
||||||
return <span className={className}>icon</span>;
|
return <span className={className}>icon</span>
|
||||||
}
|
}
|
||||||
else if(icon) {
|
else if(icon) {
|
||||||
return (
|
return (
|
||||||
|
@ -12,6 +12,6 @@ export default function make_icon(icon, className) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue