1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-23 05:24:18 +00:00
pds-2021-g2-nest/code/frontend/src/components/interactive/BoxRepositoriesArchived.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

import React, { useContext } from "react"
2021-04-29 14:58:31 +00:00
import BoxFull from "../base/BoxFull"
import ContextUser from "../../contexts/ContextUser"
2021-05-11 16:24:51 +00:00
import SummaryRepository from "./SummaryRepository"
2021-05-12 02:22:43 +00:00
import { faFolder } from "@fortawesome/free-solid-svg-icons"
2021-04-29 14:58:31 +00:00
/**
* A {@link BoxFull} listing all the user's archived 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 BoxRepositoriesArchived({ repositories, refresh, ...props }) {
2021-05-11 14:37:15 +00:00
const { user } = useContext(ContextUser)
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-12 02:22:43 +00:00
icon={faFolder}
2021-05-11 14:33:12 +00:00
refresh={refresh}
2021-05-11 17:42:04 +00:00
canArchive={false}
2021-05-11 14:33:12 +00:00
canEdit={false}
canDelete={repo["owner"]["username"] === user["username"]}
/>
))
}
else {
2021-05-11 14:33:12 +00:00
contents = <i>There's nothing here.</i>
}
return (
<BoxFull header={"Your archived repositories"} {...props}>
{contents}
</BoxFull>
)
}