Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | 7x 7x 7x 7x 7x 7x 7x 7x 7x | import { useSetRecoilState, useRecoilValue } from "recoil";
import { format } from "date-fns";
import { MainTable, Button } from "@canonical/react-components";
import { publisherMatchesFilterQuery } from "../../utils";
import {
filterQueryState,
publisherState,
activeInviteEmailState,
} from "../../state/atoms";
import { filteredCollaboratorsListState } from "../../state/selectors";
type Props = {
setShowRevokeModal: (showRevokeModal: boolean) => void;
};
function Collaborators({ setShowRevokeModal }: Props) {
const setActiveInviteEmail = useSetRecoilState(activeInviteEmailState);
const collaboratorsList = useRecoilValue(filteredCollaboratorsListState);
const filterQuery = useRecoilValue(filterQueryState);
const publisher = useRecoilValue(publisherState);
const publisherTableRow = {
columns: [
{
content: (
<>
{publisher ? publisher?.["display-name"] : ""}
<div className="p-status-label--information">Owner</div>
</>
),
className: "u-truncate",
},
{
content: publisher ? publisher?.email : "",
className: "u-truncate",
},
{
content: "",
},
{
content: "",
},
],
};
const collaboratorTableRows = collaboratorsList.map((collaborator) => {
return {
columns: [
{
content: collaborator?.account?.["display-name"],
className: "u-truncate",
},
{
content: collaborator?.account?.email,
className: "u-truncate",
},
{
content:
collaborator["created-at"] &&
format(new Date(collaborator["created-at"]), "dd/MM/yyyy"),
},
{
content: (
<Button
dense
className="u-no-margin--bottom"
onClick={() => {
setShowRevokeModal(true);
setActiveInviteEmail(collaborator?.account?.email);
}}
>
Revoke
</Button>
),
className: "u-align--right",
},
],
};
});
let tableRows = collaboratorTableRows;
Iif (publisher) {
if (!filterQuery || publisherMatchesFilterQuery(publisher, filterQuery)) {
tableRows = [publisherTableRow, ...collaboratorTableRows];
}
}
return (
<MainTable
responsive
headers={[
{
content: "Users",
heading: "Users",
},
{
content: "Email",
heading: "Email",
},
{
content: "Accepted on",
heading: "Accepted on",
},
{
content: "",
heading: "Actions",
},
]}
rows={tableRows}
/>
);
}
export default Collaborators;
|