|
|
@ -20,6 +20,7 @@ import { getCollectionManager } from "../etebase-helpers";
|
|
|
|
import { CachedCollection } from "../Pim/helpers";
|
|
|
|
import { CachedCollection } from "../Pim/helpers";
|
|
|
|
|
|
|
|
|
|
|
|
import CollectionMemberAddDialog from "./CollectionMemberAddDialog";
|
|
|
|
import CollectionMemberAddDialog from "./CollectionMemberAddDialog";
|
|
|
|
|
|
|
|
import Alert from "@material-ui/lab/Alert";
|
|
|
|
|
|
|
|
|
|
|
|
interface PropsType {
|
|
|
|
interface PropsType {
|
|
|
|
collection: CachedCollection;
|
|
|
|
collection: CachedCollection;
|
|
|
@ -30,15 +31,19 @@ export default function CollectionMembers(props: PropsType) {
|
|
|
|
const [members_, setMembers] = React.useState<Etebase.CollectionMember[]>();
|
|
|
|
const [members_, setMembers] = React.useState<Etebase.CollectionMember[]>();
|
|
|
|
const [revokeUser, setRevokeUser] = React.useState<string | null>(null);
|
|
|
|
const [revokeUser, setRevokeUser] = React.useState<string | null>(null);
|
|
|
|
const [addMemberOpen, setAddMemberOpen] = React.useState(false);
|
|
|
|
const [addMemberOpen, setAddMemberOpen] = React.useState(false);
|
|
|
|
// FIXME: add error handling
|
|
|
|
const [error, setError] = React.useState<Error>();
|
|
|
|
|
|
|
|
|
|
|
|
const { collection, metadata } = props.collection;
|
|
|
|
const { collection, metadata } = props.collection;
|
|
|
|
|
|
|
|
|
|
|
|
async function fetchMembers() {
|
|
|
|
async function fetchMembers() {
|
|
|
|
const colMgr = getCollectionManager(etebase);
|
|
|
|
const colMgr = getCollectionManager(etebase);
|
|
|
|
const memberManager = colMgr.getMemberManager(collection);
|
|
|
|
const memberManager = colMgr.getMemberManager(collection);
|
|
|
|
const members = await memberManager.list();
|
|
|
|
try {
|
|
|
|
setMembers(members.data);
|
|
|
|
const members = await memberManager.list();
|
|
|
|
|
|
|
|
setMembers(members.data);
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
setError(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
React.useEffect(() => {
|
|
|
@ -70,6 +75,11 @@ export default function CollectionMembers(props: PropsType) {
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<AppBarOverride title={`${metadata.name} - Members`} />
|
|
|
|
<AppBarOverride title={`${metadata.name} - Members`} />
|
|
|
|
<Container style={{ maxWidth: "30rem" }}>
|
|
|
|
<Container style={{ maxWidth: "30rem" }}>
|
|
|
|
|
|
|
|
{error && (
|
|
|
|
|
|
|
|
<Alert color="error">
|
|
|
|
|
|
|
|
{error.toString()}
|
|
|
|
|
|
|
|
</Alert>
|
|
|
|
|
|
|
|
)}
|
|
|
|
{members ?
|
|
|
|
{members ?
|
|
|
|
<List>
|
|
|
|
<List>
|
|
|
|
<ListItem rightIcon={<IconMemberAdd />} onClick={() => setAddMemberOpen(true)}>
|
|
|
|
<ListItem rightIcon={<IconMemberAdd />} onClick={() => setAddMemberOpen(true)}>
|
|
|
|