2021-05-24 12:13:24 +00:00
|
|
|
import React from "react"
|
2021-05-24 01:42:30 +00:00
|
|
|
import {
|
|
|
|
faArchive,
|
|
|
|
faBell,
|
|
|
|
faFolder,
|
|
|
|
faFolderOpen,
|
|
|
|
faPencilAlt,
|
|
|
|
faShare,
|
|
|
|
faTrash,
|
|
|
|
} from "@fortawesome/free-solid-svg-icons"
|
2021-05-18 15:51:36 +00:00
|
|
|
import SummaryBase from "../base/summary/SummaryBase"
|
|
|
|
import SummaryLeft from "../base/summary/SummaryLeft"
|
|
|
|
import SummaryLabels from "../base/summary/SummaryLabels"
|
|
|
|
import SummaryButton from "../base/summary/SummaryButton"
|
|
|
|
import SummaryRight from "../base/summary/SummaryRight"
|
2021-05-24 12:13:24 +00:00
|
|
|
import useStrings from "../../hooks/useStrings"
|
2021-04-24 02:23:23 +00:00
|
|
|
|
|
|
|
|
2021-04-25 15:22:52 +00:00
|
|
|
/**
|
2021-05-19 17:56:41 +00:00
|
|
|
* A {@link SummaryBase} representing a repository.
|
2021-04-25 15:22:52 +00:00
|
|
|
*
|
2021-05-19 17:56:41 +00:00
|
|
|
* @param repo - The repository to display.
|
|
|
|
* @param view - Function with no parameters to call when the view repository button is clicked.
|
2021-05-24 01:42:30 +00:00
|
|
|
* @param alerts - Function with no parameters to call when the alerts button is clicked.
|
|
|
|
* @param share - Function with no parameters to call when the share repository button is clicked.
|
2021-05-19 17:56:41 +00:00
|
|
|
* @param archive - Function with no parameters to call when the archive repository button is clicked.
|
|
|
|
* @param edit - Function with no parameters to call when the edit repository button is clicked.
|
|
|
|
* @param destroy - Function with no parameters to call when the delete repository button is clicked.
|
|
|
|
* @param running - If an action is running on the viewset.
|
|
|
|
* @param className - Additional class(es) to append to the summary.
|
|
|
|
* @param props - Additional props to pass to the summary.
|
2021-04-25 15:22:52 +00:00
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-05-11 16:24:51 +00:00
|
|
|
export default function SummaryRepository(
|
2021-05-24 01:42:30 +00:00
|
|
|
{ repo, view, alerts, share, archive, edit, destroy, running, className, ...props },
|
2021-04-25 15:22:52 +00:00
|
|
|
) {
|
2021-05-24 12:13:24 +00:00
|
|
|
const strings = useStrings()
|
2021-05-10 13:22:07 +00:00
|
|
|
|
2021-04-24 02:23:23 +00:00
|
|
|
return (
|
2021-05-18 17:15:53 +00:00
|
|
|
<SummaryBase {...props}>
|
2021-05-18 15:51:36 +00:00
|
|
|
<SummaryLeft
|
|
|
|
icon={repo.is_active ? faFolderOpen : faFolder}
|
|
|
|
title={repo.name}
|
|
|
|
subtitle={repo.owner ? repo.owner.username : null}
|
2021-05-19 17:56:41 +00:00
|
|
|
onClick={view}
|
2021-05-23 15:35:38 +00:00
|
|
|
disabled={running}
|
2021-05-18 15:51:36 +00:00
|
|
|
/>
|
2021-05-19 17:56:41 +00:00
|
|
|
|
2021-05-18 15:51:36 +00:00
|
|
|
<SummaryLabels
|
|
|
|
upperLabel={strings.created}
|
|
|
|
upperValue={repo.start ? new Date(repo.start).toLocaleString() : null}
|
|
|
|
lowerLabel={strings.archived}
|
|
|
|
lowerValue={repo.end ? new Date(repo.end).toLocaleString() : null}
|
|
|
|
/>
|
2021-05-19 17:56:41 +00:00
|
|
|
|
2021-05-23 14:28:53 +00:00
|
|
|
{share ?
|
|
|
|
<SummaryButton
|
2021-05-24 01:42:30 +00:00
|
|
|
color={"Grey"}
|
2021-05-23 14:28:53 +00:00
|
|
|
icon={faShare}
|
|
|
|
onClick={() => share()}
|
|
|
|
disabled={running}
|
|
|
|
>
|
|
|
|
{strings.share}
|
|
|
|
</SummaryButton>
|
|
|
|
: null}
|
|
|
|
|
2021-05-24 01:42:30 +00:00
|
|
|
{alerts ?
|
2021-05-20 10:16:01 +00:00
|
|
|
<SummaryButton
|
2021-05-24 01:42:30 +00:00
|
|
|
color={"Green"}
|
|
|
|
icon={faBell}
|
|
|
|
onClick={() => alerts()}
|
2021-05-20 10:16:01 +00:00
|
|
|
disabled={running}
|
|
|
|
>
|
2021-05-24 01:42:30 +00:00
|
|
|
{strings.alerts}
|
2021-05-20 10:16:01 +00:00
|
|
|
</SummaryButton>
|
2021-05-24 01:42:30 +00:00
|
|
|
: null}
|
|
|
|
|
|
|
|
{edit ?
|
|
|
|
<SummaryButton
|
|
|
|
color={"Yellow"}
|
|
|
|
icon={faPencilAlt}
|
|
|
|
onClick={() => edit()}
|
|
|
|
disabled={running}
|
|
|
|
>
|
|
|
|
{strings.edit}
|
|
|
|
</SummaryButton>
|
|
|
|
: null}
|
2021-05-19 17:56:41 +00:00
|
|
|
|
|
|
|
{archive ?
|
2021-05-20 10:16:01 +00:00
|
|
|
<SummaryButton
|
|
|
|
color={"Grey"}
|
|
|
|
icon={faArchive}
|
2021-05-23 14:28:53 +00:00
|
|
|
onClick={() => archive()}
|
2021-05-20 10:16:01 +00:00
|
|
|
disabled={running}
|
|
|
|
>
|
|
|
|
{strings.archive}
|
|
|
|
</SummaryButton>
|
|
|
|
: null}
|
2021-05-19 17:56:41 +00:00
|
|
|
|
2021-05-24 01:42:30 +00:00
|
|
|
{destroy ?
|
2021-05-20 10:16:01 +00:00
|
|
|
<SummaryButton
|
2021-05-24 01:42:30 +00:00
|
|
|
color={"Red"}
|
|
|
|
icon={faTrash}
|
|
|
|
onClick={() => destroy()}
|
2021-05-20 10:16:01 +00:00
|
|
|
disabled={running}
|
|
|
|
>
|
2021-05-24 01:42:30 +00:00
|
|
|
{strings.delete}
|
2021-05-20 10:16:01 +00:00
|
|
|
</SummaryButton>
|
2021-05-24 01:42:30 +00:00
|
|
|
: null}
|
2021-05-19 17:56:41 +00:00
|
|
|
|
2021-05-18 15:51:36 +00:00
|
|
|
<SummaryRight/>
|
|
|
|
</SummaryBase>
|
2021-04-24 02:23:23 +00:00
|
|
|
)
|
2021-05-18 15:51:36 +00:00
|
|
|
}
|