muffin-admin 2.6.1 → 2.6.2
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/MuffinResourceList.js +1 -1
- package/dist/MuffinResourceShow.js +2 -2
- package/dist/buttons/ActionButton.d.ts +2 -2
- package/dist/buttons/ActionButton.js +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +3 -2
- package/package.json +1 -1
- package/src/MuffinResourceList.tsx +2 -2
- package/src/MuffinResourceShow.tsx +7 -3
- package/src/buttons/ActionButton.tsx +4 -4
- package/src/types.ts +9 -8
|
@@ -13,4 +13,4 @@ export function MuffinResourceList(props) {
|
|
|
13
13
|
setupAdmin(["list"], (props) => _jsx(MuffinResourceList, Object.assign({}, props)));
|
|
14
14
|
setupAdmin(["list-fields"], buildRA);
|
|
15
15
|
setupAdmin(["list-filters"], buildRA);
|
|
16
|
-
setupAdmin(["list-actions"], ({ actions, remove }) => (_jsxs(_Fragment, { children: [actions.map((props
|
|
16
|
+
setupAdmin(["list-actions"], ({ actions, remove }) => (_jsxs(_Fragment, { children: [actions.map((props) => (_jsx(BulkActionButton, Object.assign({}, props), props.id))), remove && _jsx(BulkDeleteButton, {})] })));
|
|
@@ -9,10 +9,10 @@ export function MuffinResourceShow(props) {
|
|
|
9
9
|
const ShowActions = findBuilder(["show-actions", resourceName]);
|
|
10
10
|
return (_jsx(Show, { actions: _jsx(ShowActions, Object.assign({}, props)), children: _jsx(SimpleShowLayout, { children: buildAdmin(["show-fields", resourceName], props) }) }));
|
|
11
11
|
}
|
|
12
|
+
setupAdmin(["record-actions"], ({ actions }) => actions.map((props) => _jsx(ActionButton, Object.assign({}, props), props.id)));
|
|
13
|
+
setupAdmin(["record-links"], ({ links }) => links.map(([key, props]) => _jsx(LinkAction, Object.assign({ resource: key }, props), key)));
|
|
12
14
|
setupAdmin(["show"], (props) => _jsx(MuffinResourceShow, Object.assign({}, props)));
|
|
13
15
|
setupAdmin(["show-fields"], ({ fields }) => buildRA(fields));
|
|
14
|
-
setupAdmin(["record-actions"], ({ actions }) => actions.map((props, idx) => _jsx(ActionButton, Object.assign({}, props), idx)));
|
|
15
|
-
setupAdmin(["record-links"], ({ links }) => links.map(([key, props]) => _jsx(LinkAction, Object.assign({ resource: key }, props), key)));
|
|
16
16
|
setupAdmin(["show-actions"], ({ actions, links, edit }) => {
|
|
17
17
|
const resourceName = useResourceContext();
|
|
18
18
|
const Actions = findBuilder(["record-actions", resourceName]);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { AdminAction } from "../types";
|
|
2
|
-
export declare function BulkActionButton({ label, icon, title, action }: AdminAction): import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare function ActionButton({ icon, label, title, action }: AdminAction): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function BulkActionButton({ label, icon, title, action, id }: AdminAction): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function ActionButton({ icon, label, title, action, id }: AdminAction): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,11 +3,11 @@ import { Button, useListContext, useNotify, useRecordContext, useRefresh, useRes
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { useAction } from "../hooks/useAction";
|
|
5
5
|
import { buildIcon, findBuilder } from "../utils";
|
|
6
|
-
export function BulkActionButton({ label, icon, title, action }) {
|
|
6
|
+
export function BulkActionButton({ label, icon, title, action, id }) {
|
|
7
7
|
const resource = useResourceContext();
|
|
8
8
|
const { selectedIds } = useListContext();
|
|
9
9
|
const [payloadActive, setPayloadActive] = useState(false);
|
|
10
|
-
const PayloadBuilder = findBuilder(["action", "payload",
|
|
10
|
+
const PayloadBuilder = findBuilder(["action", "payload", id]);
|
|
11
11
|
const refresh = useRefresh(), unselectAll = useUnselectAll(resource), notify = useNotify();
|
|
12
12
|
const { mutate, isLoading } = useAction(action);
|
|
13
13
|
const process = (payload) => mutate({ ids: selectedIds, payload }, {
|
|
@@ -27,11 +27,11 @@ export function BulkActionButton({ label, icon, title, action }) {
|
|
|
27
27
|
});
|
|
28
28
|
return (_jsxs(_Fragment, { children: [_jsx(Button, { label: label, title: title, onClick: () => (PayloadBuilder ? setPayloadActive(true) : process()), disabled: isLoading, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onHandle: (payload) => process(payload), onClose: () => setPayloadActive(false) }))] }));
|
|
29
29
|
}
|
|
30
|
-
export function ActionButton({ icon, label, title, action }) {
|
|
30
|
+
export function ActionButton({ icon, label, title, action, id }) {
|
|
31
31
|
const [payloadActive, setPayloadActive] = useState(false);
|
|
32
32
|
const record = useRecordContext();
|
|
33
33
|
const { mutate, isLoading } = useAction(action);
|
|
34
|
-
const PayloadBuilder = findBuilder(["action", "payload",
|
|
34
|
+
const PayloadBuilder = findBuilder(["action", "payload", id]);
|
|
35
35
|
const refresh = useRefresh(), notify = useNotify();
|
|
36
36
|
const process = (payload) => mutate({ record, payload }, {
|
|
37
37
|
onSuccess: ({ data }) => {
|