muffin-admin 1.44.0 → 1.44.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/cjs/buttons/ActionButton.js +7 -5
- package/dist/cjs/index.js +9 -1
- package/dist/cjs/views/show.js +18 -9
- package/dist/esm/buttons/ActionButton.js +5 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/views/show.js +18 -9
- package/package.json +1 -1
- package/src/buttons/ActionButton.jsx +3 -8
- package/src/index.js +1 -0
- package/src/views/show.jsx +20 -11
|
@@ -9,7 +9,7 @@ exports["default"] = exports.BulkActionButton = exports.ActionButton = void 0;
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _reactAdmin = require("react-admin");
|
|
11
11
|
var icons = _interopRequireWildcard(require("@mui/icons-material"));
|
|
12
|
-
var
|
|
12
|
+
var _useAction2 = _interopRequireDefault(require("../hooks/useAction"));
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
15
|
var BulkActionButton = function BulkActionButton(_ref) {
|
|
@@ -23,7 +23,7 @@ var BulkActionButton = function BulkActionButton(_ref) {
|
|
|
23
23
|
unselectAll = (0, _reactAdmin.useUnselectAll)(resource),
|
|
24
24
|
notify = (0, _reactAdmin.useNotify)(),
|
|
25
25
|
Icon = icons[icon];
|
|
26
|
-
var mutation = (0,
|
|
26
|
+
var mutation = (0, _useAction2["default"])(resource, action);
|
|
27
27
|
var onClick = function onClick() {
|
|
28
28
|
mutation.mutate({
|
|
29
29
|
action: action,
|
|
@@ -59,12 +59,14 @@ var ActionButton = function ActionButton(props) {
|
|
|
59
59
|
resource = props.resource,
|
|
60
60
|
action = props.action;
|
|
61
61
|
var record = (0, _reactAdmin.useRecordContext)();
|
|
62
|
-
var
|
|
62
|
+
var _useAction = (0, _useAction2["default"])(resource, action),
|
|
63
|
+
mutate = _useAction.mutate,
|
|
64
|
+
isLoading = _useAction.isLoading;
|
|
63
65
|
var refresh = (0, _reactAdmin.useRefresh)(),
|
|
64
66
|
notify = (0, _reactAdmin.useNotify)(),
|
|
65
67
|
Icon = icons[icon];
|
|
66
68
|
var onClick = function onClick() {
|
|
67
|
-
|
|
69
|
+
mutate({
|
|
68
70
|
record: record
|
|
69
71
|
}, {
|
|
70
72
|
onSuccess: function onSuccess(_ref3) {
|
|
@@ -86,7 +88,7 @@ var ActionButton = function ActionButton(props) {
|
|
|
86
88
|
label: label,
|
|
87
89
|
title: title,
|
|
88
90
|
onClick: onClick,
|
|
89
|
-
disabled:
|
|
91
|
+
disabled: isLoading
|
|
90
92
|
}, Icon && /*#__PURE__*/_react["default"].createElement(Icon, null));
|
|
91
93
|
};
|
|
92
94
|
exports.ActionButton = ActionButton;
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,8 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
var _exportNames = {
|
|
8
8
|
initAdmin: true,
|
|
9
|
-
buildRAComponent: true
|
|
9
|
+
buildRAComponent: true,
|
|
10
|
+
ActionButton: true
|
|
10
11
|
};
|
|
12
|
+
Object.defineProperty(exports, "ActionButton", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _ActionButton.ActionButton;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
11
18
|
Object.defineProperty(exports, "buildRAComponent", {
|
|
12
19
|
enumerable: true,
|
|
13
20
|
get: function get() {
|
|
@@ -32,6 +39,7 @@ Object.keys(_utils).forEach(function (key) {
|
|
|
32
39
|
});
|
|
33
40
|
});
|
|
34
41
|
var _ui = require("./ui");
|
|
42
|
+
var _ActionButton = require("./buttons/ActionButton");
|
|
35
43
|
function initAdmin() {
|
|
36
44
|
return _initAdmin.apply(this, arguments);
|
|
37
45
|
}
|
package/dist/cjs/views/show.js
CHANGED
|
@@ -12,17 +12,26 @@ var _ActionButton = require("../buttons/ActionButton");
|
|
|
12
12
|
var actions = _ref.actions,
|
|
13
13
|
fields = _ref.fields;
|
|
14
14
|
return function MAShow(props) {
|
|
15
|
-
var Actions = function Actions() {
|
|
16
|
-
return /*#__PURE__*/_react["default"].createElement(_reactAdmin.TopToolbar, null, actions.map(function (props, idx) {
|
|
17
|
-
return /*#__PURE__*/_react["default"].createElement(_ActionButton.ActionButton, (0, _extends2["default"])({
|
|
18
|
-
key: idx,
|
|
19
|
-
resource: resource
|
|
20
|
-
}, props));
|
|
21
|
-
}), /*#__PURE__*/_react["default"].createElement(_reactAdmin.ListButton, null), /*#__PURE__*/_react["default"].createElement(_reactAdmin.EditButton, null));
|
|
22
|
-
};
|
|
23
15
|
return /*#__PURE__*/_react["default"].createElement(_reactAdmin.Show, (0, _extends2["default"])({
|
|
24
|
-
actions:
|
|
16
|
+
actions: (0, _utils.processAdmin)("show-actions", {
|
|
17
|
+
actions: actions,
|
|
18
|
+
resource: resource
|
|
19
|
+
}, resource)
|
|
25
20
|
}, props), /*#__PURE__*/_react["default"].createElement(_reactAdmin.SimpleShowLayout, null, (0, _utils.processAdmin)("show-fields", fields, resource)));
|
|
26
21
|
};
|
|
27
22
|
}));
|
|
23
|
+
|
|
24
|
+
/* Actions */
|
|
25
|
+
(0, _utils.setupAdmin)("show-actions", function (_ref2) {
|
|
26
|
+
var actions = _ref2.actions,
|
|
27
|
+
resource = _ref2.resource;
|
|
28
|
+
return /*#__PURE__*/_react["default"].createElement(_reactAdmin.TopToolbar, null, actions.map(function (props, idx) {
|
|
29
|
+
return /*#__PURE__*/_react["default"].createElement(_ActionButton.ActionButton, (0, _extends2["default"])({
|
|
30
|
+
key: idx,
|
|
31
|
+
resource: resource
|
|
32
|
+
}, props));
|
|
33
|
+
}), /*#__PURE__*/_react["default"].createElement(_reactAdmin.ListButton, null), /*#__PURE__*/_react["default"].createElement(_reactAdmin.EditButton, null));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/* Fields */
|
|
28
37
|
(0, _utils.setupAdmin)("show-fields", _ui["default"]);
|
|
@@ -48,12 +48,14 @@ export var ActionButton = function ActionButton(props) {
|
|
|
48
48
|
resource = props.resource,
|
|
49
49
|
action = props.action;
|
|
50
50
|
var record = useRecordContext();
|
|
51
|
-
var
|
|
51
|
+
var _useAction = useAction(resource, action),
|
|
52
|
+
mutate = _useAction.mutate,
|
|
53
|
+
isLoading = _useAction.isLoading;
|
|
52
54
|
var refresh = useRefresh(),
|
|
53
55
|
notify = useNotify(),
|
|
54
56
|
Icon = icons[icon];
|
|
55
57
|
var onClick = function onClick() {
|
|
56
|
-
|
|
58
|
+
mutate({
|
|
57
59
|
record: record
|
|
58
60
|
}, {
|
|
59
61
|
onSuccess: function onSuccess(_ref3) {
|
|
@@ -75,7 +77,7 @@ export var ActionButton = function ActionButton(props) {
|
|
|
75
77
|
label: label,
|
|
76
78
|
title: title,
|
|
77
79
|
onClick: onClick,
|
|
78
|
-
disabled:
|
|
80
|
+
disabled: isLoading
|
|
79
81
|
}, Icon && /*#__PURE__*/React.createElement(Icon, null));
|
|
80
82
|
};
|
|
81
83
|
export default ActionButton;
|
package/dist/esm/index.js
CHANGED
package/dist/esm/views/show.js
CHANGED
|
@@ -10,17 +10,26 @@ setupAdmin("show", checkParams(function (_ref, resource) {
|
|
|
10
10
|
var actions = _ref.actions,
|
|
11
11
|
fields = _ref.fields;
|
|
12
12
|
return function MAShow(props) {
|
|
13
|
-
var Actions = function Actions() {
|
|
14
|
-
return /*#__PURE__*/React.createElement(TopToolbar, null, actions.map(function (props, idx) {
|
|
15
|
-
return /*#__PURE__*/React.createElement(ActionButton, _extends({
|
|
16
|
-
key: idx,
|
|
17
|
-
resource: resource
|
|
18
|
-
}, props));
|
|
19
|
-
}), /*#__PURE__*/React.createElement(ListButton, null), /*#__PURE__*/React.createElement(EditButton, null));
|
|
20
|
-
};
|
|
21
13
|
return /*#__PURE__*/React.createElement(Show, _extends({
|
|
22
|
-
actions:
|
|
14
|
+
actions: processAdmin("show-actions", {
|
|
15
|
+
actions: actions,
|
|
16
|
+
resource: resource
|
|
17
|
+
}, resource)
|
|
23
18
|
}, props), /*#__PURE__*/React.createElement(SimpleShowLayout, null, processAdmin("show-fields", fields, resource)));
|
|
24
19
|
};
|
|
25
20
|
}));
|
|
21
|
+
|
|
22
|
+
/* Actions */
|
|
23
|
+
setupAdmin("show-actions", function (_ref2) {
|
|
24
|
+
var actions = _ref2.actions,
|
|
25
|
+
resource = _ref2.resource;
|
|
26
|
+
return /*#__PURE__*/React.createElement(TopToolbar, null, actions.map(function (props, idx) {
|
|
27
|
+
return /*#__PURE__*/React.createElement(ActionButton, _extends({
|
|
28
|
+
key: idx,
|
|
29
|
+
resource: resource
|
|
30
|
+
}, props));
|
|
31
|
+
}), /*#__PURE__*/React.createElement(ListButton, null), /*#__PURE__*/React.createElement(EditButton, null));
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/* Fields */
|
|
26
35
|
setupAdmin("show-fields", initRAItems);
|
package/package.json
CHANGED
|
@@ -60,14 +60,14 @@ export const BulkActionButton = ({
|
|
|
60
60
|
export const ActionButton = (props) => {
|
|
61
61
|
const { icon, label, title, resource, action } = props
|
|
62
62
|
const record = useRecordContext()
|
|
63
|
-
const
|
|
63
|
+
const { mutate, isLoading } = useAction(resource, action)
|
|
64
64
|
|
|
65
65
|
const refresh = useRefresh(),
|
|
66
66
|
notify = useNotify(),
|
|
67
67
|
Icon = icons[icon]
|
|
68
68
|
|
|
69
69
|
let onClick = () => {
|
|
70
|
-
|
|
70
|
+
mutate(
|
|
71
71
|
{ record },
|
|
72
72
|
{
|
|
73
73
|
onSuccess: ({ data }) => {
|
|
@@ -85,12 +85,7 @@ export const ActionButton = (props) => {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
return (
|
|
88
|
-
<Button
|
|
89
|
-
label={label}
|
|
90
|
-
title={title}
|
|
91
|
-
onClick={onClick}
|
|
92
|
-
disabled={mutation.isLoading}
|
|
93
|
-
>
|
|
88
|
+
<Button label={label} title={title} onClick={onClick} disabled={isLoading}>
|
|
94
89
|
{Icon && <Icon />}
|
|
95
90
|
</Button>
|
|
96
91
|
)
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { processAdmin } from "./utils"
|
|
|
5
5
|
|
|
6
6
|
export * from "./utils"
|
|
7
7
|
export { buildRAComponent } from "./ui"
|
|
8
|
+
export { ActionButton } from "./buttons/ActionButton"
|
|
8
9
|
|
|
9
10
|
export async function initAdmin(prefix = "") {
|
|
10
11
|
const response = await fetch(`${prefix}/ra.json`)
|
package/src/views/show.jsx
CHANGED
|
@@ -18,18 +18,15 @@ setupAdmin(
|
|
|
18
18
|
checkParams(
|
|
19
19
|
({ actions, fields }, resource) =>
|
|
20
20
|
function MAShow(props) {
|
|
21
|
-
const Actions = () => (
|
|
22
|
-
<TopToolbar>
|
|
23
|
-
{actions.map((props, idx) => {
|
|
24
|
-
return <ActionButton key={idx} resource={resource} {...props} />
|
|
25
|
-
})}
|
|
26
|
-
<ListButton />
|
|
27
|
-
<EditButton />
|
|
28
|
-
</TopToolbar>
|
|
29
|
-
)
|
|
30
|
-
|
|
31
21
|
return (
|
|
32
|
-
<Show
|
|
22
|
+
<Show
|
|
23
|
+
actions={processAdmin(
|
|
24
|
+
"show-actions",
|
|
25
|
+
{ actions, resource },
|
|
26
|
+
resource
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
33
30
|
<SimpleShowLayout>
|
|
34
31
|
{processAdmin("show-fields", fields, resource)}
|
|
35
32
|
</SimpleShowLayout>
|
|
@@ -39,4 +36,16 @@ setupAdmin(
|
|
|
39
36
|
)
|
|
40
37
|
)
|
|
41
38
|
|
|
39
|
+
/* Actions */
|
|
40
|
+
setupAdmin("show-actions", ({ actions, resource }) => (
|
|
41
|
+
<TopToolbar>
|
|
42
|
+
{actions.map((props, idx) => (
|
|
43
|
+
<ActionButton key={idx} resource={resource} {...props} />
|
|
44
|
+
))}
|
|
45
|
+
<ListButton />
|
|
46
|
+
<EditButton />
|
|
47
|
+
</TopToolbar>
|
|
48
|
+
))
|
|
49
|
+
|
|
50
|
+
/* Fields */
|
|
42
51
|
setupAdmin("show-fields", initRAItems)
|