Allow importing csv files

Change-Id: I8f4c417c1762ba6dbc0fa929ecf8262e6e8a2e42
This commit is contained in:
Michael Albert 2020-04-15 10:32:47 +02:00
parent 2240559f74
commit a2807fe281
2 changed files with 32 additions and 1 deletions

View File

@ -25,7 +25,8 @@
"react": "^16.13.1",
"react-admin": "^3.4.0",
"react-dom": "^16.13.1",
"react-scripts": "^3.4.1"
"react-scripts": "^3.4.1",
"react-admin-import-csv": "^0.2.5"
},
"scripts": {
"start": "react-scripts start",

View File

@ -21,10 +21,14 @@ import {
TextField,
TextInput,
ReferenceField,
Toolbar,
TopToolbar,
SelectInput,
regex,
Pagination,
} from "react-admin";
import { ImportButton } from "react-admin-import-csv";
import { CreateButton, ExportButton } from "ra-ui-materialui";
const UserPagination = props => (
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
@ -41,6 +45,31 @@ const UserFilter = props => (
</Filter>
);
const ListActions = props => {
const {
className,
basePath,
total,
resource,
currentSort,
filterValues,
exporter
} = props;
return (
<TopToolbar className={className}>
<CreateButton basePath={basePath} />
<ImportButton {...props} />
<ExportButton
disabled={total === 0}
resource={resource}
sort={currentSort}
filter={filterValues}
exporter={exporter}
/>
</TopToolbar>
);
};
export const UserList = props => (
<List
{...props}
@ -48,6 +77,7 @@ export const UserList = props => (
filterDefaultValues={{ guests: true, deactivated: false }}
bulkActionButtons={false}
pagination={<UserPagination />}
actions={<ListActions />}
>
<Datagrid rowClick="edit">
<ReferenceField