2021-04-26 20:08:52 +00:00
|
|
|
import React, { useContext } from "react"
|
2021-05-11 16:24:51 +00:00
|
|
|
import SummaryRepository from "./SummaryRepository"
|
2021-05-12 02:22:43 +00:00
|
|
|
import { faFolderOpen } from "@fortawesome/free-solid-svg-icons"
|
2021-05-11 14:33:12 +00:00
|
|
|
import ContextUser from "../../contexts/ContextUser"
|
2021-05-12 23:07:17 +00:00
|
|
|
import Loading from "../base/Loading"
|
|
|
|
import BoxFullScrollable from "../base/BoxFullScrollable"
|
2021-05-18 00:04:06 +00:00
|
|
|
import ContextLanguage from "../../contexts/ContextLanguage"
|
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.
|
2021-05-12 23:07:17 +00:00
|
|
|
* @param archiveRepository - Function to be called when archive is pressed on a repository summary.
|
|
|
|
* @param destroyRepository - Function to be called when delete is pressed on a repository summary.
|
|
|
|
* @param running - If an action is currently running.
|
2021-04-29 14:58:31 +00:00
|
|
|
* @param props - Additional props to pass to the box.
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-05-13 15:05:33 +00:00
|
|
|
export default function BoxRepositoriesActive({
|
|
|
|
repositories,
|
|
|
|
archiveRepository,
|
|
|
|
destroyRepository,
|
|
|
|
running,
|
|
|
|
...props
|
|
|
|
}) {
|
2021-05-11 14:37:15 +00:00
|
|
|
const { user } = useContext(ContextUser)
|
2021-05-18 00:04:06 +00:00
|
|
|
const {strings} = useContext(ContextLanguage)
|
2021-04-26 20:08:52 +00:00
|
|
|
|
2021-05-11 14:37:15 +00:00
|
|
|
let contents
|
2021-05-12 23:07:17 +00:00
|
|
|
if(repositories === null) {
|
|
|
|
contents = <Loading/>
|
|
|
|
}
|
|
|
|
else if(repositories.length === 0) {
|
2021-05-18 00:04:06 +00:00
|
|
|
contents = <i>{strings.emptyMenu}.</i>
|
2021-05-12 23:07:17 +00:00
|
|
|
}
|
|
|
|
else {
|
2021-05-11 14:33:12 +00:00
|
|
|
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={faFolderOpen}
|
2021-05-12 23:07:17 +00:00
|
|
|
archiveSelf={() => archiveRepository(repo["id"])}
|
|
|
|
deleteSelf={() => destroyRepository(repo["id"])}
|
2021-05-11 14:33:12 +00:00
|
|
|
canArchive={true}
|
|
|
|
canEdit={true}
|
|
|
|
canDelete={repo["owner"]["username"] === user["username"]}
|
2021-05-12 23:07:17 +00:00
|
|
|
running={running}
|
2021-05-11 14:33:12 +00:00
|
|
|
/>
|
|
|
|
))
|
2021-04-26 20:08:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-05-18 00:04:06 +00:00
|
|
|
<BoxFullScrollable header={strings.menuActive} {...props}>
|
2021-04-26 20:08:52 +00:00
|
|
|
{contents}
|
2021-05-12 23:07:17 +00:00
|
|
|
</BoxFullScrollable>
|
2021-04-26 20:08:52 +00:00
|
|
|
)
|
|
|
|
}
|