muffin-admin 2.8.0 → 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/dist/types.d.ts CHANGED
@@ -42,6 +42,7 @@ export type AdminResourceProps = {
42
42
  limit: number;
43
43
  limitMax: number;
44
44
  actions: AdminAction[];
45
+ create: boolean;
45
46
  filters: AdminInput[];
46
47
  fields: AdminField[];
47
48
  show: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -1,32 +1,44 @@
1
1
  import sortBy from "lodash/sortBy"
2
2
  import uniq from "lodash/uniq"
3
- import { BulkDeleteButton, Datagrid, EditButton, List, 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, 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}
31
+ actions={<Actions />}
20
32
  filters={buildAdmin(["list-filters", name], filters)}
21
- bulkActionButtons={<Actions actions={actions} remove={remove} />}
33
+ bulkActionButtons={<BulkActions />}
22
34
  pagination={
23
35
  <Pagination rowsPerPageOptions={sortBy(uniq([10, 25, 50, 100, limit, limitMax]))} />
24
36
  }
25
37
  >
26
- <Datagrid rowClick={show ? "show" : edit ? "edit" : false}>
38
+ <DatagridConfigurable rowClick={show ? "show" : edit ? "edit" : false}>
27
39
  {buildAdmin(["list-fields", name], fields)}
28
40
  {edit && <EditButton />}
29
- </Datagrid>
41
+ </DatagridConfigurable>
30
42
  </List>
31
43
  )
32
44
  }
@@ -36,13 +48,25 @@ setupAdmin(["list-fields"], buildRA)
36
48
 
37
49
  setupAdmin(["list-filters"], buildRA)
38
50
 
39
- function MuffinResourceListActions({
40
- actions,
41
- remove,
42
- }: {
43
- actions: AdminAction[]
44
- remove?: boolean
45
- }) {
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()
46
70
  return (
47
71
  <>
48
72
  {actions.map((props) => (
@@ -53,4 +77,4 @@ function MuffinResourceListActions({
53
77
  )
54
78
  }
55
79
 
56
- setupAdmin(["list-actions"], MuffinResourceListActions)
80
+ setupAdmin(["list-bulk-actions"], MuffinListBulkActions)
package/src/types.ts CHANGED
@@ -43,6 +43,7 @@ export type AdminResourceProps = {
43
43
  limit: number
44
44
  limitMax: number
45
45
  actions: AdminAction[]
46
+ create: boolean
46
47
  filters: AdminInput[]
47
48
  fields: AdminField[]
48
49
  // Enable show button