2021-05-18 00:04:06 +00:00
|
|
|
import React, { useContext } from "react"
|
2021-05-12 02:10:36 +00:00
|
|
|
import Loading from "../base/Loading"
|
|
|
|
import BoxFullScrollable from "../base/BoxFullScrollable"
|
|
|
|
import SummaryUser from "./SummaryUser"
|
2021-05-18 00:04:06 +00:00
|
|
|
import ContextLanguage from "../../contexts/ContextLanguage"
|
2021-05-12 02:10:36 +00:00
|
|
|
|
|
|
|
|
2021-05-23 03:03:41 +00:00
|
|
|
/**
|
|
|
|
* A {@link BoxFullScrollable} rendering an array of users as {@link SummaryUser}s.
|
|
|
|
*
|
|
|
|
* @param users - Array of users to render.
|
2021-05-23 15:35:38 +00:00
|
|
|
* @param shareWithUser - Async function to share a repository with an user, to be passed to {@link SummaryUser}.
|
|
|
|
* @param unshareWithUser - Async function to unshare a repository with an user, to be passed to {@link SummaryUser}.
|
2021-05-23 03:03:41 +00:00
|
|
|
* @param destroyUser - Async function to destroy an user, to be passed to {@link SummaryUser}.
|
|
|
|
* @param running - Whether another request is currently running.
|
|
|
|
* @param props - Additional props to pass to the box.
|
|
|
|
* @returns {JSX.Element}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2021-05-23 15:35:38 +00:00
|
|
|
export default function BoxUserList({ users, shareWithUser, unshareWithUser, destroyUser, running, ...props }) {
|
2021-05-18 00:48:34 +00:00
|
|
|
const { strings } = useContext(ContextLanguage)
|
2021-05-18 00:04:06 +00:00
|
|
|
|
2021-05-12 02:10:36 +00:00
|
|
|
let contents
|
|
|
|
if(users === null) {
|
|
|
|
contents = <Loading/>
|
|
|
|
}
|
|
|
|
else {
|
2021-05-23 15:35:38 +00:00
|
|
|
contents = users.map(user => (
|
|
|
|
<SummaryUser
|
|
|
|
key={user["email"]}
|
|
|
|
shareWithUser={shareWithUser}
|
|
|
|
unshareWithUser={unshareWithUser}
|
|
|
|
destroyUser={destroyUser}
|
|
|
|
running={running}
|
|
|
|
user={user}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)
|
2021-05-12 02:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-05-18 00:04:06 +00:00
|
|
|
<BoxFullScrollable header={strings.userList} {...props}>
|
2021-05-12 02:10:36 +00:00
|
|
|
{contents}
|
|
|
|
</BoxFullScrollable>
|
|
|
|
)
|
|
|
|
}
|