muffin-admin 3.2.2 → 3.3.12

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.2.2",
3
+ "version": "3.3.12",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "js-cookie": "^3.0.5",
27
27
  "react": "^18.3.1",
28
- "react-admin": "^4.16.18",
28
+ "react-admin": "^5.0.3",
29
29
  "react-dom": "^18.3.1",
30
30
  "validator": "^13.12.0"
31
31
  },
@@ -2,6 +2,7 @@ import sortBy from "lodash/sortBy"
2
2
  import uniq from "lodash/uniq"
3
3
  import {
4
4
  BulkDeleteButton,
5
+ BulkExportButton,
5
6
  CreateButton,
6
7
  DatagridConfigurable,
7
8
  EditButton,
@@ -23,7 +24,6 @@ export function MuffinList() {
23
24
 
24
25
  const DataGrid = findBuilder(["list-grid", name])
25
26
  const Toolbar = findBuilder(["list-toolbar", name])
26
- const BulkActions = findBuilder(["list-bulk-actions", name])
27
27
 
28
28
  return (
29
29
  <List
@@ -31,7 +31,6 @@ export function MuffinList() {
31
31
  perPage={limit}
32
32
  actions={<Toolbar />}
33
33
  filters={buildAdmin(["list-filters", name], filters)}
34
- bulkActionButtons={<BulkActions />}
35
34
  pagination={
36
35
  <Pagination rowsPerPageOptions={sortBy(uniq([10, 25, 50, 100, limit, limitMax]))} />
37
36
  }
@@ -48,8 +47,12 @@ setupAdmin(["list-filters"], buildRA)
48
47
  function MuffinListDatagrid() {
49
48
  const { name, list } = useMuffinResourceOpts()
50
49
  const { fields, edit, show } = list
50
+ const BulkActions = findBuilder(["list-bulk-actions", name])
51
51
  return (
52
- <DatagridConfigurable rowClick={show ? "show" : edit ? "edit" : false}>
52
+ <DatagridConfigurable
53
+ rowClick={show ? "show" : edit ? "edit" : false}
54
+ bulkActionButtons={<BulkActions />}
55
+ >
53
56
  {buildAdmin(["list-fields", name], fields)}
54
57
  {buildAdmin(["list-grid-buttons", name])}
55
58
  </DatagridConfigurable>
@@ -91,6 +94,7 @@ function MuffinListBulkActions() {
91
94
  {actions.map((props) => (
92
95
  <BulkActionButton key={props.id} {...props} />
93
96
  ))}
97
+ <BulkExportButton />
94
98
  {remove && <BulkDeleteButton />}
95
99
  </>
96
100
  )
@@ -9,7 +9,7 @@ export function ActionButton({ icon, label, title, action, id }: AdminAction) {
9
9
  const [payloadActive, setPayloadActive] = useState(false)
10
10
  const record = useRecordContext()
11
11
  const resource = useResourceContext()
12
- const { mutate, isLoading } = useAction(action, {})
12
+ const { mutate, isPending } = useAction(action, {})
13
13
 
14
14
  const PayloadBuilder = findBuilder(["action", "payload", id, resource])
15
15
 
@@ -19,7 +19,7 @@ export function ActionButton({ icon, label, title, action, id }: AdminAction) {
19
19
  label={label}
20
20
  title={title}
21
21
  onClick={() => (PayloadBuilder ? setPayloadActive(true) : mutate({ record }))}
22
- disabled={isLoading}
22
+ disabled={isPending}
23
23
  >
24
24
  {buildIcon(icon)}
25
25
  </Button>
@@ -36,7 +36,7 @@ export function ActionButton({ icon, label, title, action, id }: AdminAction) {
36
36
 
37
37
  export function BulkActionButton({ label, icon, title, action, id }: AdminAction) {
38
38
  const { selectedIds } = useListContext()
39
- const { mutate, isLoading } = useAction(action)
39
+ const { mutate, isPending } = useAction(action)
40
40
  const resource = useResourceContext()
41
41
  const [payloadActive, setPayloadActive] = useState(false)
42
42
 
@@ -48,7 +48,7 @@ export function BulkActionButton({ label, icon, title, action, id }: AdminAction
48
48
  label={label}
49
49
  title={title}
50
50
  onClick={() => (PayloadBuilder ? setPayloadActive(true) : mutate({ ids: selectedIds }))}
51
- disabled={isLoading}
51
+ disabled={isPending}
52
52
  >
53
53
  {buildIcon(icon)}
54
54
  </Button>
@@ -1,3 +1,4 @@
1
+ import { UseMutationOptions, useMutation } from "@tanstack/react-query"
1
2
  import {
2
3
  useDataProvider,
3
4
  useNotify,
@@ -5,7 +6,6 @@ import {
5
6
  useResourceContext,
6
7
  useUnselectAll,
7
8
  } from "react-admin"
8
- import { UseMutationOptions, useMutation } from "react-query"
9
9
  import { MuffinDataprovider, TActionProps } from "../dataprovider"
10
10
 
11
11
  export function useAction(
@@ -17,7 +17,9 @@ export function useAction(
17
17
  const resource = useResourceContext()
18
18
  const unselectAll = useUnselectAll(resource)
19
19
  const dataProvider = useDataProvider() as ReturnType<typeof MuffinDataprovider>
20
- return useMutation((params: TActionProps) => dataProvider.runAction(resource, action, params), {
20
+
21
+ return useMutation({
22
+ mutationFn: (params: TActionProps) => dataProvider.runAction(resource, action, params),
21
23
  onSuccess: ({ data }) => {
22
24
  if (data && data.message) notify(data.message, { type: "success" })
23
25
  if (data && data.redirectTo) window.location = data.redirectTo