muffin-admin 3.0.3 → 3.1.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": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -19,8 +19,9 @@ import { buildAdmin, findBuilder, setupAdmin } from "./utils"
19
19
 
20
20
  export function MuffinList() {
21
21
  const { name, list } = useMuffinResourceOpts()
22
- const { fields, edit, show, limit, limitMax, filters, sort } = list
22
+ const { limit, limitMax, filters, sort } = list
23
23
 
24
+ const DataGrid = findBuilder(["list-grid", name])
24
25
  const Toolbar = findBuilder(["list-toolbar", name])
25
26
  const BulkActions = findBuilder(["list-bulk-actions", name])
26
27
 
@@ -35,10 +36,7 @@ export function MuffinList() {
35
36
  <Pagination rowsPerPageOptions={sortBy(uniq([10, 25, 50, 100, limit, limitMax]))} />
36
37
  }
37
38
  >
38
- <DatagridConfigurable rowClick={show ? "show" : edit ? "edit" : false}>
39
- {buildAdmin(["list-fields", name], fields)}
40
- {edit && <EditButton />}
41
- </DatagridConfigurable>
39
+ <DataGrid />
42
40
  </List>
43
41
  )
44
42
  }
@@ -47,6 +45,28 @@ setupAdmin(["list"], MuffinList)
47
45
  setupAdmin(["list-fields"], buildRA)
48
46
  setupAdmin(["list-filters"], buildRA)
49
47
 
48
+ function MuffinListDatagrid() {
49
+ const { name, list } = useMuffinResourceOpts()
50
+ const { fields, edit, show } = list
51
+ return (
52
+ <DatagridConfigurable rowClick={show ? "show" : edit ? "edit" : false}>
53
+ {buildAdmin(["list-fields", name], fields)}
54
+ {buildAdmin(["list-grid-buttons"], name)}
55
+ </DatagridConfigurable>
56
+ )
57
+ }
58
+
59
+ setupAdmin(["list-grid"], MuffinListDatagrid)
60
+
61
+ function MuffinListGridButtons() {
62
+ const { list } = useMuffinResourceOpts()
63
+ const { edit } = list
64
+ if (!edit) return null
65
+ return <EditButton />
66
+ }
67
+
68
+ setupAdmin(["list-grid-buttons"], MuffinListGridButtons)
69
+
50
70
  function MuffinListToolbar() {
51
71
  const {
52
72
  list: { create },