muffin-admin 2.8.2 → 2.9.1

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.1",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -11,7 +11,6 @@ import {
11
11
  import { buildRA } from "./buildRA"
12
12
  import { ActionButton } from "./buttons"
13
13
  import { useMuffinAdminOpts, useMuffinResourceOpts } from "./hooks"
14
- import { AdminAction } from "./types"
15
14
  import { buildAdmin, findBuilder, setupAdmin } from "./utils"
16
15
 
17
16
  export function MuffinResourceEdit() {
@@ -21,11 +20,11 @@ export function MuffinResourceEdit() {
21
20
  const { edit, name } = useMuffinResourceOpts()
22
21
  if (!edit) return null
23
22
 
24
- const { actions, inputs, remove, ...opts } = edit
25
- const Actions = findBuilder(["edit-actions", name])
23
+ const { inputs, remove } = edit
24
+ const Actions = findBuilder(["edit-actions", name]) as unknown as any
26
25
 
27
26
  return (
28
- <Edit actions={<Actions actions={actions} />} mutationMode={mutationMode} {...opts}>
27
+ <Edit actions={<Actions />} mutationMode={mutationMode}>
29
28
  <SimpleForm
30
29
  toolbar={
31
30
  <Toolbar>
@@ -48,7 +47,10 @@ export function MuffinResourceEdit() {
48
47
 
49
48
  setupAdmin(["edit"], MuffinResourceEdit)
50
49
 
51
- function MuffinResourceEditActions({ actions }: { actions: AdminAction[] }) {
50
+ function MuffinResourceEditActions() {
51
+ const { edit } = useMuffinResourceOpts()
52
+ if (!edit) return null
53
+ const { actions = [] } = edit
52
54
  return (
53
55
  <TopToolbar>
54
56
  {actions.map((props, idx) => (
@@ -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)