import React from "react";
import {
Datagrid,
Create,
Edit,
List,
Filter,
SimpleForm,
BooleanField,
BooleanInput,
ImageField,
PasswordInput,
TextField,
TextInput,
SearchInput,
ReferenceField,
SaveButton,
Toolbar,
regex,
} from "react-admin";
import SaveQrButton from "./SaveQrButton";
const UserFilter = props => (
);
export const UserList = props => (
}
filterDefaultValues={{ guests: true, deactivated: false }}
bulkActionButtons={false}
>
{/* Hack since the users endpoint does not give displaynames in the list*/}
);
function generateRandomUser() {
const homeserver = localStorage.getItem("home_server");
const user_id =
"@" +
Array(8)
.fill("0123456789abcdefghijklmnopqrstuvwxyz")
.map(
x =>
x[
Math.floor(
(crypto.getRandomValues(new Uint32Array(1))[0] /
(0xffffffff + 1)) *
x.length
)
]
)
.join("") +
":" +
homeserver;
const password = Array(20)
.fill(
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$"
)
.map(
x =>
x[
Math.floor(
(crypto.getRandomValues(new Uint32Array(1))[0] / (0xffffffff + 1)) *
x.length
)
]
)
.join("");
return {
id: user_id,
password: password,
};
}
// redirect to the related Author show page
const redirect = (basePath, id, data) => {
return {
pathname: "/showpdf",
state: {
id: data.id,
displayname: data.displayname,
password: data.password,
},
};
};
const UserCreateToolbar = props => (
);
// https://matrix.org/docs/spec/appendices#user-identifiers
const validateUser = regex(
/^@[a-z0-9._=\-/]+:.*/,
"synapseadmin.users.invalid_user_id"
);
export const UserCreate = props => (
}>
);
export const UserEdit = props => (
}>
);