muffin-admin 3.8.5 → 3.9.0
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 +3 -2
- package/dist/MuffinResourceList.js +3 -2
- package/dist/buttons/ActionButton.d.ts +1 -1
- package/dist/buttons/ActionButton.js +8 -4
- package/dist/common/HelpLink.d.ts +2 -0
- package/dist/common/HelpLink.js +21 -0
- package/dist/i18n/en.d.ts +6 -0
- package/dist/i18n/en.js +6 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/provider.d.ts +1 -0
- package/dist/i18n/provider.js +14 -0
- package/dist/i18n/ru.d.ts +6 -0
- package/dist/i18n/ru.js +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +2 -1
- package/src/MuffinAdmin.tsx +2 -2
- package/src/MuffinResourceList.tsx +3 -0
- package/src/buttons/ActionButton.tsx +22 -2
- package/src/common/HelpLink.tsx +13 -0
- package/src/i18n/en.ts +7 -0
- package/src/i18n/index.ts +1 -0
- package/src/i18n/provider.ts +21 -0
- package/src/i18n/ru.ts +7 -0
- package/src/types.ts +3 -0
package/dist/MuffinAdmin.js
CHANGED
|
@@ -3,15 +3,16 @@ import IconButton from "@mui/material/IconButton";
|
|
|
3
3
|
import SvgIcon from "@mui/material/SvgIcon";
|
|
4
4
|
import Tooltip from "@mui/material/Tooltip";
|
|
5
5
|
import Typography from "@mui/material/Typography";
|
|
6
|
-
import { AdminContext, AdminUI, AppBar,
|
|
6
|
+
import { AdminContext, AdminUI, AppBar, Layout, localStorageStore, Login, } from "react-admin";
|
|
7
7
|
import { ConfirmationProvider } from "./common";
|
|
8
8
|
import { useMuffinAdminOpts } from "./hooks";
|
|
9
|
+
import { muffinI18nProvider } from "./i18n";
|
|
9
10
|
import { buildAdmin, findBuilder, findIcon, setupAdmin } from "./utils";
|
|
10
11
|
export function MuffinAdmin(props) {
|
|
11
12
|
const opts = useMuffinAdminOpts();
|
|
12
13
|
const { resources = [], auth, adminProps, apiUrl } = opts;
|
|
13
14
|
document.title = (adminProps === null || adminProps === void 0 ? void 0 : adminProps.title) || "Muffin Admin";
|
|
14
|
-
const { basename, authProvider = findBuilder(["authprovider"])(auth), dataProvider = findBuilder(["dataprovider"])(apiUrl), catchAll, dashboard = findBuilder(["dashboard"]), disableTelemetry, error, i18nProvider =
|
|
15
|
+
const { basename, authProvider = findBuilder(["authprovider"])(auth), dataProvider = findBuilder(["dataprovider"])(apiUrl), catchAll, dashboard = findBuilder(["dashboard"]), disableTelemetry, error, i18nProvider = muffinI18nProvider, layout = findBuilder(["layout"]), loading, loginPage = findBuilder(["loginpage"]), authCallbackPage, notification, queryClient, requireAuth = auth.required, store = localStorageStore(), ready, theme, lightTheme, darkTheme, defaultTheme, title = "React Admin", } = props;
|
|
15
16
|
return (_jsx(AdminContext, { authProvider: authProvider, basename: basename, dataProvider: dataProvider, i18nProvider: i18nProvider, store: store, queryClient: queryClient, theme: theme, lightTheme: lightTheme, darkTheme: darkTheme, defaultTheme: defaultTheme, children: _jsx(ConfirmationProvider, { children: _jsx(AdminUI, { layout: layout, dashboard: dashboard, disableTelemetry: disableTelemetry, catchAll: catchAll, error: error, title: title, loading: loading, loginPage: loginPage, authCallbackPage: authCallbackPage, notification: notification, requireAuth: requireAuth, ready: ready, children: resources === null || resources === void 0 ? void 0 : resources.map(({ name }) => buildAdmin(["resource", name], { name })) }) }) }));
|
|
16
17
|
}
|
|
17
18
|
setupAdmin(["admin"], MuffinAdmin);
|
|
@@ -4,6 +4,7 @@ import uniq from "lodash/uniq";
|
|
|
4
4
|
import { BulkDeleteButton, BulkExportButton, CreateButton, DatagridConfigurable, EditButton, ExportButton, FilterButton, List, Pagination, SelectColumnsButton, TopToolbar, } from "react-admin";
|
|
5
5
|
import { buildRA } from "./buildRA";
|
|
6
6
|
import { ActionButton, BulkActionButton } from "./buttons";
|
|
7
|
+
import { HelpLink } from "./common/HelpLink";
|
|
7
8
|
import { useMuffinResourceOpts } from "./hooks";
|
|
8
9
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils";
|
|
9
10
|
export function MuffinList() {
|
|
@@ -32,9 +33,9 @@ function MuffinListGridButtons() {
|
|
|
32
33
|
}
|
|
33
34
|
setupAdmin(["list-grid-buttons"], MuffinListGridButtons);
|
|
34
35
|
function MuffinListToolbar() {
|
|
35
|
-
const { actions: baseActions = [], list: { create }, } = useMuffinResourceOpts();
|
|
36
|
+
const { actions: baseActions = [], help, list: { create }, } = useMuffinResourceOpts();
|
|
36
37
|
const actions = baseActions.filter((a) => a.view.includes("list"));
|
|
37
|
-
return (_jsxs(TopToolbar, { children: [_jsx(SelectColumnsButton, {}), _jsx(FilterButton, {}), actions.length ? actions.map((props) => _jsx(ActionButton, Object.assign({}, props), props.id)) : null, create && _jsx(CreateButton, {}), _jsx(ExportButton, {})] }));
|
|
38
|
+
return (_jsxs(TopToolbar, { children: [_jsx(SelectColumnsButton, {}), help && _jsx(HelpLink, { href: help }), _jsx(FilterButton, {}), actions.length ? actions.map((props) => _jsx(ActionButton, Object.assign({}, props), props.id)) : null, create && _jsx(CreateButton, {}), _jsx(ExportButton, {})] }));
|
|
38
39
|
}
|
|
39
40
|
setupAdmin(["list-toolbar"], MuffinListToolbar);
|
|
40
41
|
function MuffinListBulkActions() {
|
|
@@ -6,4 +6,4 @@ export type ActionPayloadProps = {
|
|
|
6
6
|
};
|
|
7
7
|
export declare function ActionButton({ paths, confirm, ...props }: AdminAction): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export declare function BulkActionButton({ paths, confirm, ...props }: AdminAction): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export declare function CommonPayload({ active, onClose, onHandle, schema, title }: AdminPayloadProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function CommonPayload({ active, onClose, onHandle, schema, title, help, }: AdminPayloadProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,9 +21,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
22
|
import { Button, FormGroupsProvider, useAugmentedForm, useListContext, useRecordContext, useResourceContext, useTranslate, } from "react-admin";
|
|
23
23
|
import { FormProvider } from "react-hook-form";
|
|
24
|
+
import { Stack } from "@mui/material";
|
|
24
25
|
import { useState } from "react";
|
|
25
26
|
import { buildRA } from "../buildRA";
|
|
26
27
|
import { AdminModal, PayloadButtons, useConfirmation } from "../common";
|
|
28
|
+
import { HelpLink } from "../common/HelpLink";
|
|
27
29
|
import { useAction } from "../hooks/useAction";
|
|
28
30
|
import { buildIcon, findBuilder } from "../utils";
|
|
29
31
|
export function ActionButton(_a) {
|
|
@@ -56,7 +58,7 @@ export function BulkActionButton(_a) {
|
|
|
56
58
|
});
|
|
57
59
|
return _jsx(ActionButtonBase, Object.assign({}, props, { onHandle: onHandle, isPending: isPending }));
|
|
58
60
|
}
|
|
59
|
-
function ActionButtonBase({ label, title, onHandle, isPending, icon, schema, id, }) {
|
|
61
|
+
function ActionButtonBase({ label, title, onHandle, isPending, icon, schema, id, help, }) {
|
|
60
62
|
const resource = useResourceContext();
|
|
61
63
|
const [payloadActive, setPayloadActive] = useState(false);
|
|
62
64
|
const PayloadBuilder = findBuilder(["action", "payload", id, resource]) || (schema && CommonPayload);
|
|
@@ -65,9 +67,9 @@ function ActionButtonBase({ label, title, onHandle, isPending, icon, schema, id,
|
|
|
65
67
|
setPayloadActive(true);
|
|
66
68
|
else
|
|
67
69
|
onHandle();
|
|
68
|
-
}, disabled: isPending, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onHandle: onHandle, onClose: () => setPayloadActive(false), title: title || label, schema: schema }))] }));
|
|
70
|
+
}, disabled: isPending, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onHandle: onHandle, onClose: () => setPayloadActive(false), title: title || label, schema: schema, help: help }))] }));
|
|
69
71
|
}
|
|
70
|
-
export function CommonPayload({ active, onClose, onHandle, schema, title }) {
|
|
72
|
+
export function CommonPayload({ active, onClose, onHandle, schema, title, help, }) {
|
|
71
73
|
schema[0][1] = Object.assign(Object.assign({}, schema[0][1]), { autoFocus: true });
|
|
72
74
|
const inputs = buildRA(schema);
|
|
73
75
|
const translate = useTranslate();
|
|
@@ -79,5 +81,7 @@ export function CommonPayload({ active, onClose, onHandle, schema, title }) {
|
|
|
79
81
|
},
|
|
80
82
|
record: {},
|
|
81
83
|
});
|
|
82
|
-
return (_jsx(FormProvider, Object.assign({}, form, { children: _jsx(FormGroupsProvider, { children: _jsx(AdminModal, { maxWidth: "sm", open: active, onClose: onClose, title:
|
|
84
|
+
return (_jsx(FormProvider, Object.assign({}, form, { children: _jsx(FormGroupsProvider, { children: _jsx(AdminModal, { maxWidth: "sm", open: active, onClose: onClose, title: help
|
|
85
|
+
? (_jsxs(Stack, { alignItems: "flex-start", children: [_jsx("span", { children: translate(title, { _: title }) }), _jsx(HelpLink, { href: help, style: { alignSelf: "flex-end" } })] }))
|
|
86
|
+
: translate(title, { _: title }), actions: _jsx(PayloadButtons, { onClose: onClose, onSubmit: formHandleSubmit, isValid: form.formState.isValid }), children: inputs }) }) })));
|
|
83
87
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import HelpIcon from "@mui/icons-material/Help";
|
|
14
|
+
import Link from "@mui/material/Link";
|
|
15
|
+
import { Button, useTranslate } from "react-admin";
|
|
16
|
+
export function HelpLink(_a) {
|
|
17
|
+
var { label } = _a, props = __rest(_a, ["label"]);
|
|
18
|
+
const translate = useTranslate();
|
|
19
|
+
label = label || translate("muffin.instructions");
|
|
20
|
+
return (_jsx(Button, Object.assign({ component: Link, label: label, target: "_blank" }, props, { children: _jsx(HelpIcon, {}) })));
|
|
21
|
+
}
|
package/dist/i18n/en.js
ADDED
package/dist/i18n/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./provider";
|
package/dist/i18n/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./provider";
|
package/dist/i18n/provider.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const muffinI18nProvider: import("react-admin").I18nProvider;
|
package/dist/i18n/provider.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import polyglotI18nProvider from "ra-i18n-polyglot";
|
|
2
|
+
import raEnglishMessages from "ra-language-english";
|
|
3
|
+
import raRussianMessages from "ra-language-russian";
|
|
4
|
+
import { resolveBrowserLocale } from "react-admin";
|
|
5
|
+
import muffinEnglishMessages from "./en";
|
|
6
|
+
import muffinRussianMessages from "./ru";
|
|
7
|
+
const translations = {
|
|
8
|
+
en: Object.assign(Object.assign({}, raEnglishMessages), muffinEnglishMessages),
|
|
9
|
+
ru: Object.assign(Object.assign({}, raRussianMessages), muffinRussianMessages),
|
|
10
|
+
};
|
|
11
|
+
export const muffinI18nProvider = polyglotI18nProvider((locale) => (translations[locale] ? translations[locale] : translations.en), resolveBrowserLocale(), [
|
|
12
|
+
{ locale: "en", name: "English" },
|
|
13
|
+
{ locale: "ru", name: "Русский" },
|
|
14
|
+
], { allowMissing: true });
|