mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 14:34:19 +00:00
✨ Add Archive and Unarchive functionality
This commit is contained in:
parent
e9fe23fd63
commit
ba2dfa415b
1 changed files with 9 additions and 1 deletions
|
@ -1,10 +1,12 @@
|
||||||
import React from "react"
|
import React, { useContext } from "react"
|
||||||
import Style from "./RepositorySummaryBase.module.css"
|
import Style from "./RepositorySummaryBase.module.css"
|
||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
||||||
import Button from "../base/Button"
|
import Button from "../base/Button"
|
||||||
import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-icons"
|
import { faArchive, faPencilAlt, faTrash } from "@fortawesome/free-solid-svg-icons"
|
||||||
import { useHistory } from "react-router"
|
import { useHistory } from "react-router"
|
||||||
|
import useData from "../../hooks/useData"
|
||||||
|
import ContextUser from "../../contexts/ContextUser"
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +30,11 @@ import { useHistory } from "react-router"
|
||||||
export default function RepositorySummaryBase(
|
export default function RepositorySummaryBase(
|
||||||
{ id, owner, icon, name, start, end, isActive, canDelete, canEdit, canArchive, className, ...props }
|
{ id, owner, icon, name, start, end, isActive, canDelete, canEdit, canArchive, className, ...props }
|
||||||
) {
|
) {
|
||||||
|
const {fetchDataAuth} = useContext(ContextUser)
|
||||||
const {history} = useHistory()
|
const {history} = useHistory()
|
||||||
|
const {fetchNow: archiveThis} = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, {"close": true})
|
||||||
|
const {fetchNow: unarchiveThis} = useData(fetchDataAuth, "PATCH", `/api/v1/repositories/${id}`, {"open": true})
|
||||||
|
const {fetchNow: deletThis} = useData(fetchDataAuth, "DELETE", `/api/v1/repositories/${id}`)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(Style.RepositorySummary, className)} {...props}>
|
<div className={classNames(Style.RepositorySummary, className)} {...props}>
|
||||||
|
@ -56,6 +62,7 @@ export default function RepositorySummaryBase(
|
||||||
<Button
|
<Button
|
||||||
color={"Red"}
|
color={"Red"}
|
||||||
icon={faTrash}
|
icon={faTrash}
|
||||||
|
onClick={deletThis}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -73,6 +80,7 @@ export default function RepositorySummaryBase(
|
||||||
<Button
|
<Button
|
||||||
color={"Grey"}
|
color={"Grey"}
|
||||||
icon={faArchive}
|
icon={faArchive}
|
||||||
|
onClick={isActive ? archiveThis : unarchiveThis}
|
||||||
>
|
>
|
||||||
{isActive ? "Archive" : "Unarchive"}
|
{isActive ? "Archive" : "Unarchive"}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Reference in a new issue