mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 14:34:19 +00:00
🐛 Fix repository display bug
This commit is contained in:
parent
86ed277f31
commit
e4ac241a03
3 changed files with 31 additions and 11 deletions
|
@ -5,6 +5,7 @@ import useData from "../../hooks/useData"
|
||||||
import RepositorySummaryBase from "./RepositorySummaryBase"
|
import RepositorySummaryBase from "./RepositorySummaryBase"
|
||||||
import Loading from "../base/Loading"
|
import Loading from "../base/Loading"
|
||||||
import BoxAlert from "../base/BoxAlert"
|
import BoxAlert from "../base/BoxAlert"
|
||||||
|
import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,9 +16,9 @@ import BoxAlert from "../base/BoxAlert"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxRepositoriesActive({ ...props }) {
|
export default function BoxRepositoriesActive({ ...props }) {
|
||||||
const {fetchDataAuth} = useContext(ContextUser)
|
const {user, fetchDataAuth} = useContext(ContextUser)
|
||||||
const {data, started, loading, error} = useData(fetchDataAuth, "GET", "/api/v1/repositories/", {
|
const {data, started, loading, error} = useData(fetchDataAuth, "GET", "/api/v1/repositories/", {
|
||||||
"onlyAlive": true,
|
"onlyActive": true,
|
||||||
})
|
})
|
||||||
|
|
||||||
let contents;
|
let contents;
|
||||||
|
@ -30,7 +31,15 @@ export default function BoxRepositoriesActive({ ...props }) {
|
||||||
else {
|
else {
|
||||||
let repositories = [...data["owner"], ...data["spectator"]]
|
let repositories = [...data["owner"], ...data["spectator"]]
|
||||||
if(repositories.length > 0) {
|
if(repositories.length > 0) {
|
||||||
contents = repositories.map(repo => <RepositorySummaryBase {...repo}/>)
|
contents = repositories.map(repo => (
|
||||||
|
<RepositorySummaryBase
|
||||||
|
{...repo}
|
||||||
|
icon={faSearch}
|
||||||
|
canArchive={true}
|
||||||
|
canEdit={true}
|
||||||
|
canDelete={repo["owner"]["username"] === user["username"]}
|
||||||
|
/>
|
||||||
|
))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
contents = <i>There's nothing here.</i>
|
contents = <i>There's nothing here.</i>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import useData from "../../hooks/useData"
|
||||||
import RepositorySummaryBase from "./RepositorySummaryBase"
|
import RepositorySummaryBase from "./RepositorySummaryBase"
|
||||||
import Loading from "../base/Loading"
|
import Loading from "../base/Loading"
|
||||||
import BoxAlert from "../base/BoxAlert"
|
import BoxAlert from "../base/BoxAlert"
|
||||||
|
import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +16,7 @@ import BoxAlert from "../base/BoxAlert"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function BoxRepositoriesArchived({ ...props }) {
|
export default function BoxRepositoriesArchived({ ...props }) {
|
||||||
const {fetchDataAuth} = useContext(ContextUser)
|
const {user, fetchDataAuth} = useContext(ContextUser)
|
||||||
const {data, started, loading, error} = useData(fetchDataAuth, "GET", "/api/v1/repositories/", {
|
const {data, started, loading, error} = useData(fetchDataAuth, "GET", "/api/v1/repositories/", {
|
||||||
"onlyDead": true,
|
"onlyDead": true,
|
||||||
})
|
})
|
||||||
|
@ -30,7 +31,15 @@ export default function BoxRepositoriesArchived({ ...props }) {
|
||||||
else {
|
else {
|
||||||
let repositories = [...data["owner"], ...data["spectator"]]
|
let repositories = [...data["owner"], ...data["spectator"]]
|
||||||
if(repositories.length > 0) {
|
if(repositories.length > 0) {
|
||||||
contents = repositories.map(repo => <RepositorySummaryBase {...repo}/>)
|
contents = repositories.map(repo => (
|
||||||
|
<RepositorySummaryBase
|
||||||
|
{...repo}
|
||||||
|
icon={faSearch}
|
||||||
|
canArchive={true}
|
||||||
|
canEdit={false}
|
||||||
|
canDelete={repo["owner"]["username"] === user["username"]}
|
||||||
|
/>
|
||||||
|
))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
contents = <i>There's nothing here.</i>
|
contents = <i>There's nothing here.</i>
|
||||||
|
|
|
@ -10,10 +10,12 @@ import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-ico
|
||||||
* A long line representing a repository in a list.
|
* A long line representing a repository in a list.
|
||||||
*
|
*
|
||||||
* @param icon - The FontAwesome IconDefinition that represents the repository.
|
* @param icon - The FontAwesome IconDefinition that represents the repository.
|
||||||
* @param title - The title of the repository.
|
* @param name - The title of the repository.
|
||||||
* @todo What goes in the details field?
|
* @todo What goes in the details field?
|
||||||
* @param details - Whatever should be rendered in the details field.
|
* @param details - Whatever should be rendered in the details field.
|
||||||
* @param startDate - The start date of the repository.
|
* @param start - The start date of the repository.
|
||||||
|
* @param end - The end date of the repository.
|
||||||
|
* @param isActive - Whether the repository is active or not.
|
||||||
* @param canDelete - If the Delete button should be displayed or not.
|
* @param canDelete - If the Delete button should be displayed or not.
|
||||||
* @param canEdit - If the Edit button should be displayed or not.
|
* @param canEdit - If the Edit button should be displayed or not.
|
||||||
* @param canArchive - If the Archive button should be displayed or not.
|
* @param canArchive - If the Archive button should be displayed or not.
|
||||||
|
@ -23,7 +25,7 @@ import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-ico
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function RepositorySummaryBase(
|
export default function RepositorySummaryBase(
|
||||||
{ icon, title, details, startDate, canDelete, canEdit, canArchive, className, ...props }
|
{ icon, name, details, start, end, isActive, canDelete, canEdit, canArchive, className, ...props }
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(Style.RepositorySummary, className)} {...props}>
|
<div className={classNames(Style.RepositorySummary, className)} {...props}>
|
||||||
|
@ -32,10 +34,10 @@ export default function RepositorySummaryBase(
|
||||||
<FontAwesomeIcon icon={icon}/>
|
<FontAwesomeIcon icon={icon}/>
|
||||||
</div>
|
</div>
|
||||||
<div className={Style.Title}>
|
<div className={Style.Title}>
|
||||||
{title}
|
{name}
|
||||||
</div>
|
</div>
|
||||||
<div className={Style.StartDate}>
|
<div className={Style.StartDate}>
|
||||||
{startDate}
|
{start}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={Style.Middle}>
|
<div className={Style.Middle}>
|
||||||
|
@ -49,7 +51,7 @@ export default function RepositorySummaryBase(
|
||||||
<Button color={"Yellow"} icon={faPencilAlt}>Edit</Button>
|
<Button color={"Yellow"} icon={faPencilAlt}>Edit</Button>
|
||||||
: null}
|
: null}
|
||||||
{canArchive ?
|
{canArchive ?
|
||||||
<Button color={"Grey"} icon={faArchive}>Archive</Button>
|
<Button color={"Grey"} icon={faArchive}>{isActive ? "Archive" : "Unarchive"}</Button>
|
||||||
: null}
|
: null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue