mirror of
https://github.com/pds-nest/nest.git
synced 2025-02-16 12:43:58 +00:00
✨ Allow clicking on Summaries
This commit is contained in:
parent
9c71ec422f
commit
85ae08b6ce
4 changed files with 17 additions and 3 deletions
|
@ -10,6 +10,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
* @param icon - The icon of the summary.
|
* @param icon - The icon of the summary.
|
||||||
* @param title - The title of the summary.
|
* @param title - The title of the summary.
|
||||||
* @param subtitle - The subtitle of the summary.
|
* @param subtitle - The subtitle of the summary.
|
||||||
|
* @param onClick - A function to call when the summary is clicked.
|
||||||
* @param upperLabel - The label for the upper value.
|
* @param upperLabel - The label for the upper value.
|
||||||
* @param upperValue - The upper value.
|
* @param upperValue - The upper value.
|
||||||
* @param lowerLabel - The label for the lower value.
|
* @param lowerLabel - The label for the lower value.
|
||||||
|
@ -21,11 +22,11 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export default function Summary(
|
export default function Summary(
|
||||||
{ icon, title, subtitle, upperLabel, upperValue, lowerLabel, lowerValue, buttons, className, ...props },
|
{ icon, title, subtitle, onClick, upperLabel, upperValue, lowerLabel, lowerValue, buttons, className, ...props },
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<div className={classNames(Style.Summary, className)} {...props}>
|
<div className={classNames(Style.Summary, className)} {...props}>
|
||||||
<div className={Style.Left}>
|
<div className={classNames(Style.Left, onClick ? Style.Clickable : null)} onClick={onClick}>
|
||||||
<div className={Style.IconContainer}>
|
<div className={Style.IconContainer}>
|
||||||
<FontAwesomeIcon icon={icon}/>
|
<FontAwesomeIcon icon={icon}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,6 +7,13 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Clickable:hover {
|
||||||
|
filter: brightness(110%);
|
||||||
|
}
|
||||||
|
|
||||||
.Left {
|
.Left {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
|
|
|
@ -28,6 +28,10 @@ export default function SummaryRepository(
|
||||||
const { fetchNow: archiveThis } = useBackend(fetchDataAuth, "PATCH", `/api/v1/repositories/${repo.id}`, { "close": true })
|
const { fetchNow: archiveThis } = useBackend(fetchDataAuth, "PATCH", `/api/v1/repositories/${repo.id}`, { "close": true })
|
||||||
const { fetchNow: deletThis } = useBackend(fetchDataAuth, "DELETE", `/api/v1/repositories/${repo.id}`)
|
const { fetchNow: deletThis } = useBackend(fetchDataAuth, "DELETE", `/api/v1/repositories/${repo.id}`)
|
||||||
|
|
||||||
|
const onRepoClick = () => {
|
||||||
|
history.push(`/repositories/${repo.id}`)
|
||||||
|
}
|
||||||
|
|
||||||
const onEditClick = () => {
|
const onEditClick = () => {
|
||||||
history.push(`/repositories/${repo.id}/edit`)
|
history.push(`/repositories/${repo.id}/edit`)
|
||||||
}
|
}
|
||||||
|
@ -77,6 +81,7 @@ export default function SummaryRepository(
|
||||||
icon={repo.is_active ? faFolderOpen : faFolder}
|
icon={repo.is_active ? faFolderOpen : faFolder}
|
||||||
title={repo.name}
|
title={repo.name}
|
||||||
subtitle={repo.owner ? repo.owner.username : null}
|
subtitle={repo.owner ? repo.owner.username : null}
|
||||||
|
onClick={onRepoClick}
|
||||||
upperLabel={"Created"}
|
upperLabel={"Created"}
|
||||||
upperValue={repo.start ? new Date(repo.start).toLocaleString() : null}
|
upperValue={repo.start ? new Date(repo.start).toLocaleString() : null}
|
||||||
lowerLabel={"Archived"}
|
lowerLabel={"Archived"}
|
||||||
|
|
|
@ -13,7 +13,8 @@ export default function SummaryUser({ user, destroyUser, running, ...props }) {
|
||||||
<Button
|
<Button
|
||||||
color={"Red"}
|
color={"Red"}
|
||||||
icon={faTrash}
|
icon={faTrash}
|
||||||
onClick={async () => {
|
onClick={async event => {
|
||||||
|
event.stopPropagation()
|
||||||
// TODO: Errors are not caught here. Where should they be displayed?
|
// TODO: Errors are not caught here. Where should they be displayed?
|
||||||
await destroyUser(user["email"])
|
await destroyUser(user["email"])
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue