muffin-admin 1.44.1 → 1.44.3
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/authprovider.js +21 -6
- package/dist/cjs/buttons/ActionButton.js +7 -5
- package/dist/cjs/index.js +9 -1
- package/dist/esm/authprovider.js +21 -6
- package/dist/esm/buttons/ActionButton.js +5 -3
- package/dist/esm/index.js +1 -0
- package/package.json +13 -13
- package/src/authprovider.js +3 -3
- package/src/buttons/ActionButton.jsx +3 -8
- package/src/index.js +1 -0
package/dist/cjs/authprovider.js
CHANGED
|
@@ -98,11 +98,11 @@ var _default = function _default(props) {
|
|
|
98
98
|
}(),
|
|
99
99
|
checkError: function () {
|
|
100
100
|
var _checkError = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(error) {
|
|
101
|
-
var status;
|
|
101
|
+
var _ref4, status;
|
|
102
102
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
103
103
|
while (1) switch (_context3.prev = _context3.next) {
|
|
104
104
|
case 0:
|
|
105
|
-
status =
|
|
105
|
+
_ref4 = error || {}, status = _ref4.status;
|
|
106
106
|
if (!(status == 401 || status == 403)) {
|
|
107
107
|
_context3.next = 4;
|
|
108
108
|
break;
|
|
@@ -190,10 +190,25 @@ var _default = function _default(props) {
|
|
|
190
190
|
return logout;
|
|
191
191
|
}(),
|
|
192
192
|
getIdentity: getIdentity,
|
|
193
|
-
getPermissions: function
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
getPermissions: function () {
|
|
194
|
+
var _getPermissions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
|
|
195
|
+
var role;
|
|
196
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
197
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
198
|
+
case 0:
|
|
199
|
+
role = authGet(storage_name + "_role");
|
|
200
|
+
return _context6.abrupt("return", role || "");
|
|
201
|
+
case 2:
|
|
202
|
+
case "end":
|
|
203
|
+
return _context6.stop();
|
|
204
|
+
}
|
|
205
|
+
}, _callee6);
|
|
206
|
+
}));
|
|
207
|
+
function getPermissions() {
|
|
208
|
+
return _getPermissions.apply(this, arguments);
|
|
209
|
+
}
|
|
210
|
+
return getPermissions;
|
|
211
|
+
}()
|
|
197
212
|
};
|
|
198
213
|
};
|
|
199
214
|
exports["default"] = _default;
|
|
@@ -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/esm/authprovider.js
CHANGED
|
@@ -91,11 +91,11 @@ export default (function (props) {
|
|
|
91
91
|
}(),
|
|
92
92
|
checkError: function () {
|
|
93
93
|
var _checkError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(error) {
|
|
94
|
-
var status;
|
|
94
|
+
var _ref4, status;
|
|
95
95
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
96
96
|
while (1) switch (_context3.prev = _context3.next) {
|
|
97
97
|
case 0:
|
|
98
|
-
status =
|
|
98
|
+
_ref4 = error || {}, status = _ref4.status;
|
|
99
99
|
if (!(status == 401 || status == 403)) {
|
|
100
100
|
_context3.next = 4;
|
|
101
101
|
break;
|
|
@@ -183,9 +183,24 @@ export default (function (props) {
|
|
|
183
183
|
return logout;
|
|
184
184
|
}(),
|
|
185
185
|
getIdentity: getIdentity,
|
|
186
|
-
getPermissions: function
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
getPermissions: function () {
|
|
187
|
+
var _getPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
188
|
+
var role;
|
|
189
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
190
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
191
|
+
case 0:
|
|
192
|
+
role = authGet(storage_name + "_role");
|
|
193
|
+
return _context6.abrupt("return", role || "");
|
|
194
|
+
case 2:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context6.stop();
|
|
197
|
+
}
|
|
198
|
+
}, _callee6);
|
|
199
|
+
}));
|
|
200
|
+
function getPermissions() {
|
|
201
|
+
return _getPermissions.apply(this, arguments);
|
|
202
|
+
}
|
|
203
|
+
return getPermissions;
|
|
204
|
+
}()
|
|
190
205
|
};
|
|
191
206
|
});
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muffin-admin",
|
|
3
|
-
"version": "1.44.
|
|
3
|
+
"version": "1.44.3",
|
|
4
4
|
"description": "NPM package for https://github.com/klen/muffin-admin",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -22,25 +22,25 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/klen/muffin-admin#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mui/icons-material": "^5.
|
|
26
|
-
"@mui/material": "^5.
|
|
25
|
+
"@mui/icons-material": "^5.14.1",
|
|
26
|
+
"@mui/material": "^5.14.2",
|
|
27
27
|
"js-cookie": "^3.0.5",
|
|
28
|
-
"ra-ui-materialui": "^4.
|
|
28
|
+
"ra-ui-materialui": "^4.12.2",
|
|
29
29
|
"react": "^18.2.0",
|
|
30
|
-
"react-admin": "^4.
|
|
30
|
+
"react-admin": "^4.12.2",
|
|
31
31
|
"react-dom": "^18.2.0",
|
|
32
32
|
"validator": "^13.9.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@babel/cli": "^7.22.
|
|
36
|
-
"@babel/core": "^7.22.
|
|
37
|
-
"@babel/eslint-parser": "^7.22.
|
|
38
|
-
"@babel/plugin-transform-runtime": "^7.22.
|
|
39
|
-
"@babel/preset-env": "^7.22.
|
|
35
|
+
"@babel/cli": "^7.22.9",
|
|
36
|
+
"@babel/core": "^7.22.9",
|
|
37
|
+
"@babel/eslint-parser": "^7.22.9",
|
|
38
|
+
"@babel/plugin-transform-runtime": "^7.22.9",
|
|
39
|
+
"@babel/preset-env": "^7.22.9",
|
|
40
40
|
"@babel/preset-react": "^7.22.5",
|
|
41
|
-
"babel-loader": "^9.1.
|
|
42
|
-
"eslint-plugin-react": "^7.
|
|
43
|
-
"webpack": "^5.88.
|
|
41
|
+
"babel-loader": "^9.1.3",
|
|
42
|
+
"eslint-plugin-react": "^7.33.0",
|
|
43
|
+
"webpack": "^5.88.2",
|
|
44
44
|
"webpack-cli": "^5.1.4",
|
|
45
45
|
"webpack-dev-server": "^4.15.1"
|
|
46
46
|
}
|
package/src/authprovider.js
CHANGED
|
@@ -42,7 +42,7 @@ export default (props) => {
|
|
|
42
42
|
},
|
|
43
43
|
|
|
44
44
|
checkError: async (error) => {
|
|
45
|
-
const { status } = error
|
|
45
|
+
const { status } = error || {}
|
|
46
46
|
|
|
47
47
|
if (status == 401 || status == 403) {
|
|
48
48
|
// Clean storage
|
|
@@ -77,9 +77,9 @@ export default (props) => {
|
|
|
77
77
|
|
|
78
78
|
getIdentity,
|
|
79
79
|
|
|
80
|
-
getPermissions: () => {
|
|
80
|
+
getPermissions: async () => {
|
|
81
81
|
const role = authGet(storage_name + "_role")
|
|
82
|
-
return role
|
|
82
|
+
return role || ""
|
|
83
83
|
},
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -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`)
|