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/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type TProps = {
|
|
|
3
3
|
};
|
|
4
4
|
export type AdminAction = {
|
|
5
5
|
view?: ("show" | "edit" | "list" | "bulk")[];
|
|
6
|
+
help?: string;
|
|
6
7
|
id: string;
|
|
7
8
|
label: string;
|
|
8
9
|
title: string;
|
|
@@ -36,11 +37,13 @@ export type AdminPayloadProps = {
|
|
|
36
37
|
onHandle: (payload?: any) => void;
|
|
37
38
|
title?: string;
|
|
38
39
|
schema?: AdminInput[];
|
|
40
|
+
help?: string;
|
|
39
41
|
};
|
|
40
42
|
export type AdminResourceProps = {
|
|
41
43
|
name: string;
|
|
42
44
|
icon?: string;
|
|
43
45
|
label: string;
|
|
46
|
+
help?: string;
|
|
44
47
|
actions: AdminAction[];
|
|
45
48
|
create: AdminInput[] | false;
|
|
46
49
|
edit: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muffin-admin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "NPM package for https://github.com/klen/muffin-admin",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"homepage": "https://github.com/klen/muffin-admin#readme",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"js-cookie": "^3.0.5",
|
|
27
|
+
"ra-language-russian": "^4.14.2",
|
|
27
28
|
"react": "^18.3.1",
|
|
28
29
|
"react-admin": "^5.0.3",
|
|
29
30
|
"react-dom": "^18.3.1",
|
package/src/MuffinAdmin.tsx
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
AdminUI,
|
|
9
9
|
AppBar,
|
|
10
10
|
AppBarProps,
|
|
11
|
-
defaultI18nProvider,
|
|
12
11
|
Layout,
|
|
13
12
|
LayoutProps,
|
|
14
13
|
localStorageStore,
|
|
@@ -17,6 +16,7 @@ import {
|
|
|
17
16
|
|
|
18
17
|
import { ConfirmationProvider } from "./common"
|
|
19
18
|
import { useMuffinAdminOpts } from "./hooks"
|
|
19
|
+
import { muffinI18nProvider } from "./i18n"
|
|
20
20
|
import { buildAdmin, findBuilder, findIcon, setupAdmin } from "./utils"
|
|
21
21
|
|
|
22
22
|
export function MuffinAdmin(props: AdminProps) {
|
|
@@ -33,7 +33,7 @@ export function MuffinAdmin(props: AdminProps) {
|
|
|
33
33
|
dashboard = findBuilder(["dashboard"]),
|
|
34
34
|
disableTelemetry,
|
|
35
35
|
error,
|
|
36
|
-
i18nProvider =
|
|
36
|
+
i18nProvider = muffinI18nProvider,
|
|
37
37
|
layout = findBuilder(["layout"]),
|
|
38
38
|
loading,
|
|
39
39
|
loginPage = findBuilder(["loginpage"]),
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "react-admin"
|
|
16
16
|
import { buildRA } from "./buildRA"
|
|
17
17
|
import { ActionButton, BulkActionButton } from "./buttons"
|
|
18
|
+
import { HelpLink } from "./common/HelpLink"
|
|
18
19
|
import { useMuffinResourceOpts } from "./hooks"
|
|
19
20
|
import { buildAdmin, findBuilder, setupAdmin } from "./utils"
|
|
20
21
|
|
|
@@ -73,12 +74,14 @@ setupAdmin(["list-grid-buttons"], MuffinListGridButtons)
|
|
|
73
74
|
function MuffinListToolbar() {
|
|
74
75
|
const {
|
|
75
76
|
actions: baseActions = [],
|
|
77
|
+
help,
|
|
76
78
|
list: { create },
|
|
77
79
|
} = useMuffinResourceOpts()
|
|
78
80
|
const actions = baseActions.filter((a) => a.view.includes("list"))
|
|
79
81
|
return (
|
|
80
82
|
<TopToolbar>
|
|
81
83
|
<SelectColumnsButton />
|
|
84
|
+
{help && <HelpLink href={help} />}
|
|
82
85
|
<FilterButton />
|
|
83
86
|
{actions.length ? actions.map((props) => <ActionButton key={props.id} {...props} />) : null}
|
|
84
87
|
{create && <CreateButton />}
|
|
@@ -9,9 +9,11 @@ import {
|
|
|
9
9
|
} from "react-admin"
|
|
10
10
|
import { FormProvider } from "react-hook-form"
|
|
11
11
|
|
|
12
|
+
import { Stack } from "@mui/material"
|
|
12
13
|
import { useState } from "react"
|
|
13
14
|
import { buildRA } from "../buildRA"
|
|
14
15
|
import { AdminModal, PayloadButtons, useConfirmation } from "../common"
|
|
16
|
+
import { HelpLink } from "../common/HelpLink"
|
|
15
17
|
import { useAction } from "../hooks/useAction"
|
|
16
18
|
import { AdminAction, AdminPayloadProps } from "../types"
|
|
17
19
|
import { buildIcon, findBuilder } from "../utils"
|
|
@@ -66,6 +68,7 @@ function ActionButtonBase({
|
|
|
66
68
|
icon,
|
|
67
69
|
schema,
|
|
68
70
|
id,
|
|
71
|
+
help,
|
|
69
72
|
}: Omit<AdminAction, "paths"> & {
|
|
70
73
|
isPending?: boolean
|
|
71
74
|
onHandle: (payload?: any) => void
|
|
@@ -96,13 +99,21 @@ function ActionButtonBase({
|
|
|
96
99
|
onClose={() => setPayloadActive(false)}
|
|
97
100
|
title={title || label}
|
|
98
101
|
schema={schema}
|
|
102
|
+
help={help}
|
|
99
103
|
/>
|
|
100
104
|
)}
|
|
101
105
|
</>
|
|
102
106
|
)
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
export function CommonPayload({
|
|
109
|
+
export function CommonPayload({
|
|
110
|
+
active,
|
|
111
|
+
onClose,
|
|
112
|
+
onHandle,
|
|
113
|
+
schema,
|
|
114
|
+
title,
|
|
115
|
+
help,
|
|
116
|
+
}: AdminPayloadProps) {
|
|
106
117
|
schema[0][1] = { ...schema[0][1], autoFocus: true }
|
|
107
118
|
const inputs = buildRA(schema)
|
|
108
119
|
const translate = useTranslate()
|
|
@@ -122,7 +133,16 @@ export function CommonPayload({ active, onClose, onHandle, schema, title }: Admi
|
|
|
122
133
|
maxWidth="sm"
|
|
123
134
|
open={active}
|
|
124
135
|
onClose={onClose}
|
|
125
|
-
title={
|
|
136
|
+
title={
|
|
137
|
+
help
|
|
138
|
+
? ((
|
|
139
|
+
<Stack alignItems="flex-start">
|
|
140
|
+
<span>{translate(title, { _: title })}</span>
|
|
141
|
+
<HelpLink href={help} style={{ alignSelf: "flex-end" }} />
|
|
142
|
+
</Stack>
|
|
143
|
+
) as any)
|
|
144
|
+
: translate(title, { _: title })
|
|
145
|
+
}
|
|
126
146
|
actions={
|
|
127
147
|
<PayloadButtons
|
|
128
148
|
onClose={onClose}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import HelpIcon from "@mui/icons-material/Help"
|
|
2
|
+
import Link from "@mui/material/Link"
|
|
3
|
+
import { Button, useTranslate } from "react-admin"
|
|
4
|
+
|
|
5
|
+
export function HelpLink({ label, ...props }: Parameters<typeof Button>[0]) {
|
|
6
|
+
const translate = useTranslate()
|
|
7
|
+
label = label || translate("muffin.instructions")
|
|
8
|
+
return (
|
|
9
|
+
<Button component={Link} label={label} target="_blank" {...props}>
|
|
10
|
+
<HelpIcon />
|
|
11
|
+
</Button>
|
|
12
|
+
)
|
|
13
|
+
}
|
package/src/i18n/en.ts
ADDED
package/src/i18n/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./provider"
|
package/src/i18n/provider.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
|
|
8
|
+
const translations = {
|
|
9
|
+
en: { ...raEnglishMessages, ...muffinEnglishMessages },
|
|
10
|
+
ru: { ...raRussianMessages, ...muffinRussianMessages },
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const muffinI18nProvider = polyglotI18nProvider(
|
|
14
|
+
(locale) => (translations[locale] ? translations[locale] : translations.en),
|
|
15
|
+
resolveBrowserLocale(),
|
|
16
|
+
[
|
|
17
|
+
{ locale: "en", name: "English" },
|
|
18
|
+
{ locale: "ru", name: "Русский" },
|
|
19
|
+
],
|
|
20
|
+
{ allowMissing: true }
|
|
21
|
+
)
|
package/src/i18n/ru.ts
ADDED
package/src/types.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type TProps = {
|
|
|
4
4
|
|
|
5
5
|
export type AdminAction = {
|
|
6
6
|
view?: ("show" | "edit" | "list" | "bulk")[]
|
|
7
|
+
help?: string
|
|
7
8
|
id: string
|
|
8
9
|
label: string
|
|
9
10
|
title: string
|
|
@@ -34,12 +35,14 @@ export type AdminPayloadProps = {
|
|
|
34
35
|
onHandle: (payload?: any) => void
|
|
35
36
|
title?: string
|
|
36
37
|
schema?: AdminInput[]
|
|
38
|
+
help?: string
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
export type AdminResourceProps = {
|
|
40
42
|
name: string
|
|
41
43
|
icon?: string
|
|
42
44
|
label: string
|
|
45
|
+
help?: string
|
|
43
46
|
actions: AdminAction[]
|
|
44
47
|
create: AdminInput[] | false
|
|
45
48
|
edit:
|