1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-30 00:14:19 +00:00
pds-2021-g2-nest/nest_frontend/routes/PageRepositoriesList.js

74 lines
2.8 KiB
JavaScript
Raw Normal View History

import React, { useCallback, useContext } from "react"
import useBackendViewset from "../hooks/useBackendViewset"
import BoxRepositories from "../components/interactive/BoxRepositories"
import { useHistory } from "react-router"
import ContextLanguage from "../contexts/ContextLanguage"
2021-05-24 03:02:07 +00:00
import BoxHeader from "../components/base/BoxHeader"
import { faHome, faPlus } from "@fortawesome/free-solid-svg-icons"
2021-05-25 15:10:40 +00:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
2021-05-25 02:06:14 +00:00
import PageWithHeader from "../components/base/layout/PageWithHeader"
import ButtonHeader from "../components/base/ButtonHeader"
import BodyHorizontalHalves from "../components/base/layout/BodyHorizontalHalves"
2021-04-21 16:21:30 +00:00
2021-05-25 02:09:47 +00:00
export default function PageRepositoriesList() {
const bv = useBackendViewset("/api/v1/repositories/", "id")
const history = useHistory()
2021-05-20 10:16:01 +00:00
const { strings } = useContext(ContextLanguage)
const archive = useCallback(
async (pk) => {
await bv.apiRequest("PATCH", `/api/v1/repositories/${pk}`, {
"close": true,
})
2021-05-19 22:47:59 +00:00
await bv.retrieveResource(pk)
2021-05-11 15:05:38 +00:00
},
2021-05-15 16:05:13 +00:00
[bv],
2021-05-11 15:05:38 +00:00
)
2021-05-11 14:33:12 +00:00
2021-04-21 16:21:30 +00:00
return (
2021-05-25 02:06:14 +00:00
<PageWithHeader
header={
<BoxHeader>
<FontAwesomeIcon icon={faHome}/> {strings.dashboard}
</BoxHeader>
}
buttons={
<ButtonHeader
2021-05-24 03:02:07 +00:00
icon={faPlus}
color={"Green"}
onClick={() => history.push("/repositories/create")}
>
{strings.createRepo}
2021-05-25 02:06:14 +00:00
</ButtonHeader>
}
>
<BodyHorizontalHalves
upper={
<BoxRepositories
header={strings.menuActive}
loading={!bv.firstLoad}
running={bv.running}
repositories={bv.resources.filter(r => r.is_active)}
view={pk => history.push(`/repositories/${pk}`)}
share={pk => history.push(`/repositories/${pk}/share`)}
alerts={pk => history.push(`/repositories/${pk}/alerts/`)}
2021-05-25 02:06:14 +00:00
archive={archive}
edit={pk => history.push(`/repositories/${pk}/edit`)}
/>
}
lower={
<BoxRepositories
header={strings.menuArchived}
loading={!bv.firstLoad}
running={bv.running}
repositories={bv.resources.filter(r => !r.is_active)}
view={pk => history.push(`/repositories/${pk}`)}
destroy={bv.destroyResource}
/>
}
/>
2021-05-25 02:06:14 +00:00
</PageWithHeader>
2021-04-21 16:21:30 +00:00
)
}