muffin-admin 2.8.2 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "2.8.2",
3
+ "version": "2.9.0",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -1,33 +1,44 @@
1
1
  import sortBy from "lodash/sortBy"
2
2
  import uniq from "lodash/uniq"
3
- import { BulkDeleteButton, Datagrid, EditButton, List, ListActions, Pagination } from "react-admin"
3
+ import {
4
+ BulkDeleteButton,
5
+ CreateButton,
6
+ DatagridConfigurable,
7
+ EditButton,
8
+ ExportButton,
9
+ FilterButton,
10
+ List,
11
+ Pagination,
12
+ SelectColumnsButton,
13
+ TopToolbar,
14
+ } from "react-admin"
4
15
  import { buildRA } from "./buildRA"
5
16
  import { BulkActionButton } from "./buttons"
6
17
  import { useMuffinResourceOpts } from "./hooks"
7
- import { AdminAction } from "./types"
8
18
  import { buildAdmin, findBuilder, setupAdmin } from "./utils"
9
19
 
10
20
  export function MuffinResourceList() {
11
21
  const { name, list } = useMuffinResourceOpts()
12
- const { fields, create, edit, show, limit, limitMax, filters, actions, remove, sort } = list
22
+ const { fields, edit, show, limit, limitMax, filters, sort } = list
13
23
 
14
24
  const Actions = findBuilder(["list-actions", name])
25
+ const BulkActions = findBuilder(["list-bulk-actions", name])
15
26
 
16
27
  return (
17
28
  <List
18
29
  sort={sort}
19
30
  perPage={limit}
20
- actions={<ListActions hasCreate={create} />}
31
+ actions={<Actions />}
21
32
  filters={buildAdmin(["list-filters", name], filters)}
22
- bulkActionButtons={<Actions actions={actions} remove={remove} />}
33
+ bulkActionButtons={<BulkActions />}
23
34
  pagination={
24
35
  <Pagination rowsPerPageOptions={sortBy(uniq([10, 25, 50, 100, limit, limitMax]))} />
25
36
  }
26
37
  >
27
- <Datagrid rowClick={show ? "show" : edit ? "edit" : false}>
38
+ <DatagridConfigurable rowClick={show ? "show" : edit ? "edit" : false}>
28
39
  {buildAdmin(["list-fields", name], fields)}
29
40
  {edit && <EditButton />}
30
- </Datagrid>
41
+ </DatagridConfigurable>
31
42
  </List>
32
43
  )
33
44
  }
@@ -37,13 +48,25 @@ setupAdmin(["list-fields"], buildRA)
37
48
 
38
49
  setupAdmin(["list-filters"], buildRA)
39
50
 
40
- function MuffinResourceListActions({
41
- actions,
42
- remove,
43
- }: {
44
- actions: AdminAction[]
45
- remove?: boolean
46
- }) {
51
+ function MuffinListActions() {
52
+ const {
53
+ list: { create },
54
+ } = useMuffinResourceOpts()
55
+ return (
56
+ <TopToolbar>
57
+ <SelectColumnsButton />
58
+ <FilterButton />
59
+ {create && <CreateButton />}
60
+ <ExportButton />
61
+ </TopToolbar>
62
+ )
63
+ }
64
+ setupAdmin(["list-actions"], MuffinListActions)
65
+
66
+ function MuffinListBulkActions() {
67
+ const {
68
+ list: { actions, remove },
69
+ } = useMuffinResourceOpts()
47
70
  return (
48
71
  <>
49
72
  {actions.map((props) => (
@@ -54,4 +77,4 @@ function MuffinResourceListActions({
54
77
  )
55
78
  }
56
79
 
57
- setupAdmin(["list-actions"], MuffinResourceListActions)
80
+ setupAdmin(["list-bulk-actions"], MuffinListBulkActions)