|
|
@ -22,6 +22,8 @@ import { CachedCollection } from "../Pim/helpers";
|
|
|
|
|
|
|
|
|
|
|
|
import CollectionMemberAddDialog from "./CollectionMemberAddDialog";
|
|
|
|
import CollectionMemberAddDialog from "./CollectionMemberAddDialog";
|
|
|
|
import Alert from "@material-ui/lab/Alert";
|
|
|
|
import Alert from "@material-ui/lab/Alert";
|
|
|
|
|
|
|
|
import { pushMessage } from "../store/actions";
|
|
|
|
|
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
|
|
|
|
|
|
|
|
interface PropsType {
|
|
|
|
interface PropsType {
|
|
|
|
collection: CachedCollection;
|
|
|
|
collection: CachedCollection;
|
|
|
@ -29,10 +31,10 @@ interface PropsType {
|
|
|
|
|
|
|
|
|
|
|
|
export default function CollectionMembers(props: PropsType) {
|
|
|
|
export default function CollectionMembers(props: PropsType) {
|
|
|
|
const etebase = useCredentials()!;
|
|
|
|
const etebase = useCredentials()!;
|
|
|
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const [members, setMembers] = React.useState<Etebase.CollectionMember[]>();
|
|
|
|
const [members, setMembers] = React.useState<Etebase.CollectionMember[]>();
|
|
|
|
const [revokeUser, setRevokeUser] = React.useState<Etebase.CollectionMember | null>(null);
|
|
|
|
const [revokeUser, setRevokeUser] = React.useState<Etebase.CollectionMember | null>(null);
|
|
|
|
const [addMemberOpen, setAddMemberOpen] = React.useState(false);
|
|
|
|
const [addMemberOpen, setAddMemberOpen] = React.useState(false);
|
|
|
|
const [inviteSuccessOpen, setInviteSuccessOpen] = React.useState(false);
|
|
|
|
|
|
|
|
const [error, setError] = React.useState<Error>();
|
|
|
|
const [error, setError] = React.useState<Error>();
|
|
|
|
|
|
|
|
|
|
|
|
const { collection, metadata } = props.collection;
|
|
|
|
const { collection, metadata } = props.collection;
|
|
|
@ -71,6 +73,7 @@ export default function CollectionMembers(props: PropsType) {
|
|
|
|
await memberManager.remove(revokeUser!.username);
|
|
|
|
await memberManager.remove(revokeUser!.username);
|
|
|
|
await fetchMembers();
|
|
|
|
await fetchMembers();
|
|
|
|
setRevokeUser(null);
|
|
|
|
setRevokeUser(null);
|
|
|
|
|
|
|
|
dispatch(pushMessage({ message: "Removed member", severity: "success" }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function onMemberAdd(username: string, pubkey: Uint8Array, accessLevel: Etebase.CollectionAccessLevel) {
|
|
|
|
async function onMemberAdd(username: string, pubkey: Uint8Array, accessLevel: Etebase.CollectionAccessLevel) {
|
|
|
@ -78,7 +81,7 @@ export default function CollectionMembers(props: PropsType) {
|
|
|
|
await inviteMgr.invite(collection, username, pubkey, accessLevel);
|
|
|
|
await inviteMgr.invite(collection, username, pubkey, accessLevel);
|
|
|
|
await fetchMembers();
|
|
|
|
await fetchMembers();
|
|
|
|
setAddMemberOpen(false);
|
|
|
|
setAddMemberOpen(false);
|
|
|
|
setInviteSuccessOpen(true);
|
|
|
|
dispatch(pushMessage({ message: "Invitation sent", severity: "success" }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
@ -149,17 +152,6 @@ export default function CollectionMembers(props: PropsType) {
|
|
|
|
onClose={() => setAddMemberOpen(false)}
|
|
|
|
onClose={() => setAddMemberOpen(false)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<ConfirmationDialog
|
|
|
|
|
|
|
|
title="Invite user"
|
|
|
|
|
|
|
|
labelOk="OK"
|
|
|
|
|
|
|
|
open={inviteSuccessOpen}
|
|
|
|
|
|
|
|
onOk={() => setInviteSuccessOpen(false)}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
Invitation sent. User will be added once the invitation has been accepted.
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</ConfirmationDialog>
|
|
|
|
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|