2021-04-26 20:08:52 +00:00
|
|
|
import React, { useContext } from "react"
|
2021-04-29 14:58:31 +00:00
|
|
|
import BoxFull from "../base/BoxFull"
|
2021-05-11 16:24:51 +00:00
|
|
|
import SummaryRepository from "./SummaryRepository"
|
2021-05-02 16:10:09 +00:00
|
|
|
import { faSearch } from "@fortawesome/free-solid-svg-icons"
|
2021-05-11 14:33:12 +00:00
|
|
|
import ContextUser from "../../contexts/ContextUser"
|
2021-04-26 20:08:52 +00:00
|
|
|
|
|
|
|
|
2021-04-29 14:58:31 +00:00
|
|
|
/**
|
|
|
|
* A {@link BoxFull} listing all the user's active repositories.
|
|
|
|
*
|
2021-05-11 14:33:12 +00:00
|
|
|
* @param repositories - Array of repositories to display in the box.
|
|
|
|
* @param refresh - Function that can be called to refresh the repositories list.
|
2021-04-29 14:58:31 +00:00
|
|
|
* @param props - Additional props to pass to the box.
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-05-11 14:33:12 +00:00
|
|
|
export default function BoxRepositoriesActive({ repositories, refresh, ...props }) {
|
2021-05-11 14:37:15 +00:00
|
|
|
const { user } = useContext(ContextUser)
|
2021-04-26 20:08:52 +00:00
|
|
|
|
2021-05-11 14:37:15 +00:00
|
|
|
let contents
|
2021-05-11 14:33:12 +00:00
|
|
|
if(repositories.length > 0) {
|
|
|
|
contents = repositories.map(repo => (
|
2021-05-11 16:24:51 +00:00
|
|
|
<SummaryRepository
|
2021-05-11 14:33:12 +00:00
|
|
|
key={repo["id"]}
|
2021-05-11 16:24:51 +00:00
|
|
|
repo={repo}
|
2021-05-11 14:33:12 +00:00
|
|
|
icon={faSearch}
|
|
|
|
refresh={refresh}
|
|
|
|
canArchive={true}
|
|
|
|
canEdit={true}
|
|
|
|
canDelete={repo["owner"]["username"] === user["username"]}
|
|
|
|
/>
|
|
|
|
))
|
2021-04-26 20:08:52 +00:00
|
|
|
}
|
2021-05-10 12:13:12 +00:00
|
|
|
else {
|
2021-05-11 14:33:12 +00:00
|
|
|
contents = <i>There's nothing here.</i>
|
2021-05-10 12:13:12 +00:00
|
|
|
}
|
2021-04-26 20:08:52 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<BoxFull header={"Your active repositories"} {...props}>
|
|
|
|
{contents}
|
|
|
|
</BoxFull>
|
|
|
|
)
|
|
|
|
}
|