muffin-admin 1.45.2 → 1.45.4
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/MuffinAdmin.js +2 -2
- package/dist/MuffinDashboard.d.ts +3 -1
- package/dist/MuffinDashboard.js +10 -3
- package/dist/actions/LinkAction.d.ts +1 -1
- package/dist/actions/LinkAction.js +19 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/MuffinAdmin.tsx +5 -5
- package/src/MuffinDashboard.tsx +19 -7
- package/src/actions/LinkAction.tsx +8 -2
- package/src/index.tsx +1 -0
- package/src/types.ts +1 -0
package/dist/MuffinAdmin.js
CHANGED
|
@@ -10,7 +10,7 @@ const darkTheme = createTheme({
|
|
|
10
10
|
palette: { mode: "dark" },
|
|
11
11
|
});
|
|
12
12
|
export function MuffinAdmin(props) {
|
|
13
|
-
const { resources, auth, appBarLinks } = props;
|
|
13
|
+
const { resources, auth, appBarLinks, dashboard } = props;
|
|
14
14
|
const children = resources.map((resource) => buildAdmin(["resource", resource.name], Object.assign(Object.assign({}, resource), { key: resource.name })));
|
|
15
15
|
const appBar = (props) => (_jsxs(AppBar, Object.assign({}, props, { children: [_jsx(Typography, { variant: "h6", color: "inherit", id: "react-admin-title", style: {
|
|
16
16
|
flex: 1,
|
|
@@ -18,7 +18,7 @@ export function MuffinAdmin(props) {
|
|
|
18
18
|
whiteSpace: "nowrap",
|
|
19
19
|
overflow: "hidden",
|
|
20
20
|
} }), _jsx(ToggleThemeButton, { lightTheme: defaultTheme, darkTheme: darkTheme }), appBarLinks.map((info) => (_jsx(Tooltip, { title: info.title, children: _jsx(IconButton, { color: "inherit", href: info.url, children: _jsx(SvgIcon, { component: findIcon(info.icon) }) }) }, info.url)))] })));
|
|
21
|
-
return (_jsx(AdminPropsContext.Provider, { value: props, children: _jsx(Admin, {
|
|
21
|
+
return (_jsx(AdminPropsContext.Provider, { value: props, children: _jsx(Admin, { authProvider: buildAdmin(["authprovider"], auth), dashboard: buildAdmin(["dashboard"], dashboard), dataProvider: buildAdmin(["dataprovider"], props), layout: (props) => _jsx(Layout, Object.assign({}, props, { appBar: appBar })), loginPage: findBuilder(["loginpage"]), requireAuth: auth.required, children: children }) }));
|
|
22
22
|
}
|
|
23
23
|
setupAdmin(["admin"], MuffinAdmin);
|
|
24
24
|
// Initialize login page
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { AdminOpts } from "./types";
|
|
2
|
-
export declare function MuffinDashboard(
|
|
2
|
+
export declare function MuffinDashboard({ src }: {
|
|
3
|
+
src: AdminOpts["dashboard"];
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
package/dist/MuffinDashboard.js
CHANGED
|
@@ -7,10 +7,17 @@ import TableBody from "@mui/material/TableBody";
|
|
|
7
7
|
import TableCell from "@mui/material/TableCell";
|
|
8
8
|
import TableRow from "@mui/material/TableRow";
|
|
9
9
|
import Typography from "@mui/material/Typography";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import { setupAdmin } from "./utils";
|
|
11
|
+
export function MuffinDashboard({ src }) {
|
|
12
|
+
return (_jsx(Grid, { container: true, spacing: 1, children: _jsx(AdminCards, { src: src }) }));
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function AdminCards({ src }) {
|
|
15
|
+
if (Array.isArray(src))
|
|
16
|
+
return (_jsx(Grid, { container: true, item: true, spacing: 2, children: src.map((card, idx) => (_jsx(AdminCards, { src: card }, idx))) }));
|
|
17
|
+
return _jsx(DashboardCard, Object.assign({}, src));
|
|
18
|
+
}
|
|
19
|
+
function DashboardCard({ title, value }) {
|
|
14
20
|
return (_jsx(Grid, { item: true, xs: true, children: _jsx(Card, { children: _jsxs(CardContent, { children: [_jsx(Typography, { variant: "h5", component: "h2", m: 2, style: { textAlign: "center" }, children: title }), (Array.isArray(value) && _jsx(AdminTableView, { src: value })) || (_jsx("pre", { children: JSON.stringify(value, null, 2) }))] }) }) }));
|
|
15
21
|
}
|
|
16
22
|
const AdminTableView = ({ src }) => (_jsx(Table, { children: _jsx(TableBody, { children: src.map((row, idx) => (_jsx(TableRow, { hover: true, children: row.map((cell, idx) => (_jsx(TableCell, { children: cell }, idx))) }, idx))) }) }));
|
|
23
|
+
setupAdmin(["dashboard"], (dashboard) => () => _jsx(MuffinDashboard, { src: dashboard }));
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useContext } from "react";
|
|
2
14
|
import { useRecordContext, useResourceContext } from "react-admin";
|
|
3
15
|
import LinkButton from "../buttons/LinkButton";
|
|
4
|
-
|
|
16
|
+
import { AdminPropsContext } from "../utils";
|
|
17
|
+
export function LinkAction(_a) {
|
|
18
|
+
var _b;
|
|
19
|
+
var { fk, icon } = _a, props = __rest(_a, ["fk", "icon"]);
|
|
20
|
+
const adminProps = useContext(AdminPropsContext);
|
|
5
21
|
const record = useRecordContext();
|
|
6
22
|
const currentResource = useResourceContext();
|
|
7
23
|
if (!record)
|
|
8
24
|
return null;
|
|
9
|
-
|
|
25
|
+
icon = icon || ((_b = adminProps === null || adminProps === void 0 ? void 0 : adminProps.resources[props.resource]) === null || _b === void 0 ? void 0 : _b.icon);
|
|
26
|
+
return _jsx(LinkButton, Object.assign({}, props, { icon: icon, filters: { [currentResource]: record[fk || "id"] } }));
|
|
10
27
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { createRoot } from "react-dom/client";
|
|
11
11
|
import { buildAdmin } from "./utils";
|
|
12
12
|
export * from "./MuffinAdmin";
|
|
13
|
+
export * from "./MuffinDashboard";
|
|
13
14
|
export * from "./MuffinResource";
|
|
14
15
|
export * from "./MuffinResourceCreate";
|
|
15
16
|
export * from "./MuffinResourceEdit";
|