muffin-admin 9.4.1 → 9.4.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/MuffinAdmin.d.ts +2 -1
- package/dist/MuffinAdmin.js +14 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/MuffinAdmin.tsx +23 -6
- package/src/index.tsx +1 -1
package/package.json
CHANGED
package/src/MuffinAdmin.tsx
CHANGED
|
@@ -13,8 +13,10 @@ import {
|
|
|
13
13
|
LayoutProps,
|
|
14
14
|
localStorageStore,
|
|
15
15
|
Login,
|
|
16
|
+
LoginProps,
|
|
16
17
|
} from "react-admin"
|
|
17
18
|
|
|
19
|
+
import { useEffect } from "react"
|
|
18
20
|
import { ConfirmationProvider } from "./common"
|
|
19
21
|
import { useMuffinAdminOpts } from "./hooks"
|
|
20
22
|
import { buildProvider, muffinTranslations } from "./i18n"
|
|
@@ -28,11 +30,11 @@ export function MuffinAdmin(props: AdminProps) {
|
|
|
28
30
|
const muffinI18nProvider = buildProvider(
|
|
29
31
|
backendLocales
|
|
30
32
|
? Object.fromEntries(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
Object.entries(muffinTranslations).map(([locale, messages]) => [
|
|
34
|
+
locale,
|
|
35
|
+
deepMerge({}, messages, backendLocales[locale], buildAdmin(["locale", locale]) || {}),
|
|
36
|
+
])
|
|
37
|
+
)
|
|
36
38
|
: muffinTranslations
|
|
37
39
|
)
|
|
38
40
|
|
|
@@ -132,5 +134,20 @@ export function MuffinAppBar(props: AppBarProps) {
|
|
|
132
134
|
|
|
133
135
|
setupAdmin(["appbar"], MuffinAppBar)
|
|
134
136
|
|
|
137
|
+
export function MuffinLogin(props: LoginProps) {
|
|
138
|
+
const {
|
|
139
|
+
auth: { loginURL },
|
|
140
|
+
} = useMuffinAdminOpts()
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (loginURL) {
|
|
143
|
+
const { pathname, search } = window.location
|
|
144
|
+
const url = new URL(loginURL)
|
|
145
|
+
url.searchParams.set("redirect", pathname + search)
|
|
146
|
+
window.location.replace(url.toString())
|
|
147
|
+
}
|
|
148
|
+
}, [loginURL])
|
|
149
|
+
return <Login {...props} />
|
|
150
|
+
}
|
|
151
|
+
|
|
135
152
|
// Initialize login page
|
|
136
|
-
setupAdmin(["loginpage"],
|
|
153
|
+
setupAdmin(["loginpage"], MuffinLogin)
|
package/src/index.tsx
CHANGED